Skip to content

fix(hz/protobuf): preserve api.body custom name for oneof wrapper fields#1486

Closed
WyRainBow wants to merge 3 commits intocloudwego:mainfrom
WyRainBow:feature/fix-1474
Closed

fix(hz/protobuf): preserve api.body custom name for oneof wrapper fields#1486
WyRainBow wants to merge 3 commits intocloudwego:mainfrom
WyRainBow:feature/fix-1474

Conversation

@WyRainBow
Copy link
Copy Markdown

@WyRainBow WyRainBow commented Mar 16, 2026

Summary

  • replace internal_gengo oneof wrapper generation with a hertz implementation that applies injectTagsToStructTags to oneof choice fields
  • keep existing protobuf tags while injecting hertz binding/json/form tags from field options

Fixes #1474

@WyRainBow
Copy link
Copy Markdown
Author

Added a targeted fix for oneof wrappers so choice fields also receive hertz tag injection (injectTagsToStructTags).

This makes (api.body)="..." effective for oneof choices in generated Go code (json/form tags no longer fall back to field GoName).

Regression coverage included in TestOneofFieldCustomBodyTag with dedicated test proto/request fixtures.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@WyRainBow WyRainBow requested review from a team as code owners March 16, 2026 17:18
@xiaost
Copy link
Copy Markdown
Contributor

xiaost commented Apr 8, 2026

Hi, we have no plan to support any new feature now.

@xiaost xiaost closed this Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

使用proto的oneof语法时, 不支持自定义字段名称like [(api.body = "xxxx")]

3 participants