Skip to content

feat: http client context cleanup#411

Merged
jonaslagoni merged 6 commits into
feat/plain-object-openapi-parametersfrom
feat/http-client-context-cleanup
Jul 14, 2026
Merged

feat: http client context cleanup#411
jonaslagoni merged 6 commits into
feat/plain-object-openapi-parametersfrom
feat/http-client-context-cleanup

Conversation

@ALagoni97

Copy link
Copy Markdown
Contributor

Summary

  • Remove pagination — the client-side PaginationInfo/applyPagination/extractPaginationInfo stack was spec-unaware invention; it appended offset/limit/cursor params that shadow the typed parameters the spec actually defines. Deleted entirely (including the runtime spec file). A future spec-derived approach is deferred.
  • Remove path from context — half-broken: parameterized operations silently ignored config.path and the legitimate escape hatch is hooks.beforeRequest. Parameterless operations now bake the path literal directly into `${config.baseUrl}${requestTopic}`.
  • RenamesserverbaseUrl, queryParamsadditionalQueryParams (mirrors additionalHeaders). Fixed scheme-less default 'localhost:3000''http://localhost:3000'.
  • Conditional requestHeaders — the field is now emitted only when the spec defines operation-level headers. Operations with no spec headers get a plain Content-Type header init instead of the fallback applyTypedHeaders branch.
  • Plain-object OpenAPI header models — mirrors what the base branch did for parameters: interfaces instead of marshallable classes, plus a standalone serializeXxxHeaders() function imported and called by the generated channel function.

Test plan

  • All 646 unit tests pass (npm test)
  • TypeScript build passes (npm run build)
  • Snapshot diffs reviewed: pagination and { marshal: () => string } are gone; FindPetsByStatusAndCategoryContext gains requestHeaders?: FindPetsByStatusAndCategoryHeaders and the serializer import
  • Runtime HTTP specs still cover auth, hooks, retry, OAuth2, parameters/headers, security schemes, methods (pagination spec deleted intentionally)

🤖 Generated with Claude Code

Deletes PaginationInfo, PaginationConfig and all pagination subtypes,
applyPagination, extractPaginationInfo, parseLinkHeader, and
createPaginationHelpers from the runtime template. Removes pagination
fields from HttpClientResponse and HttpClientContext. Deletes the
pagination runtime spec and strips pagination sections from docs.

The current pagination was client-side invention (offset/limit/cursor
params not derived from the spec) — a future spec-derived implementation
is deferred; see thoughts/2026-07-14-http-client-context-cleanup/plan.md.
path was half-broken: parameterized operations already baked the path
literal into buildUrlWithParameters and silently ignored config.path;
only parameterless operations respected it. Now parameterless ops also
bake the literal path at generation time (e.g. `${config.server}/ping`).

The escape hatch for gateway rewrites is hooks.beforeRequest mutating
params.url, as documented.
Renames mirror the additionalHeaders convention: additionalQueryParams
makes clear it is an escape hatch for params not in the spec, not a
replacement for typed parameters. baseUrl is unambiguous vs the old
server field.

Also fixes the scheme-less default 'localhost:3000' → 'http://localhost:3000'
so generated code works out of the box without a CORS or fetch failure.
3a: Emit requestHeaders in context interface only when the spec defines
operation-level headers; operations with no spec headers get a plain
headersInit instead of the applyTypedHeaders branch.

3b: OpenAPI header models are now generated as plain interfaces (no
marshal/unmarshal/validate) with a standalone serializeXxxHeaders()
function. The channels generator imports and calls that function when
hasSerializeHeaders is true.
@ALagoni97
ALagoni97 requested a review from jonaslagoni as a code owner July 14, 2026 14:31
@vercel

vercel Bot commented Jul 14, 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 14, 2026 2:57pm
the-codegen-project-mcp Ready Ready Preview, Comment Jul 14, 2026 2:57pm

Remove three pagination test cases missed from methods.spec.ts,
hooks.spec.ts, and basics.spec.ts when pagination.spec.ts was deleted.

Refactor generateTypescriptHeadersCore into three extracted helpers
(createAsyncAPIHeadersGenerator, appendOpenAPISerializerFunctions,
deduplicateFiles) to bring cognitive complexity within the lint limit.
Also fix pre-existing TypescryptHeadersContext typo → TypescriptHeadersContext.
@jonaslagoni
jonaslagoni merged commit 5a5d1b2 into feat/plain-object-openapi-parameters Jul 14, 2026
16 checks passed
ALagoni97 added a commit that referenced this pull request Jul 15, 2026
feat: http client context cleanup

Republishes the HTTP-client cleanup from #411 directly on top of main,
decoupled from the plain-object parameter refactor it was originally
based on. Only the HTTP-client changes are included; no parameter
serializer / plain-object-parameter work is carried over.

- Remove pagination: the client-side PaginationInfo/applyPagination/
  extractPaginationInfo stack was spec-unaware invention that appended
  offset/limit/cursor params shadowing the typed parameters. Deleted
  entirely (including the runtime spec). A spec-derived approach is
  deferred.
- Remove `path` from context: parameterized operations already baked the
  path literal and ignored config.path; parameterless operations now bake
  the literal too (`${config.baseUrl}${requestTopic}`). The escape hatch
  for gateway rewrites is hooks.beforeRequest.
- Renames: server → baseUrl, queryParams → additionalQueryParams (mirrors
  additionalHeaders). Fix scheme-less default localhost:3000 →
  http://localhost:3000.
- Conditional requestHeaders: emitted only when the spec defines
  operation-level headers; operations without them get a plain
  Content-Type header init.
- Plain-object OpenAPI header models: interfaces instead of marshallable
  classes, plus a standalone serializeXxxHeaders() function imported and
  called by the generated channel function.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@ALagoni97
ALagoni97 deleted the feat/http-client-context-cleanup branch July 15, 2026 18:14
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.

2 participants