Skip to content

[BUG][typescript-axios] Generated JavaScript Sets are not serialized/deserializedΒ #11746

@BernhardPosselt

Description

@BernhardPosselt

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

The following schema generates a JavaScript Set property:

{
  "Test": {
    "required": [
      "a"
    ],
    "type": "object",
    "properties": {
      "a": {
        "uniqueItems": true,
        "type": "array",
        "items": {
          "type": "string"
        }
      }
    }
  }
}

Generated object:

export interface Test {
    /**
     * 
     * @type {Set<string>}
     * @memberof Test
     */
    'a': Set<string>;
}

However when sending this request to the server, the value is not de-serialized as an array but just replaced with an empty object ("a":{}).

Similarly, when inspecting the returned data from an API, the actual values on the JavaScript object are not wrapped in a set, but return as an array.

openapi-generator version

4.5.0

Suggest a fix

Either don't generate Set and use a T[] or add conversions for sending and receiving sets

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions