Parameter generated structures has params postfix to avoid names conflicting#292
Open
deansotnikov wants to merge 4 commits intooapi-codegen:mainfrom
Open
Parameter generated structures has params postfix to avoid names conflicting#292deansotnikov wants to merge 4 commits intooapi-codegen:mainfrom
deansotnikov wants to merge 4 commits intooapi-codegen:mainfrom
Conversation
mromaszewicz
added a commit
to mromaszewicz/oapi-codegen
that referenced
this pull request
Feb 11, 2026
I've been meaning to use this approach for a long time, because the attempts at avoiding type collisions via structure suffixes or prefixes work sporadically, at best. Conflict resolution is fundamentally a global problem, not a local problem when doing recursive traversal, so this PR splits the code generation into two parts. First, the OAPI document structure is traversed, and all the schemas that we generate are gathered up into a list of candidates, then we do global conflict resolution across the space of all schemas. This allows us to preserve the functionality of things affected by schema name - `$ref`, `required` properties, and so forth. This fixes issue oapi-codegen#1474 (client response wrapper type colliding with a component schema of the same name and improves issue oapi-codegen#200 handling (same name across schemas, parameters, responses, requestBodies, headers). The new system is gated behind the existing `resolve-type-name-collisions` output option. When disabled, behavior is unchanged, oapi-codegen exits with an error. This flag is default false, so there is no behavior change to oapi-codegen unless it's specified. All current test files regenerate without any differences. Added a comprehensive test which reproduces the scenarios in all the PR's and Issues below, and adds a few more, to make sure that references to renamed targets are also correct.. Key changes: - gather.go: walks entire spec collecting schemas with location metadata - resolve_names.go: assigns unique names via context suffix, per-schema disambiguation, and numeric fallback strategies - Component schemas are privileged and keep bare names on collision - Client response wrapper types now participate in collision detection - Removed ComponentType/DefinedComp from Schema struct - Removed FixDuplicateTypeNames and related functions from utils.go Obsoletes issues: - oapi-codegen#1474 Schema name vs client wrapper (CreateChatCompletionResponse) - oapi-codegen#1713 Schema name vs client wrapper (CreateBlueprintResponse) - oapi-codegen#1450 Schema name vs client wrapper (DeleteBusinessResponse) - oapi-codegen#2097 Path response type vs schema definition (Status) - oapi-codegen#255 Endpoint path vs response type (QueryResponse) - oapi-codegen#899 Duplicate types from response wrapper vs schema (AccessListResponse) - oapi-codegen#1357 Schema vs operationId response (ListAssistantsResponse, OpenAI spec) - oapi-codegen#254 Cross-section: requestBodies vs schemas (Pet) - oapi-codegen#407 Cross-section: requestBodies vs schemas (myThing) - oapi-codegen#1881 Cross-section: requestBodies with multiple content types Obsoletes PRs: - oapi-codegen#292 Parameter structures params postfix (superseded by context suffix) - oapi-codegen#1005 Fix generate equals structs (superseded by multi-pass resolution) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> EOF )
mromaszewicz
added a commit
to mromaszewicz/oapi-codegen
that referenced
this pull request
Feb 12, 2026
I've been meaning to use this approach for a long time, because the attempts at avoiding type collisions via structure suffixes or prefixes work sporadically, at best. Conflict resolution is fundamentally a global problem, not a local problem when doing recursive traversal, so this PR splits the code generation into two parts. First, the OAPI document structure is traversed, and all the schemas that we generate are gathered up into a list of candidates, then we do global conflict resolution across the space of all schemas. This allows us to preserve the functionality of things affected by schema name - `$ref`, `required` properties, and so forth. This fixes issue oapi-codegen#1474 (client response wrapper type colliding with a component schema of the same name and improves issue oapi-codegen#200 handling (same name across schemas, parameters, responses, requestBodies, headers). The new system is gated behind the existing `resolve-type-name-collisions` output option. When disabled, behavior is unchanged, oapi-codegen exits with an error. This flag is default false, so there is no behavior change to oapi-codegen unless it's specified. All current test files regenerate without any differences. Added a comprehensive test which reproduces the scenarios in all the PR's and Issues below, and adds a few more, to make sure that references to renamed targets are also correct.. Key changes: - gather.go: walks entire spec collecting schemas with location metadata - resolve_names.go: assigns unique names via context suffix, per-schema disambiguation, and numeric fallback strategies - Component schemas are privileged and keep bare names on collision - Client response wrapper types now participate in collision detection - Removed ComponentType/DefinedComp from Schema struct - Removed FixDuplicateTypeNames and related functions from utils.go Obsoletes issues: - oapi-codegen#1474 Schema name vs client wrapper (CreateChatCompletionResponse) - oapi-codegen#1713 Schema name vs client wrapper (CreateBlueprintResponse) - oapi-codegen#1450 Schema name vs client wrapper (DeleteBusinessResponse) - oapi-codegen#2097 Path response type vs schema definition (Status) - oapi-codegen#255 Endpoint path vs response type (QueryResponse) - oapi-codegen#899 Duplicate types from response wrapper vs schema (AccessListResponse) - oapi-codegen#1357 Schema vs operationId response (ListAssistantsResponse, OpenAI spec) - oapi-codegen#254 Cross-section: requestBodies vs schemas (Pet) - oapi-codegen#407 Cross-section: requestBodies vs schemas (myThing) - oapi-codegen#1881 Cross-section: requestBodies with multiple content types Obsoletes PRs: - oapi-codegen#292 Parameter structures params postfix (superseded by context suffix) - oapi-codegen#1005 Fix generate equals structs (superseded by multi-pass resolution) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> EOF )
mromaszewicz
added a commit
to mromaszewicz/oapi-codegen
that referenced
this pull request
Feb 13, 2026
I've been meaning to use this approach for a long time, because the attempts at avoiding type collisions via structure suffixes or prefixes work sporadically, at best. Conflict resolution is fundamentally a global problem, not a local problem when doing recursive traversal, so this PR splits the code generation into two parts. First, the OAPI document structure is traversed, and all the schemas that we generate are gathered up into a list of candidates, then we do global conflict resolution across the space of all schemas. This allows us to preserve the functionality of things affected by schema name - `$ref`, `required` properties, and so forth. This fixes issue oapi-codegen#1474 (client response wrapper type colliding with a component schema of the same name and improves issue oapi-codegen#200 handling (same name across schemas, parameters, responses, requestBodies, headers). The new system is gated behind the existing `resolve-type-name-collisions` output option. When disabled, behavior is unchanged, oapi-codegen exits with an error. This flag is default false, so there is no behavior change to oapi-codegen unless it's specified. All current test files regenerate without any differences. Added a comprehensive test which reproduces the scenarios in all the PR's and Issues below, and adds a few more, to make sure that references to renamed targets are also correct.. Key changes: - gather.go: walks entire spec collecting schemas with location metadata - resolve_names.go: assigns unique names via context suffix, per-schema disambiguation, and numeric fallback strategies - Component schemas are privileged and keep bare names on collision - Client response wrapper types now participate in collision detection - Removed ComponentType/DefinedComp from Schema struct - Removed FixDuplicateTypeNames and related functions from utils.go Obsoletes issues: - oapi-codegen#1474 Schema name vs client wrapper (CreateChatCompletionResponse) - oapi-codegen#1713 Schema name vs client wrapper (CreateBlueprintResponse) - oapi-codegen#1450 Schema name vs client wrapper (DeleteBusinessResponse) - oapi-codegen#2097 Path response type vs schema definition (Status) - oapi-codegen#255 Endpoint path vs response type (QueryResponse) - oapi-codegen#899 Duplicate types from response wrapper vs schema (AccessListResponse) - oapi-codegen#1357 Schema vs operationId response (ListAssistantsResponse, OpenAI spec) - oapi-codegen#254 Cross-section: requestBodies vs schemas (Pet) - oapi-codegen#407 Cross-section: requestBodies vs schemas (myThing) - oapi-codegen#1881 Cross-section: requestBodies with multiple content types Obsoletes PRs: - oapi-codegen#292 Parameter structures params postfix (superseded by context suffix) - oapi-codegen#1005 Fix generate equals structs (superseded by multi-pass resolution) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> EOF )
mromaszewicz
added a commit
to mromaszewicz/oapi-codegen
that referenced
this pull request
Feb 15, 2026
I've been meaning to use this approach for a long time, because the attempts at avoiding type collisions via structure suffixes or prefixes work sporadically, at best. Conflict resolution is fundamentally a global problem, not a local problem when doing recursive traversal, so this PR splits the code generation into two parts. First, the OAPI document structure is traversed, and all the schemas that we generate are gathered up into a list of candidates, then we do global conflict resolution across the space of all schemas. This allows us to preserve the functionality of things affected by schema name - `$ref`, `required` properties, and so forth. This fixes issue oapi-codegen#1474 (client response wrapper type colliding with a component schema of the same name and improves issue oapi-codegen#200 handling (same name across schemas, parameters, responses, requestBodies, headers). The new system is gated behind the existing `resolve-type-name-collisions` output option. When disabled, behavior is unchanged, oapi-codegen exits with an error. This flag is default false, so there is no behavior change to oapi-codegen unless it's specified. All current test files regenerate without any differences. Added a comprehensive test which reproduces the scenarios in all the PR's and Issues below, and adds a few more, to make sure that references to renamed targets are also correct.. Key changes: - gather.go: walks entire spec collecting schemas with location metadata - resolve_names.go: assigns unique names via context suffix, per-schema disambiguation, and numeric fallback strategies - Component schemas are privileged and keep bare names on collision - Client response wrapper types now participate in collision detection - Removed ComponentType/DefinedComp from Schema struct - Removed FixDuplicateTypeNames and related functions from utils.go Obsoletes issues: - oapi-codegen#1474 Schema name vs client wrapper (CreateChatCompletionResponse) - oapi-codegen#1713 Schema name vs client wrapper (CreateBlueprintResponse) - oapi-codegen#1450 Schema name vs client wrapper (DeleteBusinessResponse) - oapi-codegen#2097 Path response type vs schema definition (Status) - oapi-codegen#255 Endpoint path vs response type (QueryResponse) - oapi-codegen#899 Duplicate types from response wrapper vs schema (AccessListResponse) - oapi-codegen#1357 Schema vs operationId response (ListAssistantsResponse, OpenAI spec) - oapi-codegen#254 Cross-section: requestBodies vs schemas (Pet) - oapi-codegen#407 Cross-section: requestBodies vs schemas (myThing) - oapi-codegen#1881 Cross-section: requestBodies with multiple content types Obsoletes PRs: - oapi-codegen#292 Parameter structures params postfix (superseded by context suffix) - oapi-codegen#1005 Fix generate equals structs (superseded by multi-pass resolution) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> EOF )
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.
Hi!
When 'parameter' has the same naming as 'response' they are conflicting.