-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
[BUG] [C#] Polymorphism with 2 level derived classes generates invalid client #8849
Comments
EDIT: The spec wasn't wrong. I'm leaving this below however to document how its not done. See the official spec documentation: https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/ Your spec is wrong. Your derived classes are missing the baseclass properties. The correct spec would be:
which produces functioning classes. |
Yeah you're right. I'll check what is happening under the hood there. |
Confirmed that these are actually two separate bugs at work. Working on a fix. |
Pull request is up which fixes the class issue, the client still won't compile because the return type of the api Operations is a weird one that doesn't exist. I'm not sure if that is an issue of the Client per se, or of the spec. I'm guessing its something the client generator should be able to handle but its also something you can fix on the spec side of things. Simply change the response type of your Api endpoint to just return a BaseClass1 type (which is the only thing that semantically makes sense in such a scenario in my eyes anyway) the client will instantiate the actual type returned correctly and you can then check for the type in your code with the usual:
|
Generated client is invalid for this example:
Using latest version 5.0.1
document
The error is in the constructor of DerivedClass_A when calling base(....),
discriminator is missing in the arguments
The text was updated successfully, but these errors were encountered: