acacode / acacode/swagger-typescript-api

Array-type query params are always exploded

Aberta
#1,541 6 comentários 0 reações 0 responsáveis Ver no GitHub
bug duplicate
Linguagem predominante
TypeScript
Estrelas
4.1k
Forks
436
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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 https://github.com/acacode/swagger-typescript-api/issues/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:**

```openapi
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`

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.