Skip to content

JS client does not support polymorphic return types #2041

@delenius

Description

@delenius

In the generated constructFromObject functions, the descriminator property is ignored, which means that an instance of the abstract superclass is created. For example, if I have this in my swagger.yaml:

Vehicle:
  type: "object"
  required:
  - "vehicleType"
  discriminator: "vehicleType"
  properties:
    vehicleType:
      type: "string"

Car:
  allOf:
  - $ref: "#/definitions/Vehicle"
  - type: "object"
    required:
    - "vehicleType"
    properties:
      vehicleType:
        type: "string"

Bicycle:
  allOf:
  - $ref: "#/definitions/Vehicle"
  - type: "object"
    required:
    - "vehicleType"
    properties:
      vehicleType:
        type: "string"

then, according to my understanding of how it should work, if the vehicleType is "Car", then a new Car instance should be generated, and if vehicleType is "Bicycle", a new Bicycle instance should be generated.

Currently, all I get is a new Vehicle instance.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions