-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Closed
Labels
Description
Description
When using the typescript-axios generator, properties with uniqueItems: true in the OpenAPI spec are generated as Set<T> in the TypeScript models.
However, Set values are not serialized correctly when sent to the server. In serializeDataIfNeeded, the Set is passed to JSON.stringify, which results in {} — an empty object — instead of a JSON array.
This leads to incorrect request payloads and breaks API communication.
openapi-generator version
Tested with version 7.14.0
OpenAPI declaration file content or url
components:
schemas:
ExampleModel:
type: object
properties:
tags:
type: array
items:
type: string
uniqueItems: trueGeneration Details
openapi-generator-cli generate -i ./openapi.yaml -g typescript-axios -o ./generated
Generated model:
tags?: Set<string>;
Steps to reproduce
-
Use the OpenAPI schema above
-
Generate the typescript-axios client
-
Call any endpoint with tags: new Set(['a', 'b'])
-
Observe the actual payload sent over the network
Expected result:
{ "tags": ["a", "b"] }
Actual result:
{ "tags": {} }
Related issues/PRs
Couldn't find related open issues specific to this problem.
Suggest a fix
- Serialize Set as Array inside serializeDataIfNeeded or related functions
- Or generate Array instead of Set by default for uniqueItems: true, or at least provide a config flag to do so
Reactions are currently unavailable