acacode / acacode/swagger-typescript-api

Not generating unions with multiple media types

Offen
#314 2 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
bug
Vorherrschende Sprache
TypeScript
Sterne
4.1k
Forks
436
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

There seems to be an issue generating union types when multiple media types exist that alter the requirements for the request body.

Example path with multiple media types ([right from the swagger requestBody docs](https://swagger.io/docs/specification/describing-request-body/)):

Given the following schema:
```yaml
paths:
/pets:
post:
summary: Add a new pet
requestBody:
content:
"application/json":
schema:
$ref: '#/components/schemas/Cat'
"application/foo.bar+json":
schema:
$ref: '#/components/schemas/Dog'
```

Only one output method will be generated, it seems to either be `application/json` or index 0, I'm not entirely sure.

Is there any way I can get this to generate a union type rather than always generating from schemas/Cat? It seems like the swagger specification should allow for multiple media types for a single endpoint.

> The requestBody is more flexible in that it lets you consume different media types, such as JSON, XML, form data, plain text, and others, and use different schemas for different media types. requestBody consists of the content object, an optional Markdown-formatted description, and an optional required flag (false by default). content lists the media types consumed by the operation (such as application/json) and specifies the schema for each media type

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.