-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
Discriminators are not taken into consideration when inlined in response #1316
Comments
Putting the discriminator on the base class also works. But having the discriminator on the response is valid according to the spec: https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/ |
PR is welcome? |
I realize there is two ways this could be solved, but I'm not sure which is the way to go. Either we add the discriminated property to the types, or we add it to the combined response type. export type TypeObj1 = Base & {
moreProp?: string;
type: TypeObj1Type;
};
export type TypeObj2 = Base & {
prop?: string;
type: TypeObj2Type;
}; or export type GetApiSample200 = (TypeObj1 & { type: TypeObj1Type }) | (TypeObj2 & { type: TypeObj2Type }); I assume the first one is the wanted one, but I'm unsure if there could be implications with changing the component schema based on the response schema. Could there be two responses which return the same objects, but discriminate on different properties? If so, option 2 is the safe option. |
What are the steps to reproduce this issue?
Using the following schema:
the discriminator is not handled properly.
What happens?
The generated types are
What were you expecting to happen?
The generated types should be
Any other comments?
Moving the response into the components schema definition and referencing it from the response solves the issue:
What versions are you using?
Package Version: 6.27.1
The text was updated successfully, but these errors were encountered: