-
-
Notifications
You must be signed in to change notification settings - Fork 505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Required flag missing on property when it is referenced with 'discriminator' #2162
Comments
Yeah, there's definitely something different going on with that Thanks for the detailed report and repro case; it can makes investigating these issues so much easier. |
Quick update… At today's TSC meeting there was some discussion around |
openapi-typescript version
7.6.1
Node.js version
20.17.0
OS + version
WSL Ubuntu 22.04.1 LTS
Description
We're trying to generate a type for an update request (UpdatePet) where the attributes need to be determined by a discriminator (sound), with the two possible types being CatProps and DogProps, these have one optional property each: kittens and puppies respectively. We're also trying to generate two additional types Cat and Dog , which reference CatProps and DogProps, with kittens and puppies being required.
When the discriminator is added to the UpdatePet schema the Cat and Dog types incorrectly generate with kittens and puppies becoming optional. If we remove the discriminator, the Cat and Dog schemas generate correctly.
Reproduction
Generate a ts schema from this yml, Cat type will be:
Cat: components["schemas"]["CatProps"]
Then delete the whole discriminator, Cat type will be:
Cat: WithRequired<components["schemas"]["CatProps"], "kittens">
Expected result
Cat type should be the following:
Cat: WithRequired<components["schemas"]["CatProps"], "kittens">
The type of UpdatePet should have no effect on the seemingly unrelated Cat and Dog types.
Required
npx @redocly/cli@latest lint
)Extra
The text was updated successfully, but these errors were encountered: