Skip to content

Commit 44d30ac

Browse files
mromaszewiczclaude
andcommitted
fix: skip operationId write-back for alias operations
Alias paths share the same *openapi3.Operation pointer as the canonical path. Writing the suffixed alias name (e.g. GetTestAlias0) back to op.OperationID would corrupt the canonical operation's ID in the embedded spec. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent aee9d31 commit 44d30ac

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pkg/codegen/operations.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,8 +672,10 @@ func OperationDefinitions(swagger *openapi3.T) ([]OperationDefinition, error) {
672672
operationId = operationId + fmt.Sprintf("Alias%d", n)
673673
}
674674

675-
if !globalState.options.Compatibility.PreserveOriginalOperationIdCasingInEmbeddedSpec {
676-
// update the existing, shared, copy of the spec if we're not wanting to preserve it
675+
if !globalState.options.Compatibility.PreserveOriginalOperationIdCasingInEmbeddedSpec && !isAlias {
676+
// update the existing, shared, copy of the spec if we're not wanting to preserve it.
677+
// Skip for aliases: they share the same *Operation as the canonical path,
678+
// and writing the suffixed name back would corrupt the original.
677679
op.OperationID = operationId
678680
}
679681

0 commit comments

Comments
 (0)