Open foxable opened 1 day ago
When defining nested schemas using oneOf, the nested property will be of type object instead the corresponding union type.
oneOf
object
This is a regression introduced in openapi-generator 7.5.0, which is still present in 7.10.0.
openapi: 3.0.1 info: title: Test API version: "0.1" paths: /contacts: get: operationId: getContact responses: "200": content: '*/*': schema: oneOf: - $ref: "#/components/schemas/InstitutionContact" - $ref: "#/components/schemas/PersonContact" description: OK tags: - Contact components: schemas: Contact: type: object discriminator: propertyName: type properties: '@type': type: string required: - type InstitutionContact: type: object allOf: - $ref: "#/components/schemas/Contact" - type: object properties: address: type: object oneOf: - $ref: "#/components/schemas/DomesticAddress" - $ref: "#/components/schemas/PostboxAddress" required: - address PersonContact: type: object allOf: - $ref: "#/components/schemas/Contact" - type: object properties: address: type: object oneOf: - $ref: "#/components/schemas/DomesticAddress" - $ref: "#/components/schemas/PostboxAddress" required: - address Address: type: object discriminator: propertyName: type properties: type: type: string required: - type DomesticAddress: type: object allOf: - $ref: "#/components/schemas/Address" - type: object properties: street: type: string required: - street PostboxAddress: type: object allOf: - $ref: "#/components/schemas/Address" - type: object properties: postbox: type: string required: - postbox
I'm using the openapi-generator Gradle plugin with the following options:
'supportsES6': 'true', 'withInterfaces': 'true', 'useSingleRequestParameter': 'false', 'legacyDiscriminatorBehavior': 'false',
Up until openapi-generator 7.4.0, this generated the following types:
export type GetContact200Response = { type: 'InstitutionContact' } & InstitutionContact | { type: 'PersonContact' } & PersonContact; export interface InstitutionContact extends Contact { address: InstitutionContactAllOfAddress; } export type InstitutionContactAllOfAddress = { type: 'DomesticAddress' } & DomesticAddress | { type: 'PostboxAddress' } & PostboxAddress;
Since openapi-generator 7.5.0, the following type is generated for InstitutionContact:
InstitutionContact
export interface InstitutionContact extends Contact { address: object; }
Execute the openapi-generator via Gradle using the specified declaration file and options, using typescript-fetch with version 7.5.0 or later.
typescript-fetch
Bug Report Checklist
Description
When defining nested schemas using
oneOf
, the nested property will be of typeobject
instead the corresponding union type.openapi-generator version
This is a regression introduced in openapi-generator 7.5.0, which is still present in 7.10.0.
OpenAPI declaration file content or url
Generation Details
I'm using the openapi-generator Gradle plugin with the following options:
Up until openapi-generator 7.4.0, this generated the following types:
Since openapi-generator 7.5.0, the following type is generated for
InstitutionContact
:Steps to reproduce
Execute the openapi-generator via Gradle using the specified declaration file and options, using
typescript-fetch
with version 7.5.0 or later.