swagger-api / swagger-api/swagger-codegen
Inheritance and repeating properties in child
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
I'm looking at generated examples and not sure if I understand why it works like this.
If you would take a look at https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/Cat.cs - you would see, that it inherits from Animal, which is ok.
Now the interesting thing is, that it repeats all the properties available in Animal - like ClassName, Color - which I can't understand - isn't the very purpose of inheritance to avoid repeating those properties? They even get compiler warnings, as such properties are already defined in base class and new modifier is not used.
That is not only in C# code generation, Java works the same. Is this by design?
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 generated samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/Cat.cs and its Animal base class, then compare the corresponding Java output. Trace those generated properties back through the relevant code-generation templates and check whether the repeated declarations and compiler warnings are intentional. Done means establishing the expected inheritance behavior and documenting the precise scope of any generator change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100