Add missing case to type generation traversal#2298
Conversation
ff7a6f3 to
62bc09c
Compare
62bc09c to
b5f64e6
Compare
|
Hi @mromaszewicz could you merge this PR to the main? Thanks! |
b5f64e6 to
dc6b824
Compare
Greptile SummaryFixes a long-standing bug in Confidence Score: 4/5Safe to merge; change is a minimal additive fix with no breaking changes to the existing generated API surface. The core fix in operations.go is correct and well-scoped. All generated file diffs are proportionate — only previously-missing types are added. No types are removed or renamed. Two P2 findings: missing dedicated regression test in internal/test/issues/ and a misleading template comment that now applies to response types. Neither blocks merging. pkg/codegen/templates/param-types.tmpl — the comment template wording is now visibly incorrect for response types.
|
| Filename | Overview |
|---|---|
| pkg/codegen/operations.go | Core bug fix: adds missing loop over op.Responses[].Contents[].Schema to collect AdditionalTypes, matching the existing pattern for params and bodies. Change is minimal and correct. |
| examples/extensions/xgotypename/api.yaml | Adds a GET /example path with an inline response schema using x-go-type-name: ResponseRenamed to demonstrate and test the bug fix. |
| examples/extensions/xgotypename/gen.go | Regenerated output now includes ResponseRenamed struct; comment says "defines parameters for ExampleGet" which is misleading for a response type (pre-existing template wording issue). |
| internal/test/any_of/codegen/inline/openapi.gen.go | Newly emits GetPets200JSONResponse_Data_Item (union type) that was previously missing from generated output; additive change, no breakage. |
| internal/test/strict-server/chi/types.gen.go | Adds UnionExample200JSONResponse0 = string type alias previously missing; identical diff across all strict-server backends (chi, echo, fiber, gin, gorilla, iris, stdhttp). |
| internal/test/issues/issue-1277/content-array.gen.go | Newly emits Test200JSONResponse_Item with full additional-properties marshaling support that was previously missing; proportionate to the bug fix. |
| internal/test/name_conflict_resolution/name_conflict_resolution.gen.go | Adds four PatchResource response type aliases that were previously missing; additive change, no drift beyond the expected fix. |
Reviews (1): Last reviewed commit: "Add missing case to type generation trav..." | Re-trigger Greptile
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>
dc6b824 to
7ef95d8
Compare
|
@heww - When things our out for review, I intend to merge them, but they often wait on code review or some other gating feature. We changed our code review policies so that I can now work through my backlog. There's no need to remind me to push :) My goal is 0 open PR and 0 open issues. |
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.