René's URL Explorer Experiment


Title: strict-server: response types silently drop data for allOf-composed unions and properties + additionalProperties · Issue #2549 · oapi-codegen/oapi-codegen · GitHub

Open Graph Title: strict-server: response types silently drop data for allOf-composed unions and properties + additionalProperties · Issue #2549 · oapi-codegen/oapi-codegen

X Title: strict-server: response types silently drop data for allOf-composed unions and properties + additionalProperties · Issue #2549 · oapi-codegen/oapi-codegen

Description: PR #2332 fixed strict-server response types losing their model's MarshalJSON, closing #970 and #1665. Two shapes are still affected: the response is emitted as a defined type with no delegation, and encoding/json quietly serialises an in...

Open Graph Description: PR #2332 fixed strict-server response types losing their model's MarshalJSON, closing #970 and #1665. Two shapes are still affected: the response is emitted as a defined type with no delegation, an...

X Description: PR #2332 fixed strict-server response types losing their model's MarshalJSON, closing #970 and #1665. Two shapes are still affected: the response is emitted as a defined type with no delegation...

Opengraph URL: https://github.com/oapi-codegen/oapi-codegen/issues/2549

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"strict-server: response types silently drop data for allOf-composed unions and properties + additionalProperties","articleBody":"PR #2332 fixed strict-server response types losing their model's `MarshalJSON`, closing #970 and #1665. Two shapes are still affected: the response is emitted as a defined type with no delegation, and `encoding/json` quietly serialises an incomplete body. No error, no compile failure — just a 200 with fields missing.\n\n## Environment\n\n- `oapi-codegen` **v2.8.0**\n- `oapi-codegen/runtime` v1.6.0\n- Go **1.26.4** (darwin/arm64)\n\n## Configuration\n\n```yaml\npackage: repro\ngenerate:\n  strict-server: true\n  gorilla-server: true\n  models: true\noutput-options:\n  skip-prune: true\n```\n\n## Minimal specification\n\n```yaml\nopenapi: \"3.0.0\"\ninfo:\n  title: allOf-composed union repro\n  version: \"1.0\"\npaths:\n  /thing:\n    get:\n      operationId: getThing\n      responses:\n        \"200\":\n          description: ok\n          content:\n            application/json:\n              schema: { $ref: \"#/components/schemas/Thing\" }\n  /bag:\n    get:\n      operationId: getBag\n      responses:\n        \"200\":\n          description: ok\n          content:\n            application/json:\n              schema: { $ref: \"#/components/schemas/Bag\" }\ncomponents:\n  schemas:\n    Base:\n      type: object\n      required: [id]\n      properties:\n        id: { type: string }\n    # case 1: union nested inside an allOf member\n    Thing:\n      allOf:\n        - $ref: \"#/components/schemas/Base\"\n        - oneOf:\n            - $ref: \"#/components/schemas/Cat\"\n            - $ref: \"#/components/schemas/Dog\"\n    Cat:\n      type: object\n      properties: { meow: { type: string } }\n    Dog:\n      type: object\n      properties: { woof: { type: string } }\n    # case 2: fixed properties alongside additionalProperties\n    Bag:\n      type: object\n      required: [kind]\n      properties:\n        kind: { type: string }\n      additionalProperties: true\n```\n\n## Current behaviour\n\nThe **models** are generated correctly. Both get a custom marshaller:\n\n```go\ntype Thing struct {\n\tId    string `json:\"id\"`\n\tunion json.RawMessage\n}\nfunc (t Thing) MarshalJSON() ([]byte, error) { ... }\n\ntype Bag struct {\n\tKind                 string                 `json:\"kind\"`\n\tAdditionalProperties map[string]interface{} `json:\"-\"`\n}\nfunc (a Bag) MarshalJSON() ([]byte, error) { ... }\n```\n\nThe **response types** do not, so nothing delegates to those marshallers:\n\n```go\ntype GetThing200JSONResponse Thing   // no MarshalJSON\ntype GetBag200JSONResponse Bag       // no MarshalJSON\n```\n\nThe generated visitor encodes the response value directly:\n\n```go\nfunc (response GetThing200JSONResponse) VisitGetThingResponse(w http.ResponseWriter) error {\n\tvar buf bytes.Buffer\n\tif err := json.NewEncoder(&buf).Encode(response); err != nil {\n\t\treturn err\n\t}\n\t...\n}\n```\n\nBecause `GetThing200JSONResponse` is a defined type it does not inherit `Thing`'s method, so `encoding/json` falls back to struct-field encoding and drops the unexported `union` field. Same for `Bag`, whose `AdditionalProperties` map is tagged `json:\"-\"`.\n\nServing each response through its generated visitor:\n\n| Response value | Actual (v2.8.0) | Expected |\n|---|---|---|\n| `Thing{Id: \"abc\"}` + `FromCat(Cat{Meow: \"purr\"})` | `{\"id\":\"abc\"}` | `{\"id\":\"abc\",\"meow\":\"purr\"}` |\n| `Bag{Kind: \"demo\", AdditionalProperties: {\"extra\": 42}}` | `{\"kind\":\"demo\"}` | `{\"extra\":42,\"kind\":\"demo\"}` |\n\n## Expected behaviour\n\nThe response type should delegate to the model's marshaller, exactly as #2332 already does for a response whose schema is directly a `oneOf`/`anyOf`.\n","author":{"url":"https://github.com/PieterVoorwinden","@type":"Person","name":"PieterVoorwinden"},"datePublished":"2026-09-02T09:51:01Z","url":"https://github.com/oapi-codegen/oapi-codegen/issues/2549"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:4330aa4e-dab3-3f83-73aa-64de0ad87c98
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9ACA:110E43:2CA3FED:3AF0826:6AF9CAD1
html-safe-nonce5c8bb80c47b0e8899f7585ff5aac67ecfee111b61a8ed025990d94b55b127bb3
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QUNBOjExMEU0MzoyQ0EzRkVEOjNBRjA4MjY6NkFGOUNBRDEiLCJ2aXNpdG9yX2lkIjoiMzk0MDA0NDExNTQxOTk3NDM1MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacfad6cf855ad62adbdd4135332b5eb0a9d9d9eed9880e8ffb44372efe7e090a26
hovercard-subject-tagissue:5322386207
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/oapi-codegen/oapi-codegen/2549/issue_layout
twitter:imagehttps://opengraph.githubassets.com/9a4c636ecc581aa01e40c8b5ce93bfcb026ae5b86c70785fb295c21b6469fda6/oapi-codegen/oapi-codegen/issues/2549
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/9a4c636ecc581aa01e40c8b5ce93bfcb026ae5b86c70785fb295c21b6469fda6/oapi-codegen/oapi-codegen/issues/2549
og:image:altPR #2332 fixed strict-server response types losing their model's MarshalJSON, closing #970 and #1665. Two shapes are still affected: the response is emitted as a defined type with no delegation, an...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamePieterVoorwinden
hostnamegithub.com
expected-hostnamegithub.com
None612d3e6ffd693e7ea8d9fcf452370995872baef31d825b1fedef704cd3d24ac7
turbo-cache-controlno-preview
go-importgithub.com/oapi-codegen/oapi-codegen git https://github.com/oapi-codegen/oapi-codegen.git
octolytics-dimension-user_id142752710
octolytics-dimension-user_loginoapi-codegen
octolytics-dimension-repository_id173009358
octolytics-dimension-repository_nwooapi-codegen/oapi-codegen
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id173009358
octolytics-dimension-repository_network_root_nwooapi-codegen/oapi-codegen
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release072e34035c13c31543fba9f025cbbbda4210dae4
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/oapi-codegen/oapi-codegen/issues/2549#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Foapi-codegen%2Foapi-codegen%2Fissues%2F2549
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Foapi-codegen%2Foapi-codegen%2Fissues%2F2549
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=oapi-codegen%2Foapi-codegen
Reloadhttps://github.com/oapi-codegen/oapi-codegen/issues/2549
Reloadhttps://github.com/oapi-codegen/oapi-codegen/issues/2549
Reloadhttps://github.com/oapi-codegen/oapi-codegen/issues/2549
oapi-codegenhttps://github.com/oapi-codegen
oapi-codegenhttps://github.com/oapi-codegen/oapi-codegen
Codehttps://github.com/oapi-codegen/oapi-codegen
Issues228 (228)https://github.com/oapi-codegen/oapi-codegen/issues
Pull requests70 (70)https://github.com/oapi-codegen/oapi-codegen/pulls
Discussionshttps://github.com/oapi-codegen/oapi-codegen/discussions
Actionshttps://github.com/oapi-codegen/oapi-codegen/actions
Projectshttps://github.com/oapi-codegen/oapi-codegen/projects
Security and quality11 (11)https://github.com/oapi-codegen/oapi-codegen/security
Insightshttps://github.com/oapi-codegen/oapi-codegen/pulse
https://github.com/oapi-codegen/oapi-codegen
New issuehttps://github.com/login?return_to=https://github.com/oapi-codegen/oapi-codegen/issues/2549
New issuehttps://github.com/login?return_to=https://github.com/oapi-codegen/oapi-codegen/issues/2549
#2552https://github.com/oapi-codegen/oapi-codegen/pull/2552
strict-server: response types silently drop data for allOf-composed unions and properties + additionalPropertieshttps://github.com/oapi-codegen/oapi-codegen/issues/2549#top
#2552https://github.com/oapi-codegen/oapi-codegen/pull/2552
https://github.com/PieterVoorwinden
PieterVoorwindenhttps://github.com/PieterVoorwinden
on Sep 2, 2026https://github.com/oapi-codegen/oapi-codegen/issues/2549#issue-5322386207
#2332https://github.com/oapi-codegen/oapi-codegen/pull/2332
#970https://github.com/oapi-codegen/oapi-codegen/issues/970
#1665https://github.com/oapi-codegen/oapi-codegen/issues/1665
#2332https://github.com/oapi-codegen/oapi-codegen/pull/2332
mromaszewiczhttps://github.com/mromaszewicz
on Sep 24, 2026https://github.com/oapi-codegen/oapi-codegen/issues/2549#event-31720623313
fix(strict-server): delegate by the generated schema, never encode .u…https://github.com/TanbirRamim/oapi-codegen/commit/c15961bd4ca0350d3c6a5fcf6c8154ecc963fdb6
https://docs.github.com/articles/closing-issues-via-commit-messages
c15961bhttps://github.com/TanbirRamim/oapi-codegen/commit/c15961bd4ca0350d3c6a5fcf6c8154ecc963fdb6
mromaszewiczhttps://github.com/mromaszewicz
completedhttps://github.com/oapi-codegen/oapi-codegen/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#2552https://github.com/oapi-codegen/oapi-codegen/pull/2552
on Sep 24, 2026https://github.com/oapi-codegen/oapi-codegen/issues/2549#event-31720845445
mromaszewiczhttps://github.com/mromaszewicz
on Sep 24, 2026https://github.com/oapi-codegen/oapi-codegen/issues/2549#event-31794923562
feat(v3): an allOf that only annotates a $ref is that $ref's type (#2574https://github.com/oapi-codegen/oapi-codegen/commit/ea4c18d7166fce069064356311bed3e434ba7ae9
#2574https://github.com/oapi-codegen/oapi-codegen/pull/2574
ea4c18dhttps://github.com/oapi-codegen/oapi-codegen/commit/ea4c18d7166fce069064356311bed3e434ba7ae9
fix: keep a strict response's MarshalJSON behind allOf: [$ref X] (#2575)https://github.com/oapi-codegen/oapi-codegen/commit/05455adb4c49170d7096b37fe7c993dc7ee1d914
#2575https://github.com/oapi-codegen/oapi-codegen/pull/2575
05455adhttps://github.com/oapi-codegen/oapi-codegen/commit/05455adb4c49170d7096b37fe7c993dc7ee1d914
Boulea7https://github.com/Boulea7
on Sep 26, 2026https://github.com/oapi-codegen/oapi-codegen/issues/2549#event-31903905554
fix(strict-server): delegate JSON marshalling for allOf unions and ad…https://github.com/Boulea7/oapi-codegen/commit/2d153c64b0ef7c84f53bbddb4f517dc929832931
https://docs.github.com/articles/closing-issues-via-commit-messages
2d153c6https://github.com/Boulea7/oapi-codegen/commit/2d153c64b0ef7c84f53bbddb4f517dc929832931
Sign up for freehttps://github.com/signup?return_to=https://github.com/oapi-codegen/oapi-codegen/issues/2549
Sign in to commenthttps://github.com/login?return_to=https://github.com/oapi-codegen/oapi-codegen/issues/2549
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.