Skip to content

[BUG] [Typescript-Axios] Sets are treated like Arrays #6904

Description

@Thornsnake
Description

When creating Typescript code of the EVE Online API (https://esi.evetech.net/_latest/swagger.json) the generated code contains Set objects that are treated like Array objects. The code attempts to use Set<>.join() on Sets and tries to JSON.stringify(Set<>) them. Those are things that would only work on Arrays.

openapi-generator version

5.0.0 Beta

Command line used for generation

java -jar openapi-generator-cli-5.0.0-beta.jar generate -i https://esi.evetech.net/_latest/swagger.json -g typescript-axios -o api

Steps to reproduce

Execute the command and the resulting api.ts file will contain the broken code.

The code to look for is labels.join(COLLECTION_FORMATS.csv) and JSON.stringify(itemIds !== undefined ? itemIds : {}).

Suggest a fix/enhancement

I fixed these bugs by wrapping all Set objects into Array.from(Set<>).

For example:
Array.from(labels).join(COLLECTION_FORMATS.csv);
JSON.stringify(itemIds !== undefined ? Array.from(itemIds) : {})

The generated code should either use Arrays to begin with or (if the elements need to be unique) the Set needs to be turned back into an Array, before Array methods are called on it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions