Skip to content

Conversation

@soartec-lab
Copy link
Member

@soartec-lab soartec-lab commented Dec 21, 2025

fix #2598

Summary

Improved to generate zod schemas for request parameters (body, queryParams, headers).
Previously, only response schemas had zod schemas generated. Now, zod schemas are also generated for request parameters.

Changes

Before

model/
├── createPetsBody.ts
├── createPetsParams.ts
└── pet.zod.ts

After

model/
├── createPetsBody.ts
├── createPetsBody.zod.ts
├── createPetsParams.ts
├── createPetsParams.zod.ts
├── createPetsHeaders.zod.ts
└── pet.zod.ts

Copilot AI review requested due to automatic review settings December 21, 2025 04:08
@soartec-lab soartec-lab added enhancement New feature or request fetch Fetch client related issue labels Dec 21, 2025
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 enhances Zod schema generation to include request parameters (body, query parameters, and headers) in addition to the existing response schema generation. Previously, only response types had corresponding .zod.ts files generated; now all request parameter types also get their own Zod schema files for runtime validation.

Key Changes

  • Refactored schema generation logic into reusable helper functions (generateZodSchemaFileContent, writeZodSchemaIndex)
  • Added new writeZodSchemasFromVerbs function to generate Zod schemas from request parameters
  • Updated import generation to use the new Zod schemas and avoid duplicate imports

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
packages/orval/src/write-zod-specs.ts Extracted common schema generation logic and added new function to generate Zod schemas from verb options (request body, query params, headers)
packages/orval/src/write-specs.ts Integrated the new writeZodSchemasFromVerbs function into the schema writing workflow
packages/fetch/src/index.ts Updated schema references to remove redundant "Schema" suffix and added filtering logic to prevent duplicate imports

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@soartec-lab soartec-lab force-pushed the feat/generate-request-params-schema-with-zod branch from 66b5456 to 9f21bbb Compare December 21, 2025 04:14
@soartec-lab soartec-lab force-pushed the feat/generate-request-params-schema-with-zod branch from 9f21bbb to ab8791f Compare December 21, 2025 04:28
@soartec-lab soartec-lab added this to the 8.0.0 milestone Dec 21, 2025
@melloware melloware merged commit 8d6c24a into orval-labs:master Dec 21, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

proposal: enhanced zod Integration for fetch Client

2 participants