swagger-api / swagger-api/swagger-codegen
OneOf schema issues with C# code generation
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
OneOf schema issues with C# code generation
Please see attached Issue.png
The one on the left (1) is the “broken” one that won’t compile and the one to the right (2) is my “hotfix” to get this class to compile. However, I don’t actually know what model to use for the AppliesTo property and just randomly picked the AppliesToOffer class. In this scenario, if the server is returning AppliesToOfferProduct or AppliesToOfferProductSegment I will not be able to use those additional properties that those models have as my generated client code is unaware of those extra properties. If I pick the AppliesToOfferProductSegment, I will get deserialization errors if any mandatory properties in this model are not returned by the server e.g if the server response is the AppliesToOffer base class.
Swagger-codegen version
3.x
Swagger declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the attached ExampleAPI.docx and IssueCsharp image, then reproduce the problem using Swagger Codegen 3.x with the C# generator. Compare the generated OneOf models for AppliesToOffer, AppliesToOfferProduct, and AppliesToOfferProductSegment; done means the generated client compiles and handles each server response without losing variant properties or causing deserialization errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, openapi
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100
