swagger-api / swagger-api/swagger-codegen
collectionFormat 'multi' is not properly handled in generated code
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Query array declared with collectionFormat(multi) is not generated correctly, with ids concatenated without separator.
Swagger-codegen version
main branch
Swagger declaration file content or url
{
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "multi",
"description": "ids to query for objects",
"name": "ids",
"in": "query"
},
Command line used for generation
swag init
Steps to reproduce
- Make a REST API endpoint which takes a list of ids and declare it with
collectionFormat(multi)
e.g.// @Param ids query []string false "ids to query for objects" collectionFormat(multi) - Generate API client with
swagger-codegenforgolang - Send a request to API with generated API client code and find on server side that ids are concatenated without separators
Related issues/PRs
Not related, but probably in similar area.
https://github.com/swagger-api/swagger-codegen/issues/10963
Suggest a fix/enhancement
Add handling for collectionFormat multi to the following function:
https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/go/client.mustache#L129
Similar to python
https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/python/api_client.mustache#L423
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 in modules/swagger-codegen/src/main/resources/go/client.mustache at the referenced parameter-handling function, then compare the multi collectionFormat handling in modules/swagger-codegen/src/main/resources/python/api_client.mustache. Generate a Go client from the example declaration with swag init and verify that a multi-valued ids query is sent with separators rather than concatenated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 62/100