Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

collectionFormat 'multi' is not properly handled in generated code

未关闭 适合新手
#12,445 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
62/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
go
领域
api, tooling

调研方向

从 modules/swagger-codegen/src/main/resources/go/client.mustache 中引用的参数处理函数开始,然后对比 modules/swagger-codegen/src/main/resources/python/api_client.mustache 中对 multi collectionFormat 的处理。使用 swag init 根据示例声明生成 Go 客户端,并验证包含多个值的 ids 查询是使用分隔符发送的,而不是拼接后发送的。

由索引模型根据 Issue 内容生成。

描述

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.
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

主要语言
Mustache
星标
17.8k
派生
6k
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

swagger-api/swagger-codegen 的其他 Issue

查看 swagger-api/swagger-codegen 的全部 Issue

相似的 Issue

更多 Backend & API Design Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。