Skip to content

Don't embed embedded objects with valid JSON tags#978

Merged
wolveix merged 1 commit intomainfrom
fix-embedded-tags
Feb 19, 2026
Merged

Don't embed embedded objects with valid JSON tags#978
wolveix merged 1 commit intomainfrom
fix-embedded-tags

Conversation

@wolveix
Copy link
Collaborator

@wolveix wolveix commented Feb 19, 2026

Fixes #975/#492.

If an embedded object has a json tag, it won't be embedded.

This example:

type Meta struct {
	CreatedAt time.Time `json:"created_at" db:"created_at"`
}

type GreetingOutput struct {
	Body        struct {
		Meta    `json:"meta"`
		Message string `json:"message" example:"Hello, world!" doc:"Greeting message"`
	}
}

Previously generated:

{
  "$schema": "https://example.com/schemas/GreetingOutputBody.json",
  "message": "Hello, world!",
  "created_at": "2019-08-24T14:15:22Z"
}

When it should be:

{
  "$schema": "https://example.com/schemas/GreetingOutputBody.json",
  "message": "Hello, world!",
  "meta": {
    "created_at": "2019-08-24T14:15:22Z"
  }
}

If no JSON tag is specified, it will still function as it did before (which is correct).

@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.12%. Comparing base (6d0295c) to head (1feda7d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #978   +/-   ##
=======================================
  Coverage   93.12%   93.12%           
=======================================
  Files          23       23           
  Lines        4768     4768           
=======================================
  Hits         4440     4440           
  Misses        269      269           
  Partials       59       59           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@leonklingele leonklingele left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🫵🪨

@wolveix wolveix merged commit cbf60b6 into main Feb 19, 2026
7 checks passed
@wolveix wolveix deleted the fix-embedded-tags branch February 19, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Embedded with custom field name

2 participants