docs: add OpenAPI http_client consumer example and usage docs#385
Open
ALagoni97 wants to merge 4 commits into
Open
docs: add OpenAPI http_client consumer example and usage docs#385ALagoni97 wants to merge 4 commits into
ALagoni97 wants to merge 4 commits 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>
…ters The request-body extractor treated the presence of an operation `parameters` array as an OpenAPI 2.0 signal and looked for a `in: 'body'` parameter, returning nothing for 3.x operations. But 3.x operations routinely carry `parameters` (path/query/header) alongside a `requestBody`, so any such operation (e.g. a POST with an `X-Correlation-Id` header) had its body silently dropped: the generated context had no `payload` field and the client always sent `body = undefined`. Check `requestBody` first (OpenAPI 3.x) and only fall back to the `in: 'body'` parameter form when no `requestBody` is present (OpenAPI 2.0). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ttp-client-example
There was no OpenAPI example and no "how do I consume this" entry point for the generated HTTP client, which made the payload/parameter/http_client folder split confusing for API consumers. Add a minimal, self-contained `examples/openapi-http-client` project: a trimmed OpenAPI 3.1 document (operations intentionally without operationIds), the codegen config, the committed generated output, and a runnable demo that builds a request body, supplies a path parameter, and reads a typed response. Document the OpenAPI path and consumer usage in docs/protocols/http_client.md and list the example in the examples index. 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.
Why
There was no OpenAPI example and no "how do I consume this" entry point for the generated HTTP client, which made the
payload/·parameter/·http_client.tssplit confusing for API consumers.What
examples/openapi-http-client/— a minimal, self-contained project:operationIds, to show name synthesis),src/index.tsdemo that builds a request body, supplies a path parameter, and reads a typed response. It runs clean and strict-typechecks.docs/protocols/http_client.md— a From OpenAPI section covering the input config, name synthesis, and consumer usage.examples/README.md.This branch merges both fixes so the committed generated output shows the corrected function names (#383) and the wired-up request body (#384). Merge #383 and #384 first, then this will want a rebase onto
main(the fix commits are squashed there) so its diff collapses to just the example + docs.🤖 Generated with Claude Code