swagger-api / swagger-api/swagger-codegen
Generated code is not validation boolean values
Open
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
If we have this spec
exp_list:
type: object
properties:
exclude:
type: boolean
names:
type: array
items:
type: string
required:
- exclude
- names
maven-swagger-plugin will generated models with method
/**
* calculate SKUs exclude SKU in names list
* @return exclude
**/
@ApiModelProperty(required = true, value = "calculate SKUs exclude SKU in names list")
@NotNull
public Boolean isExclude() {
return exclude;
}
But need to generate method getExclude for spring validation work properly. Now really Boolean fields is not validated.
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 generated Java model from the YAML example using the maven-swagger-plugin, then trace the Java model template or generator path that emits isExclude(). Verify how Spring validation handles the generated Boolean field. Done means the generated accessor is getExclude() and Boolean validation works for the required field.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100