Open
Description
openapi-typescript version
7.6.1
Node.js version
20
OS + version
macOs 14.6
Description
When generating a schema from my openapi specification I get this schema:
OfferBasePersonInternalRequest: {
/** Format: int64 */
id?: number;
cif?: string;
personType?: string;
phone?: string;
email?: string;
address?: components["schemas"]["OfferAddressInternalRequest"];
};
OfferCompanyPersonInternalRequest: {
personType: "OfferCompanyPersonInternalRequest";
} & (Omit<components["schemas"]["OfferBasePersonInternalRequest"], "personType"> & {
caenCode?: string;
companyName?: string;
companyType?: string;
});
OfferIndividualPersonInternalRequest: {
personType: "OfferIndividualPersonInternalRequest";
} & (Omit<components["schemas"]["OfferBasePersonInternalRequest"], "personType"> & {
firstName?: string;
lastName?: string;
foreignPerson?: boolean;
identityDocumentNo?: string;
identityDocumentSeries?: string;
});
the value of personType is incorrect. It should be a string, but here is constrained to be the name of the schema.
This is a my definition:
BasePersonInternalResponse:
type: object
properties:
id:
type: integer
format: int64
cif:
type: string
personType:
type: string
phone:
type: string
email:
type: string
address:
$ref: '#/components/schemas/PersonAddressResponse'
discriminator:
propertyName: personType
CompanyPersonInternalResponse:
type: object
allOf:
- $ref: '#/components/schemas/BasePersonInternalResponse'
- type: object
properties:
caenCode:
type: string
companyName:
type: string
companyType:
type: string
IndividualPersonInternalResponse:
type: object
allOf:
- $ref: '#/components/schemas/BasePersonInternalResponse'
- type: object
properties:
firstName:
type: string
lastName:
type: string
identityDocumentNo:
type: string
identityDocumentSeries:
type: string
Reproduction
Use the schemas that I've put in description combined like this:
user:
oneOf:
- $ref: '#/components/schemas/OfferCompanyPersonInternalRequest'
- $ref: '#/components/schemas/OfferIndividualPersonInternalRequest'
Expected result
personType should be of type string.
Required
- My OpenAPI schema is valid and passes the Redocly validator (
npx @redocly/cli@latest lint
)
Extra
- I’m willing to open a PR (see CONTRIBUTING.md)