Skip to content

Add missing case to type generation traversal#2298

Open
mromaszewicz wants to merge 1 commit intooapi-codegen:mainfrom
mromaszewicz:fix/issue-1306
Open

Add missing case to type generation traversal#2298
mromaszewicz wants to merge 1 commit intooapi-codegen:mainfrom
mromaszewicz:fix/issue-1306

Conversation

@mromaszewicz
Copy link
Member

Fixes: #1306

GenerateTypeDefsForOperation() was extracting AdditionalTypes from params and request bodies, but not from response content schemas. This meant that x-go-type-name on an inline response schema was silently ignored — the type definition was created internally but never collected for output.

Add the missing loop over op.Responses[].Contents[].Schema to extract AdditionalTypes, matching the existing pattern for params and bodies. Extend the xgotypename example with a response-level x-go-type-name test case.

Due to this bug, we've neglected to generate types for any types defined inline in responses, so a lot of generated files were affected due to those types being missing.

@mromaszewicz mromaszewicz requested a review from a team as a code owner March 23, 2026 18:36
Fixes: oapi-codegen#1306

GenerateTypeDefsForOperation() was extracting AdditionalTypes from
params and request bodies, but not from response content schemas.
This meant that x-go-type-name on an inline response schema was
silently ignored — the type definition was created internally but
never collected for output.

Add the missing loop over op.Responses[].Contents[].Schema to
extract AdditionalTypes, matching the existing pattern for params
and bodies. Extend the xgotypename example with a response-level
x-go-type-name test case.

Due to this bug, we've neglected to generate types for any types
defined inline in responses, so a lot of generated files were
affected due to those types being missing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mromaszewicz mromaszewicz added the bug Something isn't working label Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

x-go-type-name isn't working when used in responses section

1 participant