swagger-api / swagger-api/swagger-codegen
java client to treat multi valued parameters differently between null and empty collection
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
We want to be able to use the Swagger Java generated client to send get requests of the form:
1) /v1/entity
2) /v1/entity?entityId=
3) /v1/entity?entityId=1,2,3
For each of these cases we want the java client call to be
a) ApiClient.getEntity(null)
b) ApiClient.getEntity(Collections.emptyList())
c) ApiClient.getEntity(Arrays.asList(1,2,3))
In the swagger.yaml if the "allowEmptyValue" is set to true then b) should result in 2).
At the moment the swagger generated client does not distinguish between a) and b). If you want to generate a get call of the form shown in 2) you have to do the following:
ApiClient.getEntity(Arrays.asList(""))
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 the generated Java client's ApiClient.getEntity(null), getEntity(Collections.emptyList()), and getEntity(Arrays.asList(1,2,3)) calls, then inspect how the Swagger YAML allowEmptyValue setting is handled. Verify that null omits the parameter, an empty collection emits entityId=, and populated collections emit comma-separated values.
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
- Clearly specified
- Newbie friendliness
- 48/100