swagger-api / swagger-api/swagger-codegen
Codegen is merging nested models
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When multiple nested models have identical contents, codegen automatically merges them and generates only one model. This is not expected because these models are unrelated. Need an option to disable merging.
Swagger-codegen version
2.4.1
Swagger declaration file content or url
definitions:
outer1:
type: object
properties:
inner1:
type: object
properties:
foo:
type: string
outer2:
type: object
properties:
inner2:
type: object
properties:
foo:
type: string
Command line used for generation
java -jar swagger-codegen-cli-2.4.1.jar generate -i api.yaml -l jaxrs-spec
Steps to reproduce
Just generate code. Inner1 is generated as Outer1Inner1, but inner2 is not being generated. Outer2 now has a field Outer1Inner1 inner2, which is not expected.
It's not language-specific.
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
Reproduce the issue with the shown api.yaml definitions and the java -jar swagger-codegen-cli-2.4.1.jar generate -i api.yaml -l jaxrs-spec command. Trace the model-generation entry point responsible for deduplicating identical nested models, then verify that an option can preserve separate Outer1Inner1 and Outer2Inner2 types across generated languages.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100