Repository navigation
feat: Support OpenAPI json generation for any tRPC appRouter - #7231
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
π Deployed to the trpc-pr-7231 environment in trpc-sse-and-websockets
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughNew Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI/generateOpenAPIDocument
participant TypeScript as TypeScript Compiler
participant Generator as Schema Generator
participant Components as Component Extractor
participant Builder as Document Builder
CLI->>TypeScript: Load TS program & find router export
TypeScript-->>CLI: Router type symbol
CLI->>Generator: Walk router type structure
Generator->>Components: Extract named types as schemas
Components-->>Generator: Schema references & components
Generator-->>CLI: Procedures (queries/mutations) + Error schema
CLI->>Builder: Assemble OpenAPI document
Builder->>Builder: Build paths from procedures<br/>(wrap outputs in tRPC envelope)
Builder->>Builder: Attach error responses<br/>& component schemas
Builder-->>CLI: Complete OpenAPIDocument
CLI-->>CLI: Write JSON file
sequenceDiagram
participant Client as Generated SDK Client
participant Config as createTRPCHeyApiClientConfig
participant Serializer as Query Serializer
participant HTTP as HTTP Layer
participant Server as tRPC Server
Client->>Config: Initialize with optional transformer
Config->>Config: Normalize transformer<br/>(superjson)
Config-->>Client: querySerializer + bodySerializer<br/>+ responseTransformer
Client->>Serializer: Serialize query params<br/>(input field + transformer)
Serializer-->>Client: URL-encoded params
Client->>HTTP: Execute request with serialized params
HTTP->>Server: GET /procedure?input=...
Server-->>HTTP: JSON response with typed data
HTTP->>Client: Response body
Client->>Client: Apply responseTransformer<br/>(deserialize dates, etc.)
Client-->>Client: Typed result
Estimated code review effortπ― 4 (Complex) | β±οΈ ~60 minutes Justification: The PR introduces substantial hand-written logic in Possibly related PRs
Suggested labels
β¨ Finishing Touches
π§ͺ Generate unit tests (beta)
|
There was a problem hiding this comment.
Pull request overview
Adds a new @trpc/openapi package to generate OpenAPI documents from a tRPC router via TypeScript compiler type analysis, plus docs and test fixtures to support OpenAPI-driven REST client generation.
Changes:
- Introduces
@trpc/openapiwithgenerateOpenAPIDocument, a CLI (trpc-openapi), and hey-api client helpers. - Adds a new docs page and sidebar entry for OpenAPI export and REST client generation.
- Adds extensive OpenAPI generation tests and router fixtures (including hey-api codegen outputs).
Reviewed changes
Copilot reviewed 25 out of 28 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| www/sidebars.ts | Adds the new OpenAPI doc page to the client docs sidebar. |
| www/docs/client/openapi.md | New documentation page describing OpenAPI export and client generation workflow. |
| tsconfig.json | Adds TS path aliases for @trpc/openapi package source. |
| scripts/version.ts | Updates version pinning logic to preserve alpha/beta suffixes and pin deps to base version. |
| packages/openapi/vitest.config.ts | Adds a per-package vitest config with global setup and watch triggers. |
| packages/openapi/tsdown.config.ts | Build config for library entrypoints and CLI bundle output. |
| packages/openapi/tsconfig.json | Package-local TS config for src/test compilation. |
| packages/openapi/tsconfig.build.json | Build TS config for declarations output to dist. |
| packages/openapi/test/scripts/globalSetup.ts | Intended vitest global setup hook to run hey-api codegen. |
| packages/openapi/test/scripts/codegen.ts | Generates OpenAPI JSON + hey-api SDKs for all test routers. |
| packages/openapi/test/scripts/codegen.run.ts | Node entrypoint to run the async codegen script. |
| packages/openapi/test/routers/superjsonRouter.ts.json | Generated OpenAPI JSON artifact for superjsonRouter. |
| packages/openapi/test/routers/superjsonRouter.ts | Router fixture using superjson transformer and z.date(). |
| packages/openapi/test/routers/errorFormatterRouter.ts.json | Generated OpenAPI JSON artifact for errorFormatterRouter. |
| packages/openapi/test/routers/errorFormatterRouter.ts | Router fixture with custom errorFormatter shape. |
| packages/openapi/test/routers/appRouter.ts.json | Large generated OpenAPI JSON artifact for the main fixture router. |
| packages/openapi/test/routers/appRouter.ts | Comprehensive router fixture covering many TS/Zod type shapes. |
| packages/openapi/test/routers/.prettierignore | Ignores generated subdirectories under test routers for prettier. |
| packages/openapi/test/routers/.gitignore | Ignores generated subdirectories under test routers for git. |
| packages/openapi/test/routers/.eslintignore | Ignores generated subdirectories under test routers for eslint. |
| packages/openapi/test/generate.test.ts | New test suite validating spec generation + hey-api client roundtrips. |
| packages/openapi/src/index.ts | Public entrypoint exports generator API + types. |
| packages/openapi/src/heyapi/index.ts | Adds hey-api config helper to interop with tRPC query/body/envelopes. |
| packages/openapi/src/generate.ts | Core TS-compiler-based router walker + JSON Schema/OpenAPI builder. |
| packages/openapi/src/cli.ts | New trpc-openapi CLI for generating JSON specs. |
| packages/openapi/package.json | New package definition, exports map, bin entry, scripts, deps/peers. |
| .prettierignore | Adjusts ignore formatting and adds an ignore entry for an OpenAPI JSON path. |
π‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 9
π§Ή Nitpick comments (6)
scripts/version.ts (1)
31-45: Numbered prereleases collapse to bare channel versions during version normalization.Lines 32β36 extract only the channel name (
alphaorbeta) without preserving the full prerelease identifier. The regex pattern/-(alpha|beta)(\b|$)/causes versions like11.0.0-alpha.1or11.0.0-beta.2to be rewritten as11.0.0-alphaor11.0.0-beta. Since this script runs from theversionhook (package.json:29β30), this would mutate post-bump versions unintentionally.Suggested fix
- const prereleaseMatch = version.match(/-(alpha|beta)(\b|$)/); + const prereleaseMatch = version.match( + /-((alpha|beta)(?:[.-][0-9A-Za-z-]+)*)$/, + );This captures the complete prerelease identifier including build metadata.
π€ Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/version.ts` around lines 31 - 45, The prerelease normalization currently captures only the channel name via prereleaseMatch = version.match(/-(alpha|beta)(\b|$)/) and rebuilds suffixedVersion as `${baseVersion}-${suffix}`, which strips numeric identifiers like .1 or .2; update the regex/search used in prereleaseMatch to capture the entire prerelease token (e.g., include following dot/identifier segments) so that suffixedVersion preserves the full identifier (use the captured full suffix when building suffixedVersion and when replacing `"version": "${version}"` in content and assigning version). Ensure you reference prereleaseMatch, suffix, baseVersion, suffixedVersion, content.replace and version when making the change.packages/openapi/test/routers/appRouter.ts (2)
623-672: Inconsistent pattern:simpleCasesuses object literal instead oft.router().Unlike the other nested routers (
user,complexTypes,inferredReturns,namedTypes,recursiveTypes) which uset.router({...}),simpleCasesis defined as a plain object literal. The OpenAPI generator handles both patterns (viawalkTypefalling back towalkRecordfor plain objects), but this inconsistency may confuse readers.If intentional (to test generator behavior with plain RouterRecord objects), consider adding a comment. Otherwise:
β»οΈ Suggested fix for consistency
- simpleCases: { + simpleCases: t.router({ nullish: t.procedure // ... nullable: t.procedure // ... - }, + }),π€ Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/openapi/test/routers/appRouter.ts` around lines 623 - 672, The simpleCases entry is defined as a plain object literal while other nested routers use t.router(...), causing inconsistency; change the simpleCases declaration to use t.router({...}) with the same procedures (simpleCases: t.router({ nullish: t.procedure... , optional: ..., nullable: ... })) so the shape matches other nested routers (refer to symbol simpleCases and t.router) or alternatively add a clarifying comment above simpleCases indicating the plain object is intentional to test walkRecord/walkType behavior.
1-1: Prefer namespace import for Zod.β»οΈ Suggested fix
-import { z } from 'zod'; +import * as z from 'zod';π€ Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/openapi/test/routers/appRouter.ts` at line 1, Replace the current named import "import { z } from 'zod';" with a namespace import so all Zod symbols are accessed via the namespace (e.g., change to a namespace-style import and keep existing usages of "z" intact); update the import statement at the top of the file where "z" is declared (so code referencing z.<something> continues to work but now comes from the zod namespace).packages/openapi/test/routers/errorFormatterRouter.ts (1)
1-1: Prefer namespace import for Zod.β»οΈ Suggested fix
-import { z } from 'zod'; +import * as z from 'zod';π€ Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/openapi/test/routers/errorFormatterRouter.ts` at line 1, Replace the named import of Zod with a namespace import: change the import statement that currently brings in "{ z }" from 'zod' to a namespace import (import * as z from 'zod') and update any references if necessary; locate the import line and adjust it so the rest of the file (uses of z.object, z.string, etc.) continue to work with the z namespace.packages/openapi/test/routers/superjsonRouter.ts (1)
2-2: Prefer namespace import for Zod.As per coding guidelines: "Prefer namespace imports for validation libraries and large modules (e.g.,
import * as z from 'zod')".β»οΈ Suggested fix
-import { z } from 'zod'; +import * as z from 'zod';π€ Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/openapi/test/routers/superjsonRouter.ts` at line 2, Change the default import of Zod to a namespace import to follow the codebase convention: replace the current "import { z } from 'zod'" with a namespace import (import * as z from 'zod') so all Zod utilities are accessed via the z namespace; update any usages that assume the named import (symbol z) if needed to work with the namespace import.packages/openapi/src/heyapi/index.ts (1)
78-91: Consider safer property access and reducing type assertions.The current implementation assumes
result.dataanderror.dataalways exist when their parent properties are present. If these nested properties areundefined, callingdeserialize(undefined)may behave unexpectedly depending on the transformer (e.g., superjson throws on undefined input).Additionally, the multiple
(data as any)casts could be replaced with a narrower type assertion at the top.β»οΈ Proposed improvement
responseTransformer: async (data: unknown) => { - if (!!data && typeof data === 'object' && 'result' in data) { - (data as any).result.data = transformer.output.deserialize( - (data as any).result.data, - ); - } - if (!!data && typeof data === 'object' && 'error' in data) { - (data as any).error.data = transformer.output.deserialize( - (data as any).error.data, - ); + const response = data as Record<string, unknown> | null | undefined; + if (response && typeof response === 'object') { + const result = response.result as Record<string, unknown> | undefined; + if (result && 'data' in result) { + result.data = transformer.output.deserialize(result.data); + } + const error = response.error as Record<string, unknown> | undefined; + if (error && 'data' in error) { + error.data = transformer.output.deserialize(error.data); + } } return data; },π€ Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/openapi/src/heyapi/index.ts` around lines 78 - 91, In responseTransformer, avoid blanket any casts and calling transformer.output.deserialize on possibly undefined nested properties; narrow the top-level assertion once (e.g., const obj = data as Record<string, unknown> | null) and then check that obj.result?.data !== undefined before calling transformer.output.deserialize(obj.result.data) and similarly guard obj.error?.data !== undefined before deserializing; update the code to only call transformer.output.deserialize when the nested .data exists and assign back into the same nested slot.
π€ Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/openapi/package.json`:
- Around line 22-24: Remove the "postinstall": "pnpm run codegen" lifecycle from
packages/openapi's package.json so consumers of the published tarball won't run
a repo-only codegen step during install; keep the "codegen": "tsx
test/scripts/codegen.ts" script for local/dev use and move any automatic codegen
to repo-only hooks (CI or root-level scripts) or a "prepare" script that is
executed before publishing, but do not rely on postinstall in the published
package.
In `@packages/openapi/src/cli.ts`:
- Around line 85-86: Update the help text and JSDoc to reflect the actual output
version 3.1.1: change the HELP constant string (HELP) from "OpenAPI 3.0" to
"OpenAPI 3.1.1" and also update the JSDoc comment at the top of the file (the
JSDoc lines currently referencing OpenAPI 3.0) to state OpenAPI 3.1.1 so
documentation matches the generator output.
In `@packages/openapi/src/generate.ts`:
- Around line 983-986: The JSDoc above the TypeScript router analysis currently
says "OpenAPI 3.0 document" which is inaccurate because buildOpenAPIDocument
produces "openapi": "3.1.1"; update that JSDoc sentence (the comment starting
"Analyse the given TypeScript router file...") to state "OpenAPI 3.1.1 document"
or a generic "OpenAPI 3.x document" so it matches buildOpenAPIDocument.
- Around line 959-974: The response component name currently uses "Error" but
buildProcedureOperation expects a lowercase "error" $ref; rename the responses
key from "Error" to "error" (keeping the same description, content, schema that
references meta.errorSchema ?? DEFAULT_ERROR_SCHEMA) so the component name
matches the existing reference used by buildProcedureOperation and `$ref`
resolution works correctly.
In `@packages/openapi/test/generate.test.ts`:
- Around line 93-94: Rename the test title string in the failing test block that
currently reads "returns a valid tRPC OpenAPI 3.0 document" to accurately
reflect the asserted OpenAPI version (e.g., "returns a valid tRPC OpenAPI 3.1.1
document"); update the it(...) description in the test case surrounding the
assertion expect(doc.openapi).toBe('3.1.1') so the test name matches the
contract version being asserted.
- Around line 286-298: Replace the manual server lifecycle and direct mutation
of the generated client with the test harness helper: call
testServerAndClientResource({ router: AppRouter }) and await using ctx = ... to
get the server context, then configure the generated client using ctx.httpUrl
instead of creating a handler via createHTTPHandler and calling
heyapiClient.setConfig with baseUrl; keep transformerlessClientConfig merged
into the client config. Update the affected tests (the block around the current
createHTTPHandler/AppRouter usage and the other occurrences at the noted ranges)
to use ctx for setup/teardown so the server is started/stopped by the harness
and the client uses ctx.httpUrl (and ctx.wssUrl where appropriate).
In `@packages/openapi/test/scripts/codegen.run.ts`:
- Line 4: The script currently invokes the async function codegen() without
awaiting it, which can let the process exit before async work like
createClient() finishes; update the entry point to use top-level await (i.e.
await codegen()) so the promise is resolved before exit, and ensure the module
is executed in an environment that supports top-level await (ESM/compatible
runner) so the change takes effect.
In `@scripts/version.ts`:
- Around line 49-53: The global string replace using content.replace (creating
newContent) is overwriting all "@trpc/*" entries including peerDependencies and
thus pinning ranges; instead, parse the manifest JSON (use JSON.parse on
content), update only the dependencies, devDependencies, and
optionalDependencies objects by setting each "@trpc/*" entry to depVersion
(leave peerDependencies untouched), then serialize back with JSON.stringify to
produce newContent; locate the depVersion variable and the current
content.replace usage and replace that string-replace logic with JSON-based
manipulation that targets only those three dependency keys.
In `@www/docs/client/openapi.md`:
- Around line 8-11: The caution admonition (the :::caution block) contains
broken/missing words; replace the current two sentences with a clear alpha
disclaimer such as: "This package is an alpha release; APIs may change without
notice. Because it targets a specification, behavior and results are expected to
improve over time." Update the text inside the :::caution block to use that
complete, grammatically correct copy so the warning reads intentionally and
clearly.
---
Nitpick comments:
In `@packages/openapi/src/heyapi/index.ts`:
- Around line 78-91: In responseTransformer, avoid blanket any casts and calling
transformer.output.deserialize on possibly undefined nested properties; narrow
the top-level assertion once (e.g., const obj = data as Record<string, unknown>
| null) and then check that obj.result?.data !== undefined before calling
transformer.output.deserialize(obj.result.data) and similarly guard
obj.error?.data !== undefined before deserializing; update the code to only call
transformer.output.deserialize when the nested .data exists and assign back into
the same nested slot.
In `@packages/openapi/test/routers/appRouter.ts`:
- Around line 623-672: The simpleCases entry is defined as a plain object
literal while other nested routers use t.router(...), causing inconsistency;
change the simpleCases declaration to use t.router({...}) with the same
procedures (simpleCases: t.router({ nullish: t.procedure... , optional: ...,
nullable: ... })) so the shape matches other nested routers (refer to symbol
simpleCases and t.router) or alternatively add a clarifying comment above
simpleCases indicating the plain object is intentional to test
walkRecord/walkType behavior.
- Line 1: Replace the current named import "import { z } from 'zod';" with a
namespace import so all Zod symbols are accessed via the namespace (e.g., change
to a namespace-style import and keep existing usages of "z" intact); update the
import statement at the top of the file where "z" is declared (so code
referencing z.<something> continues to work but now comes from the zod
namespace).
In `@packages/openapi/test/routers/errorFormatterRouter.ts`:
- Line 1: Replace the named import of Zod with a namespace import: change the
import statement that currently brings in "{ z }" from 'zod' to a namespace
import (import * as z from 'zod') and update any references if necessary; locate
the import line and adjust it so the rest of the file (uses of z.object,
z.string, etc.) continue to work with the z namespace.
In `@packages/openapi/test/routers/superjsonRouter.ts`:
- Line 2: Change the default import of Zod to a namespace import to follow the
codebase convention: replace the current "import { z } from 'zod'" with a
namespace import (import * as z from 'zod') so all Zod utilities are accessed
via the z namespace; update any usages that assume the named import (symbol z)
if needed to work with the namespace import.
In `@scripts/version.ts`:
- Around line 31-45: The prerelease normalization currently captures only the
channel name via prereleaseMatch = version.match(/-(alpha|beta)(\b|$)/) and
rebuilds suffixedVersion as `${baseVersion}-${suffix}`, which strips numeric
identifiers like .1 or .2; update the regex/search used in prereleaseMatch to
capture the entire prerelease token (e.g., include following dot/identifier
segments) so that suffixedVersion preserves the full identifier (use the
captured full suffix when building suffixedVersion and when replacing
`"version": "${version}"` in content and assigning version). Ensure you
reference prereleaseMatch, suffix, baseVersion, suffixedVersion, content.replace
and version when making the change.
βΉοΈ Review info
βοΈ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b0f98e59-3d68-4c57-876d-e26af2a11c13
β Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
π Files selected for processing (27)
.prettierignorepackages/openapi/package.jsonpackages/openapi/src/cli.tspackages/openapi/src/generate.tspackages/openapi/src/heyapi/index.tspackages/openapi/src/index.tspackages/openapi/test/generate.test.tspackages/openapi/test/routers/.eslintignorepackages/openapi/test/routers/.gitignorepackages/openapi/test/routers/.prettierignorepackages/openapi/test/routers/appRouter.tspackages/openapi/test/routers/appRouter.ts.jsonpackages/openapi/test/routers/errorFormatterRouter.tspackages/openapi/test/routers/errorFormatterRouter.ts.jsonpackages/openapi/test/routers/superjsonRouter.tspackages/openapi/test/routers/superjsonRouter.ts.jsonpackages/openapi/test/scripts/codegen.run.tspackages/openapi/test/scripts/codegen.tspackages/openapi/test/scripts/globalSetup.tspackages/openapi/tsconfig.build.jsonpackages/openapi/tsconfig.jsonpackages/openapi/tsdown.config.tspackages/openapi/vitest.config.tsscripts/version.tstsconfig.jsonwww/docs/client/openapi.mdwww/sidebars.ts
There was a problem hiding this comment.
Actionable comments posted: 1
π§Ή Nitpick comments (3)
examples/openapi-codegen/openapi.json (1)
1-6: Consider adding security schemes for production use.Static analysis flags missing security definitions (
CKV_OPENAPI_4,CKV_OPENAPI_5). This is acceptable for a local development example, but production APIs should define appropriate security schemes.If this example is intended to demonstrate security patterns as well, consider adding:
"components": { "securitySchemes": { "bearerAuth": { "type": "http", "scheme": "bearer" } } }π€ Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@examples/openapi-codegen/openapi.json` around lines 1 - 6, Add a production-ready security scheme to the OpenAPI document by defining a components.securitySchemes entry (e.g., "bearerAuth") and reference it in the global security array; specifically update the top-level document (where "openapi" and "info" are defined) to include a components object with securitySchemes containing a bearer/http scheme and then add a top-level "security" entry that uses "bearerAuth" so operations can require the scheme.examples/openapi-codegen/src/client/index.ts (1)
34-40: RedundantquerySerializeroverride.The
querySerializeris already configured globally viaclient.setConfig()on lines 14-17. Passing it again per-call is unnecessary and inconsistent with the other SDK calls (list,create) that don't include it.β»οΈ Suggested simplification
// Fetch the user by ID const byIdResult = await sdk.user.byId({ query: { input: '1', }, - querySerializer: createTRPCHeyApiClientConfig({ transformer }).querySerializer, });π€ Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@examples/openapi-codegen/src/client/index.ts` around lines 34 - 40, The byId call redundantly overrides querySerializer per-call; remove the querySerializer property from the sdk.user.byId invocation so it relies on the global serializer set via client.setConfig (referencing sdk.user.byId and createTRPCHeyApiClientConfig) to match the other SDK calls (list, create) and keep configuration consistent.examples/openapi-codegen/src/scripts/codegen.ts (1)
34-35: Remove theas anytype assertion from the input property.Since
docis already properly typed asOpenAPIDocument(returned fromgenerateOpenAPIDocument()), removing theas anyescape hatch allows TypeScript to enforce the type contract betweengenerateOpenAPIDocument()and@hey-api/openapi-ts. If the shapes drift, this will be caught at compile time rather than failing later during codegen. Alternatively, passinput: specPathas a string (the path toopenapi.jsonwritten on line 28), which@hey-api/[email protected]also supports.π€ Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@examples/openapi-codegen/src/scripts/codegen.ts` around lines 34 - 35, Remove the unnecessary type assertion on the createClient call: use the strongly-typed OpenAPIDocument returned by generateOpenAPIDocument() (the doc variable) directly for the input property instead of casting to any, or alternatively pass the specPath string (the path written earlier) which `@hey-api/openapi-ts` supports; update the call to createClient({ input: doc }) or createClient({ input: specPath }) so TypeScript enforces the expected OpenAPIDocument shape.
π€ Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@examples/openapi-codegen/src/scripts/codegen.ts`:
- Around line 31-47: The code currently deletes the existing SDK with
rmSync(outputDir, { recursive: true, force: true }) before awaiting
createClient(...), which risks leaving no SDK if generation fails; change the
flow to generate into a temporary directory (e.g., create a temp dir next to
outputDir), call createClient with output set to that temp dir, and only after
createClient completes successfully atomically replace or move the temp dir to
outputDir (removing or backing up the old outputDir as part of the swap). Use
the existing symbols rmSync, createClient, and outputDir to implement the
temp-generation-and-swap pattern and ensure cleanup on failure.
---
Nitpick comments:
In `@examples/openapi-codegen/openapi.json`:
- Around line 1-6: Add a production-ready security scheme to the OpenAPI
document by defining a components.securitySchemes entry (e.g., "bearerAuth") and
reference it in the global security array; specifically update the top-level
document (where "openapi" and "info" are defined) to include a components object
with securitySchemes containing a bearer/http scheme and then add a top-level
"security" entry that uses "bearerAuth" so operations can require the scheme.
In `@examples/openapi-codegen/src/client/index.ts`:
- Around line 34-40: The byId call redundantly overrides querySerializer
per-call; remove the querySerializer property from the sdk.user.byId invocation
so it relies on the global serializer set via client.setConfig (referencing
sdk.user.byId and createTRPCHeyApiClientConfig) to match the other SDK calls
(list, create) and keep configuration consistent.
In `@examples/openapi-codegen/src/scripts/codegen.ts`:
- Around line 34-35: Remove the unnecessary type assertion on the createClient
call: use the strongly-typed OpenAPIDocument returned by
generateOpenAPIDocument() (the doc variable) directly for the input property
instead of casting to any, or alternatively pass the specPath string (the path
written earlier) which `@hey-api/openapi-ts` supports; update the call to
createClient({ input: doc }) or createClient({ input: specPath }) so TypeScript
enforces the expected OpenAPIDocument shape.
βΉοΈ Review info
βοΈ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8b420fd9-643c-4789-8127-09d261a9610f
β Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
π Files selected for processing (11)
examples/openapi-codegen/.eslintignoreexamples/openapi-codegen/.prettierignoreexamples/openapi-codegen/openapi.jsonexamples/openapi-codegen/package.jsonexamples/openapi-codegen/src/client/index.tsexamples/openapi-codegen/src/scripts/codegen.tsexamples/openapi-codegen/src/server/db.tsexamples/openapi-codegen/src/server/index.tsexamples/openapi-codegen/src/server/trpc.tsexamples/openapi-codegen/src/shared/transformer.tsexamples/openapi-codegen/tsconfig.json
β Files skipped from review due to trivial changes (1)
- examples/openapi-codegen/.eslintignore
ac487be to
0cf389a
Compare
0cf389a to
f0e6dbd
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 92 out of 185 changed files in this pull request and generated 6 comments.
π‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 92 out of 185 changed files in this pull request and generated 3 comments.
π‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you. |
To see the RFC+Discussion: #7239 (comment)
π― Changes
What changes are made in this PR? Is it a feature or a bug fix?
Adds a TypeScript-compiler-driven OpenAPI 3.1 document generator to @trpc/openapi. The generator resolves fully-computed types (what the vanilla client proxy sees) rather than raw mapped/generic types, and emits a standards-compliant JSON spec, possible for use with any generator or consumer of such a document
This diff is big and it mostly doesn't matter because it's testing code which you can ignore!
Focus on:
11.12.0-alphaand update the version number of releasesβ Checklist
Summary by CodeRabbit
New Features
generateOpenAPIDocument()function or CLI.Documentation
Examples