grpc-gateway v2.31.0 版本更新介绍
发布日期: 2026-09-25
版本号: v2.31.0
grpc-gateway v2.31.0 更新内容:Go 最低版本要求从 1.25.0 升至 1.26.0,并新增 Rust edition 2026 支持。openapiv2 方面修复了路径参数的 oneof 同级字段不应出现在查询参数中、查询参数名需输出 map 键类型、常用对象类型查询参数应输出原始类型、查询参数需输出 minItems 和 maxItems 等问题;openapiv3 新增 x-* 扩展字段支持和 response_body 绑定;修复了设置 response_body 时未导入响应类型包的问题。运行时与安全性方面,新增拒绝超出范围的数字枚举查询值和 JSON 解码中的越界枚举值、将溢出的 grpc-timeout 钳制到最大时长、校验转发的头部值后再写入 grpc metadata、禁止 grpc-metadata 头映射到保留的 grpcgateway- 命名空间、整数和枚举路径参数按十进制解析、深通配符在前面有字面量时不得匹配零个路径段。此外允许 proto 文件不带 go_package 选项,并新增安全注意事项文档。本次共有 8 位新贡献者参与。
更新内容 (中文)
变更内容
- 将最低 Go 版本从 1.25.0 更新至 1.26.0,由 @johanbrandhorst 提交:https://github.com/grpc-ecosystem/grpc-gateway/pull/7269
- fix(openapiv2):从查询参数中省略路径参数的 oneof 同级字段,由 @hsdfat 提交:https://github.com/grpc-ecosystem/grpc-gateway/pull/7207
- fix:设置 response_body 时导入响应类型包,由 @MicBun 提交:https://github.com/grpc-ecosystem/grpc-gateway/pull/7225
- openapiv3:新增扩展(x-*)支持,由 @Abmun 提交:https://github.com/grpc-ecosystem/grpc-gateway/pull/7237
- docs:新增安全注意事项页面,由 @cleitonaugusto 提交:https://github.com/grpc-ecosystem/grpc-gateway/pull/7282
- fix(openapiv2):在查询参数名称中输出 map 键类型,由 @iamrajiv 提交:https://github.com/grpc-ecosystem/grpc-gateway/pull/7307
- 修复 template_test 的格式化字符串,由 @skitt 提交:https://github.com/grpc-ecosystem/grpc-gateway/pull/7323
- 新增 edition 2026 支持,由 @printfn 提交:https://github.com/grpc-ecosystem/grpc-gateway/pull/7352
- fix(openapiv2):为常见类型(well-known)对象查询参数输出原始类型,由 @iamrajiv 提交:https://github.com/grpc-ecosystem/grpc-gateway/pull/7351
- 在 parseField 中拒绝超出范围的数字枚举查询值,由 @itecz26 提交:https://github.com/grpc-ecosystem/grpc-gateway/pull/7369
- feat(protoc-gen-openapiv3):支持 response_body 绑定,由 @tobiaskohlbau 提交:https://github.com/grpc-ecosystem/grpc-gateway/pull/7371
- 将溢出的 grpc-timeout 截断至最大时长,由 @itecz26 提交:https://github.com/grpc-ecosystem/grpc-gateway/pull/7382
- 在添加到 grpc metadata 之前校验转发的 header 值,由 @itecz26 提交:https://github.com/grpc-ecosystem/grpc-gateway/pull/7390
- 在 jsonpb 非 proto 解码器中拒绝超出范围的枚举数字,由 @itecz26 提交:https://github.com/grpc-ecosystem/grpc-gateway/pull/7397
- fix(openapiv2):在查询参数上输出 minItems 和 maxItems,由 @wofiporia 提交:https://github.com/grpc-ecosystem/grpc-gateway/pull/7389
- 拒绝映射到保留的 grpcgateway- 命名空间的 grpc-metadata header,由 @itecz26 提交:https://github.com/grpc-ecosystem/grpc-gateway/pull/7401
- 在 convert.go 中以十进制解析整数和枚举路径参数,由 @itecz26 提交:https://github.com/grpc-ecosystem/grpc-gateway/pull/7405
- protoc-gen-openapiv2:允许没有 go_package 选项的 proto 文件,由 @cipherprofessor 提交:https://github.com/grpc-ecosystem/grpc-gateway/pull/7409
- runtime:深度通配符(**)在前面存在字面量时不得匹配零个路径段,由 @cipherprofessor 提交:https://github.com/grpc-ecosystem/grpc-gateway/pull/7412
新贡献者
- @MicBun 在 https://github.com/grpc-ecosystem/grpc-gateway/pull/7225 完成首次贡献
- @Abmun 在 https://github.com/grpc-ecosystem/grpc-gateway/pull/7237 完成首次贡献
- @cleitonaugusto 在 https://github.com/grpc-ecosystem/grpc-gateway/pull/7282 完成首次贡献
- @skitt 在 https://github.com/grpc-ecosystem/grpc-gateway/pull/7323 完成首次贡献
- @itecz26 在 https://github.com/grpc-ecosystem/grpc-gateway/pull/7369 完成首次贡献
- @tobiaskohlbau 在 https://github.com/grpc-ecosystem/grpc-gateway/pull/7371 完成首次贡献
- @wofiporia 在 https://github.com/grpc-ecosystem/grpc-gateway/pull/7389 完成首次贡献
- @cipherprofessor 在 https://github.com/grpc-ecosystem/grpc-gateway/pull/7409 完成首次贡献
完整变更日志:https://github.com/grpc-ecosystem/grpc-gateway/compare/v2.30.0…v2.31.0
更新内容 (原始)
What’s Changed
- Update minimum Go version from 1.25.0 to 1.26.0 by @johanbrandhorst in https://github.com/grpc-ecosystem/grpc-gateway/pull/7269
- fix(openapiv2): omit oneof siblings of path parameters from query parameters by @hsdfat in https://github.com/grpc-ecosystem/grpc-gateway/pull/7207
- fix: import response type package when response_body is set by @MicBun in https://github.com/grpc-ecosystem/grpc-gateway/pull/7225
- openapiv3: add extension (x-*) support by @Abmun in https://github.com/grpc-ecosystem/grpc-gateway/pull/7237
- docs: add a security considerations page by @cleitonaugusto in https://github.com/grpc-ecosystem/grpc-gateway/pull/7282
- fix(openapiv2): emit map key type in query parameter names by @iamrajiv in https://github.com/grpc-ecosystem/grpc-gateway/pull/7307
- Fix template_test format strings by @skitt in https://github.com/grpc-ecosystem/grpc-gateway/pull/7323
- Add edition 2026 support by @printfn in https://github.com/grpc-ecosystem/grpc-gateway/pull/7352
- fix(openapiv2): emit a primitive type for well-known object query parameters by @iamrajiv in https://github.com/grpc-ecosystem/grpc-gateway/pull/7351
- reject out-of-range numeric enum query values in parseField by @itecz26 in https://github.com/grpc-ecosystem/grpc-gateway/pull/7369
- feat(protoc-gen-openapiv3): support response_body binding by @tobiaskohlbau in https://github.com/grpc-ecosystem/grpc-gateway/pull/7371
- clamp overflowing grpc-timeout to max duration by @itecz26 in https://github.com/grpc-ecosystem/grpc-gateway/pull/7382
- validate forwarded header values before adding to grpc metadata by @itecz26 in https://github.com/grpc-ecosystem/grpc-gateway/pull/7390
- reject out-of-range enum numbers in jsonpb non-proto decoder by @itecz26 in https://github.com/grpc-ecosystem/grpc-gateway/pull/7397
- fix(openapiv2): emit minItems and maxItems on query parameters by @wofiporia in https://github.com/grpc-ecosystem/grpc-gateway/pull/7389
- reject grpc-metadata headers mapping into reserved grpcgateway- namespace by @itecz26 in https://github.com/grpc-ecosystem/grpc-gateway/pull/7401
- parse integer and enum path params as base 10 in convert.go by @itecz26 in https://github.com/grpc-ecosystem/grpc-gateway/pull/7405
- protoc-gen-openapiv2: allow proto files without a go_package option by @cipherprofessor in https://github.com/grpc-ecosystem/grpc-gateway/pull/7409
- runtime: deep wildcard (**) must not match zero segments after a preceding literal by @cipherprofessor in https://github.com/grpc-ecosystem/grpc-gateway/pull/7412
New Contributors
- @MicBun made their first contribution in https://github.com/grpc-ecosystem/grpc-gateway/pull/7225
- @Abmun made their first contribution in https://github.com/grpc-ecosystem/grpc-gateway/pull/7237
- @cleitonaugusto made their first contribution in https://github.com/grpc-ecosystem/grpc-gateway/pull/7282
- @skitt made their first contribution in https://github.com/grpc-ecosystem/grpc-gateway/pull/7323
- @itecz26 made their first contribution in https://github.com/grpc-ecosystem/grpc-gateway/pull/7369
- @tobiaskohlbau made their first contribution in https://github.com/grpc-ecosystem/grpc-gateway/pull/7371
- @wofiporia made their first contribution in https://github.com/grpc-ecosystem/grpc-gateway/pull/7389
- @cipherprofessor made their first contribution in https://github.com/grpc-ecosystem/grpc-gateway/pull/7409
Full Changelog: https://github.com/grpc-ecosystem/grpc-gateway/compare/v2.30.0...v2.31.0
下载链接
- grpc-gateway-v2.31.0.tar.gz
- grpc-gateway_2.31.0_checksums.txt
- multiple.intoto.jsonl
- protoc-gen-grpc-gateway-v2.31.0-darwin-arm64
- protoc-gen-grpc-gateway-v2.31.0-darwin-x86_64
- protoc-gen-grpc-gateway-v2.31.0-linux-arm64
- protoc-gen-grpc-gateway-v2.31.0-linux-x86_64
- protoc-gen-grpc-gateway-v2.31.0-windows-arm64.exe
- protoc-gen-grpc-gateway-v2.31.0-windows-x86_64.exe
- protoc-gen-openapiv2-v2.31.0-darwin-arm64
- protoc-gen-openapiv2-v2.31.0-darwin-x86_64
- protoc-gen-openapiv2-v2.31.0-linux-arm64
- protoc-gen-openapiv2-v2.31.0-linux-x86_64
- protoc-gen-openapiv2-v2.31.0-windows-arm64.exe
- protoc-gen-openapiv2-v2.31.0-windows-x86_64.exe