Skip to content

Path parameters are not validated properly when they are encoded #17

Open
@florentchauveau

Description

@florentchauveau

Hello,

For a simple spec like this one:

  /resource/{param}:
    get:
      operationId: getMaxLengthResourceParameter
      parameters:
        - name: param
          in: path
          required: true
          schema:
            type: string
            maxLength: 1
      responses:
        "204":
          description: success

and an HTTP request to /resource/%2B, the validation fails, although it should not. It fails because parameters are given in their encoded form to openapi3filter. In this case, it passes %2B for validation, and because it is longer than 1, it fails.

It should pass + to openapi3filter.

This is because route, pathParams, err := router.FindRoute(req) returns encoded pathParams. It does so because gorillamux.NewRouter(swagger) uses mux.NewRouter().UseEncodedPath() itself.

I am working on a PR fixing this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions