swagger-api / swagger-api/swagger-codegen
[Java] CodegenModel's discriminator property is not set for a model when it is composed using allOf
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When a model A is composed from another model B, which has declared a discriminator,
discriminator field of CodegenModel for A should be value of discriminator field of model B.
But, it is set to null.
Consider test case "handle inheritance from composed model" in CodegenTest.java which uses
src/test/resources/2_0/allOfTest.yaml .
child.discriminator should be "disc". But it is null.
Swagger-codegen version
2.2.0
Swagger declaration file content or url
src/test/resources/2_0/allOfTest.yaml
Command line used for generation
client is java.
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 “handle inheritance from composed model” test in CodegenTest.java and the fixture at src/test/resources/2_0/allOfTest.yaml. Run that test and trace how the composed model’s discriminator is represented in CodegenModel. Done means the child model’s discriminator is "disc" rather than null.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100