Skip to content
This repository was archived by the owner on Jan 31, 2025. It is now read-only.
This repository was archived by the owner on Jan 31, 2025. It is now read-only.

Array parameter in path #123

Closed
Closed
@Nico87LBS

Description

@Nico87LBS

Hello,

I have a problem (bug?) with an array parameter in path.

My swagger spec file looks like:

/foo/{bar}:
    get:
      summary: exemple of array parameter
      parameters:
        - in: path
          name: bar
          type: array
          minItems: 1
          uniqueItems: true
          items:
            type: string
            enum: [black, white]

If I make a request to this url;
http://localhost:3000/foo/white
Everything is all right.

But if I request:
http://localhost:3000/foo/white,black
I have a 400 bad request, invalid request params input.

If I add collectionFormat: csv, it changes nothing. And it seems that it is not take into account because if I add collectionFormat: ssv, swagger ui continue to generate the same url with comas!

Furthermore, if I remove the enum line, so my items are only of type string and do the following request:
http://localhost:3000/foo/white,black
In my handlers, if I display request.params, I obtain:
{bar: [ 'white,black' ] }
Instead of:
{bar: ['white', 'black'] }

Could you help me to find the solution?

Thank you

Ref: https://swagger.io/docs/specification/2-0/describing-parameters/#path-parameters

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions