OrvalOrval

Basics

Learn the fundamentals of configuring Orval

Start by generating or defining an OpenAPI specification (example petstore.yaml).

Then create a file orval.config.ts at the root of your project.

Basic Configuration

orval.config.ts
import { defineConfig } from 'orval';

export default defineConfig({
  petstore: {
    output: {
      mode: 'single',
      target: './src/petstore.ts',
      schemas: './src/model',
      mock: true,
    },
    input: {
      target: './petstore.yaml',
    },
  },
});

Output Options

The output options configure how and where you want to write the generated code.

OptionDescription
modeSpecifies how files are generated. Default: single (one file with everything)
targetSpecifies where the generated file(s) will be written
schemasSpecifies where the models will be written
clientSpecifies the HTTP client to generate (axios, react-query, vue-query, etc.)
mockGenerates mocks with MSW. See the MSW guide

Input Options

The input options configure the imported specification and any optional overrides.

OptionDescription
targetPath or URL to the OpenAPI specification file
override.transformerTransform the specification (e.g., add a parameter to every request)

Next Steps

On this page