swagger-api / swagger-api/swagger-ui

No support for nested arrays in query parameters?

Open
#2,707 4 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P2 type: feature version: 3.x
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

What I want to do i essentially this: ?where[]=user,1&where[]=section,7

After a bit of tinkering and and checking out what was discussed on Swagger Google Group a while ago, I arrived at the following implementation:

                "parameters": [
                    {
                        "name": "where[]",
                        "in": "query",
                        "description": "Filter by attribute value",
                        "required": false,
                        "type": "array",
                        "items": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            },
                            "collectionFormat": "csv"
                        },
                        "collectionFormat": "multi"
                    }
                ],

I guess, the problem is swagger-ui relies on line breaks to identify array items in the textarea field. It will correctly recognize only the top-level array, but everything else (in my case, commas) will be url encoded and ignored. Is there a way to circumvent this? Am I even doing it correctly?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the supplied nested-array query parameter definition and request in Swagger UI, then trace how the textarea input is converted into query values and URL encoding. Done means nested array items are represented and serialized as intended rather than being treated as top-level lines with encoded commas.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.