Open
Description
openapi-typescript version
7.6.1
Node.js version
22.12.0
OS + version
macOS 15.2
Description
Reproduce Bug
Given
CreateRepositoryRequest:
description: Lorem ipsum dolor sit amet.
type: object
discriminator:
propertyName: type
mapping:
azure: '#/components/schemas/CreateAzureRepositoryRequest'
git: '#/components/schemas/CreateGitRepositoryRequest'
When
run npm run generate
Actual
CreateRepositoryRequest: Record<string, never>;
Expected
A discriminated union of the two types, something like:
"CreateRepositoryRequest": {
type: "azure" | "git";
} & ({
type: "azure";
} & components["schemas"]["CreateAzureRepositoryRequest"]) | ({
type: "git";
} & components["schemas"]["CreateGitRepositoryRequest"]);
Reproduction
clone: https://github.com/iulspop/bug-report-openapi-typescript-feb-13-2025
then npm i && npm run generate
Expected result
A discriminated union of the two types, something like:
"CreateRepositoryRequest": {
type: "azure" | "git";
} & ({
type: "azure";
} & components["schemas"]["CreateAzureRepositoryRequest"]) | ({
type: "git";
} & components["schemas"]["CreateGitRepositoryRequest"]);
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)