Skip to content

docs: add OpenAPI http_client consumer example and usage docs#385

Open
ALagoni97 wants to merge 4 commits into
mainfrom
docs/openapi-http-client-example
Open

docs: add OpenAPI http_client consumer example and usage docs#385
ALagoni97 wants to merge 4 commits into
mainfrom
docs/openapi-http-client-example

Conversation

@ALagoni97

Copy link
Copy Markdown
Contributor

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.ts split confusing for API consumers.

What

  • examples/openapi-http-client/ — a minimal, self-contained project:
    • a trimmed OpenAPI 3.1 document (operations intentionally without operationIds, to show name synthesis),
    • the codegen config, the committed generated output, and
    • a runnable src/index.ts demo 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.
  • Listed the example in examples/README.md.

⚠️ Depends on #383 and #384

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

ALagoni97 and others added 4 commits July 6, 2026 21:32
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>
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>
@ALagoni97 ALagoni97 requested a review from jonaslagoni as a code owner July 6, 2026 19:51
@netlify

netlify Bot commented Jul 6, 2026

Copy link
Copy Markdown

Deploy Preview for the-codegen-project canceled.

Name Link
🔨 Latest commit 119347e
🔍 Latest deploy log https://app.netlify.com/projects/the-codegen-project/deploys/6a4c0755b308750008759fdb

@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
the-codegen-project Ready Ready Preview, Comment Jul 6, 2026 7:53pm
the-codegen-project-mcp Ready Ready Preview, Comment Jul 6, 2026 7:53pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant