发布日期: 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

新贡献者

完整变更日志:https://github.com/grpc-ecosystem/grpc-gateway/compare/v2.30.0…v2.31.0

更新内容 (原始)

What’s Changed

New Contributors

Full Changelog: https://github.com/grpc-ecosystem/grpc-gateway/compare/v2.30.0...v2.31.0

下载链接