You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When generating a C# client using NSwag.CodeGeneration.CSharp an endpoint parameter accepting an abstract class, uses a sub-type as its parameter type in the generated C# client.
I've been struggling to solve this since there's been quite a few changes to the whole polymorphism part it seems and documentation is outdated. I'm not sure if anything I'm doing is actually correct (anymore). Is UseOneOfForPolymorphism and UseAllOfToExtendReferenceSchemas still the way to do this? Are the attributes on my base/inheriting models correct?
I hope I've provided enough info, please let me know if I can clarify anything!
The generated swagger.json is also available in the repo.
I use the dotnet swagger tofile cli to generate it, but I don't think that makes much of a difference. The spec seems to properly specify the polymorphism, and it works for the get method, but not the post method.
The text was updated successfully, but these errors were encountered:
Describe the bug
When generating a C# client using
NSwag.CodeGeneration.CSharp
an endpoint parameter accepting an abstract class, uses a sub-type as its parameter type in the generated C# client.I've been struggling to solve this since there's been quite a few changes to the whole polymorphism part it seems and documentation is outdated. I'm not sure if anything I'm doing is actually correct (anymore). Is
UseOneOfForPolymorphism
andUseAllOfToExtendReferenceSchemas
still the way to do this? Are the attributes on my base/inheriting models correct?ASP.NET Project setup:
Models:
Controller:
Client generator settings:
Generated client:
Version used
To Reproduce
Repo repro
Expected behavior
I expect the generated method to be:
But it's actually;
Additional context
I hope I've provided enough info, please let me know if I can clarify anything!
The generated swagger.json is also available in the repo.
I use the
dotnet swagger tofile
cli to generate it, but I don't think that makes much of a difference. The spec seems to properly specify the polymorphism, and it works for the get method, but not the post method.The text was updated successfully, but these errors were encountered: