Skip to content

fix(go-server): use operationId consistently to fix uncompilable output for duplicate operationIds#24169

Merged
wing328 merged 1 commit into
OpenAPITools:masterfrom
halfcrazy:fix-go-duplicate-operationId
Jul 6, 2026
Merged

fix(go-server): use operationId consistently to fix uncompilable output for duplicate operationIds#24169
wing328 merged 1 commit into
OpenAPITools:masterfrom
halfcrazy:fix-go-duplicate-operationId

Conversation

@halfcrazy

@halfcrazy halfcrazy commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

When two paths share the same auto-generated operationId (e.g. /foo and /foo/), go-server and go-gin-server produced uncompilable code: the route map and interfaces used {{operationId}} (deduplicated to FooGet_0 by addOperationToGroup) while the controller handler and service stub used {{nickname}} (deduplicated to FooGet_1 by a separate pass with a different counter convention), so routes referenced handlers that didn't exist.

Switch the go-server/go-gin-server templates from {{nickname}} to {{operationId}} so routes, interfaces, handlers and service stubs all reference the same deduplicated name. This is a no-op for non-duplicate operationIds and leaves DefaultGenerator untouched, so no other generator is affected.

Add regression tests for both generators covering the /foo + /foo/ case.

fix #24167

PR checklist

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@kemokemo

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 8 files

Re-trigger cubic

…ut for duplicate operationIds

When two paths share the same auto-generated operationId (e.g. /foo and
/foo/), go-server and go-gin-server produced uncompilable code: the route
map and interfaces used {{operationId}} (deduplicated to FooGet_0 by
addOperationToGroup) while the controller handler and service stub used
{{nickname}} (deduplicated to FooGet_1 by a separate pass with a different
counter convention), so routes referenced handlers that didn't exist.

Switch the go-server/go-gin-server templates from {{nickname}} to
{{operationId}} so routes, interfaces, handlers and service stubs all
reference the same deduplicated name. This is a no-op for non-duplicate
operationIds and leaves DefaultGenerator untouched, so no other generator
is affected.

Add regression tests for both generators covering the /foo + /foo/ case.
@halfcrazy
halfcrazy force-pushed the fix-go-duplicate-operationId branch from d184194 to 17bde72 Compare July 6, 2026 07:47
@wing328

wing328 commented Jul 6, 2026

Copy link
Copy Markdown
Member

thanks for the PR

cc @antihax (2017/11) @grokify (2018/07) @kemokemo (2018/09) @jirikuncar (2021/01) @ph4r5h4d (2021/04) @lwj5 (2023/04)

@wing328 wing328 added this to the 7.24.0 milestone Jul 6, 2026
@wing328

wing328 commented Jul 6, 2026

Copy link
Copy Markdown
Member

lgtm. thanks for the fix

@wing328
wing328 merged commit 0883085 into OpenAPITools:master Jul 6, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG][go-server] Duplicate auto-generated operationIds produce uncompilable output (route/handler/service name mismatch)

2 participants