swagger-api / swagger-api/swagger-codegen
[Java] Validations missing on method parameters
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When specifying constraints (minLength, minItems) on method parameters, annotation validations are missing in generated .java interface. Validations are generated only for model objects.
Swagger-codegen version
1.0.11
Swagger declaration file content or url
/foo:
get:
parameters:
- name: id
in: query
required: true
type: array
minItems: 1
items:
type: string
minLength: 1
- name: description
in: query
required: true
type: string
minLength: 1
Command line used for generation
java -Dgenerator.dir.data=${WORKSPACE} -Dstub.for=server -jar swagger-gen.jar
Steps to reproduce
- create yaml swagger definition with above mentioned operation
- generate java interface with 1.0.11 swagger-gen
Related issues/PRs
none
Suggest a fix/enhancement
There should be the same validation generation as with model objects (@Size and @Notnull annotations).
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
Use the supplied Swagger YAML and generation command to reproduce the issue, then inspect the generated Java interface and compare its method-parameter output with validation generated for model objects. Done means required parameters with minLength or minItems receive the corresponding validation annotations in the generated interface.
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
- Clearly specified
- Newbie friendliness
- 45/100