Skip to content

Conversation

@FlameMida
Copy link
Contributor

@FlameMida FlameMida commented Nov 20, 2025

What type of PR is this?

fix: fix default tag overriding JSON values in anonymous struct

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(Optional) Translate the PR title into Chinese.

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:

  1. Anonymous embedded struct fields had incorrect JSONName (e.g., "PageInfo.page" instead of "page"), causing keyExist() to fail
  2. Default values from form/query tags were overriding JSON-provided values

zh(optional):

  1. 匿名嵌入结构体的字段JSONName构造错误(如"PageInfo.page"应为"page"),导致keyExist()判断失败
  2. form/query标签的默认值会覆盖JSON提供的值

(Optional) Which issue(s) this PR fixes:

Fixes #1454

(Optional) The PR that updates user documentation:

  Fixed two issues:
  1. Anonymous embedded struct fields had incorrect JSONName (e.g., "PageInfo.page"
     instead of "page"), causing keyExist() to fail
  2. Default values from form/query tags were overriding JSON-provided values

  Solution:
  - Skip JSONName update for anonymous fields to match Go's JSON flattening behavior
  - Add defaultDisabled flag to prevent default value override in single loop pass

Test: Added TestBind_AnonymousFieldWithDefaultTag covering 4 scenarios including
  nested anonymous structs
@FlameMida FlameMida requested review from a team as code owners November 20, 2025 08:32
@CLAassistant
Copy link

CLAassistant commented Nov 20, 2025

CLA assistant check
All committers have signed the CLA.

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.

post请求是否不支持绑定嵌套匿名结构体参数?

2 participants