Skip to content

Conversation

@soartec-lab
Copy link
Member

fix #2598

Summary

Centralize zod schema import detection logic in writer

Changes

  • add zod detection in packages/core/src/writers/generate-imports-for-builder.ts to automatically append .zod suffix
    • remove isZodSchema flag logic from packages/fetch/src/index.ts
  • add zodSchemaResponse test cases to all clients

@soartec-lab soartec-lab added this to the 8.0.0 milestone Dec 22, 2025
@soartec-lab soartec-lab added enhancement New feature or request hono Hono related issue fetch Fetch client related issue mcp labels Dec 22, 2025
@soartec-lab soartec-lab force-pushed the feat/usable-schema-type-zod-all-client branch 2 times, most recently from 7144aca to 2fa61b6 Compare December 23, 2025 10:14
@soartec-lab soartec-lab force-pushed the feat/usable-schema-type-zod-all-client branch from 2fa61b6 to 94a98d6 Compare December 23, 2025 13:41
@soartec-lab soartec-lab marked this pull request as ready for review December 23, 2025 13:41
Copilot AI review requested due to automatic review settings December 23, 2025 13:41
Copy link
Contributor

Copilot AI left a 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., isZodSchema in fetch package)
  • Added zodSchemaResponse test 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.

Comment on lines +32 to +34
} else {
return [{ exports: imports, dependency: relativeSchemasPath }];
}
Copy link

Copilot AI Dec 23, 2025

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.

Copilot uses AI. Check for mistakes.
Comment on lines +825 to +827
const schemasPath = isObject(output.schemas)
? output.schemas.path
: output.schemas;
Copy link

Copilot AI Dec 23, 2025

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.

Copilot uses AI. Check for mistakes.
@melloware melloware merged commit dad088f into orval-labs:master Dec 23, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request fetch Fetch client related issue hono Hono related issue mcp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

proposal: enhanced zod Integration for fetch Client

2 participants