Skip to content

Validator fails to recognize query parameters with brackets in parameter names (e.g., match[]) #493

@roidelapluie

Description

@roidelapluie

Hello,

I am trying to validate Prometheus API call against a OpenAPI.yaml and libopenapi. The validator reports query parameters with brackets in their names as missing, even when they are present in the request URL. This appears to be related to URL encoding where brackets are encoded as %5B (for [) and %5D (for ]).

If Define an OpenAPI spec with a query parameter that has brackets in its name:

  parameters:
    - name: match[]
      in: query
      required: true
      explode: false
      schema:
        type: array
        items:
          type: string

The validator should recognize match[] and match%5B%5D as equivalent (since %5B = [ and %5D = ] per RFC 3986) and validate successfully, but ir reports:

Error: Query parameter 'match[]' is missing
Reason: The query parameter 'match[]' is defined as being required, however it's missing from the requests

Note:

  • When inspecting the request, req.URL.Query() correctly parses it as map[match[]:[up] start:[0] end:[100]]
  • The raw query string shows: match%5B%5D=up&start=0&end=100 (URL-encoded form)
  • The validator appears to be looking for the literal string match[] in the URL rather than comparing against the decoded parameter name
  • Parameters without brackets validate correctly

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