interagent / committee

A collection of Rack middleware to support JSON Schema.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

ahx opened this issue · comments

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.

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

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.

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