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

Query parameters: Conversion of array items does not work if parameter name ends with "[]" #369

Open
ahx opened this issue Jan 3, 2023 · 3 comments

Comments

@ahx
Copy link

ahx commented Jan 3, 2023

This is related to #253

Given you have a parameter definition like this, where the name ends with a "[]", because that is a standard you've agreed on.

parameters:
  - name: ids[]
    description: IDs of the things to get
    in: query
    schema:
      type: array
      items:
        type: integer

Expected behavior:
For a request like GET /things?ids[]=1&ids=[]=2, I would expect committee to convert the array items to integers as described in the API description.

Current behavior:
Array items do not get converted to integers, but remain strings.

I guess this is mostly due to Rack's default handling of "xx[]" parameters, as it handles those as an "xx" array by default, so this might be tricky.

Do you plan to support this? If so I would be happy to help.

@ota42y
Copy link
Member

ota42y commented Jan 21, 2023

I would like to fix this problem, but have not had time to implement it. If you don't mind, could you provide support?

@ahx
Copy link
Author

ahx commented Apr 2, 2023

Hi. I have wrapped unpacking and conversion of query / path / header / cookie parameters according to OpenAPI 3 in this gem: https://github.com/ahx/openapi_parameters

It supports all variations of style and explode and applies defaults according to the spec (for example style: form, explode: true for query parameters). It think committee would benefit especially from parsing query parameters exactly as described in the spec. It would be great if you can take a look and share your thoughts. I am also happy to change anything to meet your requirements.

@ahx
Copy link
Author

ahx commented Mar 6, 2024

Something to note that people should be aware is that all query parameters that end with "[]" don't get validated.

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