Skip to content

Typescript fetch node client generator discriminator issue  #48

Description

@Sholto

When an object is extended and that objected has a discriminator, the field that acts as the discriminator is removed from the object.

To illustrate:

components:
  schemas:
    ObjectWithDiscriminator:
      oneOf:
        - $ref: '#/components/schemas/SubObject1'
        - $ref: '#/components/schemas/SubObject2'
      discriminator:
        propertyName: thisProperty
        mapping:
          true: '#/components/schemas/SubObject1'
          false: '#/components/schemas/SubObject2'

    SubObject1:
      type: object
      required:
        - thisProperty
        - otherProperty1
      properties:
        thisProperty:
          type: boolean
        otherProperty1:
          type: string

    SubObject2:
      allOf:
        - $ref: '#/components/schemas/IndependentObject'

    IndependentObject:
      type: object
      required:
        - thisProperty
      properties:
        thisProperty:
          type: boolean
        otherProperty2:
          type: string

Yields:

    interface SubObject2 extends Api.IndependentObject {
        /**
         * Value for discriminator in Api.SubObject2
         */
        thisProperty: false;
    }

    interface IndependentObject {
        otherProperty2?: string;
    }

As you can see, IndependentObject is now missing a declaration for thisProperty. It should look like:

Yields:

    interface SubObject2 extends Api.IndependentObject {
        /**
         * Value for discriminator in Api.SubObject2
         */
        thisProperty: false;
    }

    interface IndependentObject {
        thisProperty: boolean;
        otherProperty2?: string;
    }

Note: Generation appears to work in typescript-fetch-client-generator2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions