swagger-api / swagger-api/swagger-codegen
Model with inheritance recognized as interface
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Using our custom generator based on the ASP.NET Core server generator, a single model ends up as interface instead of parent on models that inherit from it. All our other inheritances work perfectly. Format matches 100%, and renaming the fields (obviously we do not use the name Dummy in our project) does not help either.
Swagger-codegen version
2.2.1, 2.2.2
Swagger declaration file content or url
I've created a test dummy based on our code that shows the issue.
https://gist.github.com/fonix232/fdef76c0884570bc574737b87ddc8f64
Command line used for generation
java -cp our-custom-lib-1.0.0.jar:swagger-codegen-cli-2.2.1.jar io.swagger.codegen.SwaggerCodegen generate -i ../Specifications/dummy.yaml -l ourcustomgenerator -c ./dummy-config.json -o ../generated
But basically any generator will result in the same
Steps to reproduce
- Use the dummy yaml to generate any kind of client
- Enjoy the fact that your client models do not inherit from the model they should
Related issues
None that I could find
Suggest a Fix
No idea what can cause this issue, however adding the debugModels flag shows that after processing the Swagger definition even before the actual code is generated, codegen recognizes it as interface, not as parent
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 dummy YAML from the linked gist and run the shown SwaggerCodegen generate command with the debugModels flag. Trace how the Swagger definition classifies the inherited model before template generation. Done means generated models preserve the declared inheritance instead of treating the parent model as an interface.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100