Skip to content

Commit 7a9d2b6

Browse files
Fixes #17
Parameters should be unscaped before being sent for validation. gorillamux returns escaped parameters, but openapi3filter expects unescaped parameters.
1 parent 91b2a73 commit 7a9d2b6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

oapi_validate.go

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"fmt"
2121
"log"
2222
"net/http"
23+
"net/url"
2324
"os"
2425
"strings"
2526

@@ -128,6 +129,12 @@ func ValidateRequestFromContext(ctx echo.Context, router routers.Router, options
128129
}
129130
}
130131

132+
// because gorillamux.NewRouter() uses mux.NewRouter().UseEncodedPath()
133+
// we need to unescape the path parameters for validation
134+
for k, v := range pathParams {
135+
pathParams[k], _ = url.PathUnescape(v)
136+
}
137+
131138
validationInput := &openapi3filter.RequestValidationInput{
132139
Request: req,
133140
PathParams: pathParams,

0 commit comments

Comments
 (0)