swagger-api / swagger-api/swagger-codegen
[codegen] InlineModelResolver doesn't copy `required` parameter to new reference property
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
https://github.com/swagger-api/swagger-codegen/blob/v2.2.1/modules/swagger-codegen/src/main/java/io/swagger/codegen/InlineModelResolver.java#L249
Here new reference property is created instead on inline object property. But flag required is not copied to newly created property definition.
It leads that generated model is not relevant to swagger description.
Also in ModelImpl - https://github.com/swagger-api/swagger-core/blob/v1.5.10/modules/swagger-models/src/main/java/io/swagger/models/ModelImpl.java#L176 the list of required fields is calculated according to properties, not appropriate variable - https://github.com/swagger-api/swagger-core/blob/v1.5.10/modules/swagger-models/src/main/java/io/swagger/models/ModelImpl.java#L22
It looks like data duplication (list and value in properties), I would remove the list.
Swagger-codegen version
2.2.1 and current master
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 InlineModelResolver.java at the referenced line to trace creation of the reference property, then inspect ModelImpl.java at the referenced lines to compare required-field storage and calculation. Reproduce the inline-object case with a required property and verify that the generated model remains consistent with the Swagger description, including the required-field handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100