fix: generate clean OpenAPI operation names without duplicated HTTP verb#383
Open
ALagoni97 wants to merge 1 commit into
Open
fix: generate clean OpenAPI operation names without duplicated HTTP verb#383ALagoni97 wants to merge 1 commit into
ALagoni97 wants to merge 1 commit into
Conversation
Generated HTTP client function names for OpenAPI inputs were doubling the
HTTP verb (e.g. `getGetv2connectreferenceId`, `postAddPet`) and, for specs
without `operationId`s, collapsing the path into an uncasable blob because
all non-alphanumeric separators were stripped before casing.
Two causes:
- The channel generator always prepended the HTTP method to the pascal-cased
operationId, even though the operationId already encodes the verb.
- The synthesized operationId (`${method}${path.replace(/[^a-zA-Z0-9]/g,'')}`)
destroyed word boundaries, so `/v2/connect/{referenceId}` became
`v2connectreferenceid` which can no longer be cased.
Extract a shared `deriveOperationId` helper that keeps spec-provided ids
verbatim and synthesizes word-boundary-preserving names from method + path
segments (`GET /v2/connect/{referenceId}` -> `getV2ConnectReferenceId`). Use
it across payloads, parameters, types, headers and the channel generator so
the correlation key stays consistent, and stop re-prepending the method in the
channel function name.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
✅ Deploy Preview for the-codegen-project canceled.
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Problem
Generated HTTP client function names for OpenAPI inputs duplicated the HTTP verb and, for specs without
operationIds, collapsed into uncasable blobs.GET /v2/connect/{referenceId}(no operationId) →getGetv2connectreferenceIdoperationId: findPetsByStatusAndCategoryon GET →getFindPetsByStatusAndCategoryTwo causes:
${method}${path.replace(/[^a-zA-Z0-9]/g,'')}) stripped all separators, destroying word boundaries so casing could never be recovered.Fix
deriveOperationId({operationId, method, path})helper: spec-provided ids are used verbatim; synthesized ids are built from method + path segments with word boundaries preserved (getV2ConnectReferenceId).Result
GET /v2/connect/{referenceId}→getV2ConnectReferenceId;findPetsByStatusAndCategorystaysfindPetsByStatusAndCategory.Tests
test/codegen/inputs/openapi/utils.spec.tscovering verbatim ids, synthesis, kebab segments, and the no-double-verb guarantee.🤖 Generated with Claude Code