Skip to content

Commit 9f0f858

Browse files
Parameters should be unscaped before being sent for validation. gorillamux returns escaped parameters, but openapi3filter expects unescaped parameters.
1 parent 58055c3 commit 9f0f858

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

oapi_validate.go

+9
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,14 @@ 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 openapi3filter
134+
for k, v := range pathParams {
135+
if v, err := url.PathUnescape(v); err == nil {
136+
pathParams[k] = v
137+
}
138+
}
139+
131140
validationInput := &openapi3filter.RequestValidationInput{
132141
Request: req,
133142
PathParams: pathParams,

0 commit comments

Comments
 (0)