Unify emitter/consumer mediatype filter#2420
Merged
Merged
Conversation
Contributor
Greptile SummaryThis PR aligns response media-type naming between generated component types and client response wrappers. It changes:
Confidence Score: 5/5This looks safe to merge.
|
| Filename | Overview |
|---|---|
| pkg/codegen/operations.go | Adds the shared suffix helper and applies JSON-only component response type reuse in client wrapper fields. |
| pkg/codegen/codegen.go | Updates component response type declaration naming to use the shared media-type suffix decision. |
| internal/test/issues/issue-2389/issue_2389_test.go | Adds compile-time regression checks for shared and distinct response component media schemas. |
Reviews (2): Last reviewed commit: "Unify emitter/consumer mediatype filter" | Re-trigger Greptile
Closes: oapi-codegen#2389 A response component exposing the same schema under multiple content types (e.g. application/json + application/xml) generated client wrapper fields typed as undefined per-content-type names (*ErrorResponseApplicationJSON / *ErrorResponseApplicationXML), breaking compilation. The type declarer (GenerateTypesForResponses) and the wrapper-field consumer (GetResponseTypeDefinitions) independently decided when to append a media-type suffix to a response type name, and the two had drifted apart: the consumer suffixed for every supported content type while the declarer only declared a suffixed name when a response carried more than one JSON content type. Both now route that decision through a single responseMediaTypeSuffix helper, so they cannot disagree. Non-JSON content types reuse the base type name, and JSON entries are suffixed only when a response has more than one JSON content type. The now-unused isMediaTypeSupported helper is removed, and a regression test is added under internal/test/issues/issue-2389. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mromaszewicz
force-pushed
the
fix/issue-2389
branch
from
June 21, 2026 01:24
d5772de to
f869516
Compare
lwc
pushed a commit
to lwc/oapi-codegen
that referenced
this pull request
Jun 23, 2026
Closes: oapi-codegen#2389 A response component exposing the same schema under multiple content types (e.g. application/json + application/xml) generated client wrapper fields typed as undefined per-content-type names (*ErrorResponseApplicationJSON / *ErrorResponseApplicationXML), breaking compilation. The type declarer (GenerateTypesForResponses) and the wrapper-field consumer (GetResponseTypeDefinitions) independently decided when to append a media-type suffix to a response type name, and the two had drifted apart: the consumer suffixed for every supported content type while the declarer only declared a suffixed name when a response carried more than one JSON content type. Both now route that decision through a single responseMediaTypeSuffix helper, so they cannot disagree. Non-JSON content types reuse the base type name, and JSON entries are suffixed only when a response has more than one JSON content type. The now-unused isMediaTypeSupported helper is removed, and a regression test is added under internal/test/issues/issue-2389. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: #2389
A response component exposing the same schema under multiple content types (e.g. application/json + application/xml) generated client wrapper fields typed as undefined per-content-type names (*ErrorResponseApplicationJSON / *ErrorResponseApplicationXML), breaking compilation.
The type declarer (GenerateTypesForResponses) and the wrapper-field consumer (GetResponseTypeDefinitions) independently decided when to append a media-type suffix to a response type name, and the two had drifted apart: the consumer suffixed for every supported content type while the declarer only declared a suffixed name when a response carried more than one JSON content type.
Both now route that decision through a single responseMediaTypeSuffix helper, so they cannot disagree. Non-JSON content types reuse the base type name, and JSON entries are suffixed only when a response has more than one JSON content type. The now-unused isMediaTypeSupported helper is removed, and a regression test is added under internal/test/issues/issue-2389.