Skip to content

fix(http): type context parameters and headers with concrete generated models#407

Merged
jonaslagoni merged 2 commits into
mainfrom
fix/http-client-typed-params
Jul 13, 2026
Merged

fix(http): type context parameters and headers with concrete generated models#407
jonaslagoni merged 2 commits into
mainfrom
fix/http-client-typed-params

Conversation

@ALagoni97

Copy link
Copy Markdown
Contributor

Problem

When generating a TypeScript HTTP fetch client, the generated context interface discarded the fully-typed parameter class and headers model that are already generated. Instead of the concrete types, it emitted structural stubs:

export interface GetV2TransactionsContext extends HttpClientContext {
  parameters: { getChannelWithParameters: (path: string) => string };
  requestHeaders?: { marshal: () => string };
}

So a consumer calling getV2Transactions(context) got no type support on context.parameters (the actual query/path params like skip, take, search, referenceId) or context.requestHeaders.

Fix

generateContextInterface (in http/client.ts) only received a hasParameters: boolean and never saw the concrete class names — even though they were already in hand (channelParameters.type). The headers model wasn't threaded into the renderer at all.

  • Thread channelParameters.type / channelHeaders.type into the context interface, mirroring the existing EventSource protocol.
  • Plumb the headers model through http/index.tsrenderHttpFetchClient (added channelHeaders to RenderHttpParameters).

Result:

export interface GetGetUserItemContext extends HttpClientContext {
  parameters: UserItemsParameters;
  requestHeaders?: ItemRequestHeaders;
}

The concrete parameter class still exposes getChannelWithParameters, so buildUrlWithParameters(...) in the function body is unaffected. Operations without a typed headers model keep the structural { marshal: () => string } fallback.

Verification

  • npm run typecheck passes.
  • Regenerated the committed runtime output (test/runtime/typescript/src/request-reply/channels/http_client.ts) — context interfaces now reference UserItemsParameters / ItemRequestHeaders, matching what the parameters-headers.spec.ts runtime spec already imports and constructs.
  • Sanity-checked against the openapi-http-client example: parameters now resolves to the concrete generated params class.

Note: npm run prepare:pr could not be run to completion locally because ESLint 8's extensionless .eslintrc loader fails under Node 25 (pre-existing, reproduces on a clean checkout, unrelated to this diff). Please run the full quality gate in CI / on a Node 22 environment.

🤖 Generated with Claude Code

…d models

The HTTP fetch client context interface discarded the fully-typed parameter
class and headers model that are already generated, emitting a structural stub
(`{ getChannelWithParameters }` / `{ marshal }`) instead. Consumers got no type
support on `context.parameters` or `context.requestHeaders`.

Thread the concrete `channelParameters`/`channelHeaders` types into
`generateContextInterface` (mirroring the EventSource protocol) so the context
references the real classes. The parameter class still exposes
`getChannelWithParameters`, so URL building is unaffected; operations without a
typed headers model keep the structural `{ marshal }` fallback.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ALagoni97 ALagoni97 requested a review from jonaslagoni as a code owner July 13, 2026 16:58
@vercel

vercel Bot commented Jul 13, 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 13, 2026 5:08pm
the-codegen-project-mcp Ready Ready Preview, Comment Jul 13, 2026 5:08pm

The OpenAPI HTTP client snapshot now reflects the concrete parameter class
(`parameters: Parameter`) instead of the structural `getChannelWithParameters`
stub.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jonaslagoni jonaslagoni merged commit fa5701b into main Jul 13, 2026
16 checks passed
@jonaslagoni

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.74.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants