Skip to content

Conversation

@soartec-lab
Copy link
Member

fix #2598

Summary

Extended the schemas configuration option to support both TypeScript type definitions and Zod schema generation through a unified interface. Users can now specify the schema generation type (typescript or zod) along with the output path, and can generate multiple schema types simultaneously using array configuration.

Details

1: Existing Behavior

{
  output: {
    schemas: './model'
  }
}

Generated Files:

  • ./model/pet.ts
  • ./model/dog.ts

2: TypeScript Schema Generation

same behavior as existing.

{
  output: {
    schemas: {
      path: './model',
      type: 'typescript'
    }
  }
}

Generated Files:

  • ./model/pet.ts
  • ./model/dog.ts

3: Zod Schema Generation

{
  output: {
    schemas: {
      path: './model',
      type: 'zod'
    }
  }
}

Generated Files:

  • ./model/pet.zod.ts
  • ./model/dog.zod.ts

4: Multiple Schema Types

I'm not sure if it's necessary to specify both "typescript" and "zod" as the type. Therefore, I may stop supporting specifying multiple types as an array.

{
  output: {
    schemas: {
      path: './model',
      type: ['typescript', 'zod']
    }
  }
}

Generated Files:

  • ./model/pet.ts
  • ./model/dog.ts
  • ./model/pet.zod.ts
  • ./model/dog.zod.ts

Copilot AI review requested due to automatic review settings December 13, 2025 09:16
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 adds support for Zod schema generation alongside TypeScript type definitions through an enhanced output.schemas configuration option. Users can now specify the schema type (typescript or zod) and generate multiple schema types simultaneously. This addresses issue #2598 by providing a unified interface for schema generation that supports both TypeScript and Zod outputs.

Key changes:

  • Extended schemas option to accept either a string path (existing behavior) or an object with path and type properties
  • Implemented Zod schema file generation with .zod.ts extension
  • Added support for generating multiple schema types via array configuration

Reviewed changes

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

Show a summary per file
File Description
packages/core/src/types.ts Added SchemaGenerationType, SchemaOptions types and updated schema-related type definitions
packages/orval/src/utils/options.ts Added normalizeSchemasOption function to handle new schema configuration format
packages/orval/src/write-specs.ts Extended schema writing logic to support both TypeScript and Zod generation based on configuration
packages/orval/src/write-zod-specs.ts New file implementing Zod schema generation with proper imports and type inference
packages/zod/src/index.ts Exported dereference function and isZodVersionV4 for use in Zod schema generation
packages/core/src/generators/schema-definition.ts Added OpenAPI schema object to GeneratorSchema type for Zod processing
packages/core/src/generators/interface.ts Included schema object in interface generation output
packages/orval/src/import-open-api.ts Added spec to WriteSpecBuilder for schema reference resolution
packages/core/src/writers/*.ts Updated all writer modes to handle new schema configuration format
tests/configs/default.config.ts Added test configurations for typescript-only, zod-only, and combined schema generation

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

@soartec-lab soartec-lab added this to the 8.0.0 milestone Dec 13, 2025
@soartec-lab soartec-lab added the enhancement New feature or request label Dec 13, 2025
@melloware melloware merged commit 8b2ff4d into orval-labs:master Dec 13, 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

proposal: enhanced zod Integration for fetch Client

2 participants