Skip to content

Array-type query params are always exploded #1541

@codeth

Description

@codeth

Apologies if I'm missing something obvious, but I'm seeing something unexpected with our generated fetch client.

Our backend API does not support exploded array query params (the Swagger specs specify explode: false) but it looks like the HTTP client does nothing to support the unexploded style, it just maps the values and joins them https://github.com/acacode/swagger-typescript-api/blob/main/templates/base/http-clients/fetch-http-client.ejs#L85

I didn't find an obvious config option that would change this behaviour, other than overriding the template or class method, which I was hoping to avoid.

There was an old issue where someone was having the opposite problem, and it looks like the fix applied there actually abandoned any OOTB support the unexploded style #222

Perhaps this is by design - I'm happy work around it for our project, but since I couldn't find any concrete docs/answers I think it's worth asking, and maybe should be called out that param schemas using explode have no support/effect on the generated client.

Example:

paths:
  /some/api/path:
    get:
      parameters:
        - name: test
          in: query
          style: form
          explode: false
          schema:
            type: array
            items:
              type: string
              enum:
                - hello
                - world
                - yay

Expected request URL:

GET /some/api/path?test=hello,yay

Actual request URL:

GET /some/api/path?test=hello&test=yay

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions