-
-
Notifications
You must be signed in to change notification settings - Fork 529
feat: enabled zod for schemas.type on all clients
#2668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: enabled zod for schemas.type on all clients
#2668
Conversation
7144aca to
2fa61b6
Compare
This reverts commit b8974c1.
2fa61b6 to
94a98d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR centralizes the logic for detecting and handling Zod schema imports by moving the detection from individual client packages to a shared writer function. This enables consistent .zod suffix handling across all clients when schemas.type is set to 'zod'.
- Moved Zod schema detection logic to core writer for centralized handling
- Removed client-specific Zod detection flags (e.g.,
isZodSchemain fetch package) - Added
zodSchemaResponsetest configurations for all supported clients
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/writers/generate-imports-for-builder.ts | Centralized Zod schema detection logic and automatic .zod suffix appending |
| packages/fetch/src/index.ts | Removed client-specific isZodSchema flag logic |
| packages/hono/src/index.ts | Added Zod detection for schema path handling |
| packages/mcp/src/index.ts | Added Zod detection for schema path handling |
| tests/configs/vue-query.config.ts | Added zodSchemaResponse test case |
| tests/configs/swr.config.ts | Added zodSchemaResponse test case |
| tests/configs/svelte-query.config.ts | Added zodSchemaResponse test case |
| tests/configs/react-query.config.ts | Added zodSchemaResponse test case |
| tests/configs/mock.config.ts | Added zodSchemaResponse test case |
| tests/configs/mcp.config.ts | Added zodSchemaResponse test case |
| tests/configs/hono.config.ts | Added zodSchemaResponse test case |
| tests/configs/axios.config.ts | Added zodSchemaResponse test case |
| tests/configs/angular.config.ts | Added zodSchemaResponse test case |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } else { | ||
| return [{ exports: imports, dependency: relativeSchemasPath }]; | ||
| } |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The if-else structure has been inverted from the original code. The original checked if (output.indexFiles) first, but the new code checks if (!output.indexFiles) first. While functionally correct, this inversion makes the code harder to follow and compare with the previous implementation. Consider maintaining the original structure for better maintainability.
| const schemasPath = isObject(output.schemas) | ||
| ? output.schemas.path | ||
| : output.schemas; |
Copilot
AI
Dec 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern of extracting schemasPath is duplicated in multiple locations (mcp/src/index.ts lines 37-39, 366-368, and here). Consider extracting this into a shared utility function to reduce duplication and improve maintainability.
fix #2598
Summary
Centralize
zodschema import detection logic in writerChanges
packages/core/src/writers/generate-imports-for-builder.tsto automatically append.zodsuffixisZodSchemaflag logic frompackages/fetch/src/index.tszodSchemaResponsetest cases to all clients