feat: OpenAPI Cyclic Types support#7283
Conversation
|
🚅 Deployed to the trpc-pr-7283 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:
WalkthroughSwitched the OpenAPI generator to use a project-local OpenAPI 3.1 type layer, improved recursive/schema registration to emit stable $refs (removed depth>20 truncation), tightened schema/operation types, added helpers for schema traversal, and introduced extensive cyclic/edge-case tests plus many autogenerated client/SDK fixtures and test utilities. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant BeforeRequest as beforeRequest
participant Interceptors
participant Fetch as fetch
participant Parser as parse/validate
Client->>BeforeRequest: normalize options (merge headers, auth, body, serializedBody)
BeforeRequest->>Interceptors: run request interceptors
Interceptors->>Fetch: perform fetch(url, request)
Fetch-->>Interceptors: raw Response or network error
Interceptors->>Parser: run response or error interceptors
Parser->>Client: parse/validate/transform and return data or throw
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR extends @trpc/openapi’s generator and test suite to better support cyclic/recursive TypeScript and Zod types, while tightening the exported OpenAPI type surface to align with openapi-types (OpenAPI v3.1).
Changes:
- Add a new cyclic-types router fixture and a dedicated test suite to validate recursive schema emission.
- Refactor schema typing across generator/tests to use the new
src/types.tsOpenAPI v3.1 type wrappers. - Update generator recursion handling and add an OpenAPI type compatibility test against
openapi-types.
Reviewed changes
Copilot reviewed 32 out of 33 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
packages/openapi/src/generate.ts |
Updates schema generation to use new OpenAPI v3.1 types and adjusts recursion handling. |
packages/openapi/src/types.ts |
Introduces shared OpenAPI v3.1 type wrappers (Document/SchemaObject/etc.) based on openapi-types. |
packages/openapi/src/schemaExtraction.ts |
Switches description overlay logic to operate on SchemaObject. |
packages/openapi/src/index.ts |
Changes package type exports to expose OpenAPIV3_1 types. |
packages/openapi/test/types.ts |
Adds shared test helpers for inspecting OpenAPI documents/schemas. |
packages/openapi/test/generate.test.ts / edgeCases.test.ts / schemaExtraction.test.ts |
Refactors tests to use the new helper utilities and new OpenAPI types. |
packages/openapi/test/cyclicTypes.test.ts |
Adds a new test suite for cyclic types. |
packages/openapi/test/routers/cyclicTypesRouter.ts (+ snapshots + hey-api output) |
Adds a new router fixture and generated OpenAPI/hey-api outputs for cyclic types. |
packages/openapi/test/openApiCompat.test.ts |
Adds a type-level compatibility check vs published openapi-types. |
packages/openapi/package.json / pnpm-lock.yaml |
Adds openapi-types dependency and updates lockfile. |
packages/openapi/README.md |
Updates TODO list related to recursion/async generator investigation. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f823cd3 to
0f15689
Compare
4a94431 to
06c75ef
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 37 out of 38 changed files in this pull request and generated 1 comment.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)
packages/openapi/package.json:97
openapi-typesis imported fromsrc/types.tsand re-exported (viaexport * as OpenAPIV3_1 from './types'). Since these types are part of the published.d.tssurface, consumers will needopenapi-typesinstalled to typecheck. Listing it only underdevDependenciesmay cause downstream TS resolution errors; it should be independencies(orpeerDependenciesif you want consumers to provide it).
"devDependencies": {
"@hey-api/openapi-ts": "^0.94.1",
"@swagger-api/apidom-ls": "^1.6.0",
"@tanstack/intent": "^0.0.23",
"@trpc/server": "11.15.0",
"@types/node": "^22.13.5",
"bson": "^7.2.0",
"eslint": "^9.26.0",
"ion-js": "^5.2.1",
"openapi-types": "^12.1.3",
"superjson": "^1.12.4",
"tsdown": "0.12.7",
"typescript": "^5.9.2",
"vscode-languageserver-textdocument": "^1.0.12",
"zod": "^4.2.1"
},
"peerDependencies": {
"@hey-api/openapi-ts": ">=0.13.0",
"@trpc/server": "11.15.0",
"typescript": ">=5.7.2",
"zod": ">=4.0.0"
},
💡 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 40 out of 41 changed files in this pull request and generated no new comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 44 out of 45 changed files in this pull request and generated 1 comment.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 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 44 out of 45 changed files in this pull request and generated no new comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 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 64 out of 65 changed files in this pull request and generated no new comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 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. |
🎯 Changes
What changes are made in this PR? Is it a feature or a bug fix?
✅ Checklist
Summary by CodeRabbit