swagger-api / swagger-api/swagger-codegen
[Java*] Default value missing for operation parameters
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Default values for operation parameters are not available in the CodegenParameter.
Sample: findPetsByStatus
parameter status default: available
This default value is not showing up in the generated samples.
For model properties this is working, e.g. Animal.java has color = default: red and this gets generated correctly.
Swagger-codegen version
2.2.3-SNAPSHOT
Swagger declaration file content or url
see petstore-with-fake-endpoints-models-for-testing.yaml
Command line used for generation
jaxrs-cxf-cdi-petstore-server.sh
Steps to reproduce
generate e.g. cxf-cdi and the defaultValue for status doesn't show up in the generated @ApiParam-annotation
Related issues
#4928: @ApiParam also contains defaultValue and is never populated
#4776: @Default is implemented for jaxrs-cxf-cdi queryParams but never populated
Suggest a Fix
Probably the defaultValue is not even parsed using swagger-jaxrs.
Currently it doesn't show up in the mustache variable defaultValue.
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 petstore-with-fake-endpoints-models-for-testing.yaml and the jaxrs-cxf-cdi-petstore-server.sh generation command, then trace how the operation parameter default reaches CodegenParameter and the Mustache defaultValue variable. Compare the generated @ApiParam annotation with the model-property behavior; done means the status parameter's defaultValue is present in generated samples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100