Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request validation does not support nested query parameters #327

Open
gburgett opened this issue Jun 15, 2021 · 1 comment
Open

Request validation does not support nested query parameters #327

gburgett opened this issue Jun 15, 2021 · 1 comment

Comments

@gburgett
Copy link

gburgett commented Jun 15, 2021

First, thank you so much for building an amazing library! It has helped us a lot in development of our new API, since we started with a documentation-driven approach. It allows us to ensure our implementation matches our spec. Please forgive me if this is a duplicate but I couldn't find it in your issue history.

We have some query parameters for an index operation that are defined as "filters" with a nested key for the attribute being filtered on. An example is GET /api/v1/events?filter[slug]=%2Ftest. Rack's Query Parser implementation turns the above into this params hash:

{
  "rack.request.query_string"=>"filter%5Bslug%5D=%2F",
  "rack.request.query_hash"=>{
    "filter"=>{
      "slug"=>"/test"
    }
  }
}

And then we get the following validation error:

#/paths/~1events/get missing required parameters: filter[slug]

Since it is a Rack specific behavior I didn't think this issue belonged in the openapi_parser library.

Thanks again!

@ota42y
Copy link
Member

ota42y commented Aug 7, 2021

Thank you for reporting!
A little more question, how do you describe the parameters in the OpenAPI definition?
Since there is a style: deepObject in the Parameter Object of OpenAPi 3, it may be possible to express it.
(If this example is intended and validation fails, it's a bug)
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#style-examples

paths:
  /events:
    get:
      parameters:
      - name: filter[slug]
        in: query
	style: deepObject
	explode: true
        schema:  
          type: object
          properties:
	    filter:
	      type: string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants