swagger-api / swagger-api/swagger-codegen

[Java*] Default value missing for operation parameters

Open
#4,927 1 comment 3 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.