Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collectionFormat 'multi' is not properly handled in generated code #12445

Open
sophiezhang666 opened this issue Aug 13, 2024 · 0 comments
Open

Comments

@sophiezhang666
Copy link

sophiezhang666 commented Aug 13, 2024

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-codegen for golang
  • 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.
#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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant