Skip to content

docs(adr): 0027 support Hey API as a third, opt-in generator stack - #133

Merged
NoZiL merged 2 commits into
mainfrom
docs/124-hey-api-adr
Nov 13, 2026
Merged

NoZiL merged 2 commits into
mainfrom
docs/124-hey-api-adr

Conversation

@NoZiL

@NoZiL NoZiL commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

What and why

Records the outcome of the #124 spike as ADR 0027 (status: accepted after review).

Recommendation: support Hey API (@hey-api/openapi-ts) as a third, opt-in, experimental stack. Don't replace either existing stack, because Hey API's calling style is different. It amends ADR 0017. ADR 0003 (gating) holds as written: the Hey API path keeps $api / $gated + gate() / <Feature>.

Evidence: branch try/hey-api (spike/hey-api/, not for merging), with the generated output committed.

  • Open enums: $resolvers on @hey-api/typescript. Every enum-shapes fixture matches openapi-typescript, and no helpers patch is needed.
  • Core/gated split and the op-ID → op-key map are read from Hey API's IR and symbol registry (Hey API's own naming, e.g. delete → delete_).
  • gate() reads queryKey[0]._id. X-Api-Version and Sunset come through a response interceptor.
  • Copies of test/types.check.ts type-check on TS 5.4, 5.5, 6.0 and 7.0.2, and copies of the test/react.test.tsx scenarios pass (6 tests).

Risks in the ADR: 0.x with no stable release since 2026-06-22; TS 7 breaks generation on 0.99.0 (hey-api/hey-api#4235, fixed in @next); two undocumented internals; output must go in v<n>/sdk/ because of a client name collision.

Closes #124

Checklist

  • mise run check passes (what CI runs). Docs-only: ran pnpm lint; CI runs the rest
  • pnpm changeset added for any change to the published package. Not needed: ADR only, same as docs(adr): 0017 support openapi-typescript and openapi-typesafe side by side #73 for ADR 0017
  • Generated output was not edited by hand (playground/generated, test/fixtures/generated)
  • ADR added or superseded in docs/adr/ if this touches a trigger in AGENTS.md

🤖 Generated with Claude Code

)

Records the #124 spike outcome. Proposed: add `generator: "hey-api"` as an
experimental, opt-in stack, with op-ID gate() and an
`openapi-versions/hey-api` runtime entry; amends ADR 0017. Evidence is on
branch try/hey-api (spike/hey-api/).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@NoZiL
NoZiL merged commit b2ab271 into main Nov 13, 2026
1 check passed
@NoZiL
NoZiL deleted the docs/124-hey-api-adr branch November 13, 2026 16:03
@NoZiL NoZiL mentioned this pull request Nov 13, 2026
4 tasks done
NoZiL added a commit that referenced this pull request Nov 13, 2026
## What and why

Codegen half of ADR 0027: `generator: "hey-api"` runs
`@hey-api/openapi-ts` 0.99.x on each major's merged spec.

- **Output**: Hey API's files go in `v<n>/sdk/`, staged and renamed with
the rest under the codegen lock (ADR 0021/0023). Imports are
extensionless, there is no barrel, and an empty explicit config file
means the app's own `openapi-ts.config.*` is not merged into our
settings.
- **Open enums**: `$resolvers.string` and `$resolvers.union` on
`@hey-api/typescript`. Nullable ones work too, including 3.0 `nullable:
true`.
- **Gating data**: operation ids and export names are read back from Hey
API's IR and symbol registry, never re-derived (e.g. `delete` →
`delete_`). Codegen fails if an operation in `meta.ops` lacks an id, its
sdk function or its TanStack helper, or if two re-exported functions
share a name. `meta.ts` gains `opIds`, and `core.ts` / `gated.ts` split
the functions into floor operations and newer ones. `client.ts` exposes
them as `$api` / `$gated`.
- **Auto-detection**: Hey API is tried last (decided in ADR 0027).
- **Pruning**: each `v<n>` keeps a manifest
(`.openapi-versions-files.json`) of what it wrote. The next run removes
exactly what it wrote before and not now, for example after a
`generator` change. Files codegen never wrote are kept.
- `loadGenerator()` now returns `kind: "schema" | "sdk"`. The Hey API
output types are exported from `openapi-versions/codegen`.

**Don't release before #126.** The generated `client.ts` imports
`openapi-versions/hey-api`, which #126 adds. Until then the fixture's
`client.ts` is excluded from tsc (`tsconfig.json`, marked to drop in
#126).

Not in this PR:
- "CI matrix type-checks the Hey API output on the supported TS range":
there is no TS matrix for any stack yet, so this item goes to #70. I
checked the output by hand on TS 5.4, 5.5, 6.0 and 7.0.2 during the #124
spike.
- TanStack `xxxQueryKey` helpers are not re-exported. Hey API registers
them without operation metadata, so finding them would mean re-deriving
its names, which ADR 0027 rules out. I'll raise it in #126, where the
client surface is designed.

Review: two `/code-review high` passes on `origin/main...HEAD`. Fixed:
app config leaking into Hey API, pruning that could delete the app's
files (now manifest-based), the weak op/export check, empty `JobError`
messages, a misleading `ENOENT` on unreadable specs, duplicate re-export
names, and a quadratic lookup. Left for the maintainer: see the PR
comment on auto-detection.

Closes #125

## Checklist

- [x] `mise run check` passes (what CI runs)
- [x] `pnpm changeset` added for any change to the published package
(`.changeset/hey-api-generator.md`, minor)
- [x] Generated output was not edited by hand (`playground/generated`,
`test/fixtures/generated`)
- [x] ADR added or superseded in `docs/adr/` if this touches a trigger
in `AGENTS.md`: covered by ADR 0027 (#133), which this implements; the
new optional peer is the range it sets

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

Spike: can openapi-versions support Hey API (@hey-api/openapi-ts)?

1 participant