Skip to content

deepObject passes validation when it's an array #484

Description

@jan-bw

I am not sure whether that's on purpose or whether that's a bug, but I've just spotted a (imo) surprising behaviour during deep object validation. Given schema definition like this:

paths:
  /foo:
    get:
      parameters:
        - name: filters
          in: query
          required: false
          style: deepObject
          explode: true
          schema:
            type: object
            properties:
              first:
                type: array
                items:
                  type: string
              second:
                type: array
                items:
                  type: string

When making a request with following params:

  • filters=foo
  • filters[]=1&filters[]=2
    the validation passed.

This surprised me because I'd expect it to fail as neither string nor array should be allowed, should they? Since in rails app you can then access the params[:filters] and it's a string or an array (respectively) it creates a risky precedence.

It's caused by the OpenapiParameters::Query#parse_deep_object where prop_key = key.match(prop_regx)&.[](1) returns nil because the regex won't match keys like filters nor filters[].

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions