Typescript fetch node client generator discriminator issue
Opened this issue · 0 comments
Sholto commented
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
.