---
title: "Configuration"
description: "Configure @hey-api/openapi-ts."
url: "https://heyapi.dev/docs/openapi/typescript/configuration"
---

`@hey-api/openapi-ts` supports loading configuration from any file inside your project root folder supported by [jiti loader](https://github.com/unjs/c12?tab=readme-ov-file#-features). Below are the most common file formats.

* openapi-ts.config.ts

  ```ts
  import { defineConfig } from '@hey-api/openapi-ts';


  export default defineConfig({
    input: 'hey-api/backend', // sign up at app.heyapi.dev
    output: 'src/client',
  });
  ```

* openapi-ts.config.cjs

  ```js
  /** @type {import('@hey-api/openapi-ts').UserConfig} */
  module.exports = {
    input: 'hey-api/backend', // sign up at app.heyapi.dev
    output: 'src/client',
  };
  ```

* openapi-ts.config.mjs

  ```js
  /** @type {import('@hey-api/openapi-ts').UserConfig} */
  export default {
    input: 'hey-api/backend', // sign up at app.heyapi.dev
    output: 'src/client',
  };
  ```

Alternatively, you can use `openapi-ts.config.js` and configure the export statement depending on your project setup.

## Input

[Section titled “Input”](#input)

You must provide an input so we can load your OpenAPI specification.

The input can be a string path, URL, [API registry](https://heyapi.dev/openapi-ts/configuration/input#api-registry) shorthand, an object containing any of these, or an object representing an OpenAPI specification. Hey API supports all valid OpenAPI versions and file formats.

You can learn more on the [Input](https://heyapi.dev/openapi-ts/configuration/input) page.

* path

  openapi-ts.config.ts

  ```js
  export default {
    input: './path/to/openapi.json',
  };
  ```

* url

  openapi-ts.config.ts

  ```js
  export default {
    input: 'https://get.heyapi.dev/hey-api/backend', // sign up at app.heyapi.dev
  };
  ```

* registry

  openapi-ts.config.ts

  ```js
  export default {
    input: 'hey-api/backend', // sign up at app.heyapi.dev
  };
  ```

* object

  openapi-ts.config.ts

  ```js
  export default {
    input: {
      path: 'hey-api/backend', // sign up at app.heyapi.dev
      // ...other options
    },
  };
  ```

* spec

  openapi-ts.config.ts

  ```js
  export default {
    input: {
      openapi: '3.1.1',
      // ...rest of your spec
    },
  };
  ```

Tip

If you use an HTTPS URL with a self-signed certificate in development, you will need to set [`NODE_TLS_REJECT_UNAUTHORIZED=0`](https://github.com/hey-api/openapi-ts/issues/276#issuecomment-2043143501) in your environment.

## Output

[Section titled “Output”](#output)

You must set the output so we know where to generate your files. It can be a path to the destination folder or an object containing the destination folder path and optional settings.

You can learn more on the [Output](https://heyapi.dev/openapi-ts/configuration/output) page.

* path

  ```js
  export default {
    input: 'hey-api/backend', // sign up at app.heyapi.dev
    output: 'src/client',
  };
  ```

* object

  ```js
  export default {
    input: 'hey-api/backend', // sign up at app.heyapi.dev
    output: {
      path: 'src/client',
      // ...other options
    },
  };
  ```

Tip

You should treat the output folder as a dependency. Do not directly modify its contents as your changes might be erased when you run `@hey-api/openapi-ts` again.

## Parser

[Section titled “Parser”](#parser)

We parse your input before making it available to plugins. Configuring the parser is optional, but it provides an ideal opportunity to modify or validate your input as needed.

You can learn more on the [Parser](https://heyapi.dev/openapi-ts/configuration/parser) page.

## Plugins

[Section titled “Plugins”](#plugins)

Plugins are responsible for generating artifacts from your input. By default, Hey API will generate TypeScript interfaces and SDK from your OpenAPI specification. You can add, remove, or customize any of the plugins. In fact, we highly encourage you to do so!

You can learn more on the [Output](https://heyapi.dev/openapi-ts/output) page.

## Advanced

[Section titled “Advanced”](#advanced)

More complex configuration scenarios can be handled by providing an array of inputs, outputs, or configurations.

### Multiple jobs

[Section titled “Multiple jobs”](#multiple-jobs)

Throughout this documentation, we generally reference single job configurations. However, you can easily run multiple jobs by providing an array of configuration objects.

* config

  ```js
  export default [
    {
      input: 'foo.yaml',
      output: 'src/foo',
    },
    {
      input: 'bar.yaml',
      output: 'src/bar',
    },
  ];
  ```

* example

  * src

    * foo

      * client/

        * …

      * core/

        * …

      * client.gen.ts

      * index.ts

      * sdk.gen.ts

      * types.gen.ts

    * bar

      * client/

        * …

      * core/

        * …

      * client.gen.ts

      * index.ts

      * sdk.gen.ts

      * types.gen.ts

### Job matrix

[Section titled “Job matrix”](#job-matrix)

Reusing configuration across multiple jobs is possible by defining a job matrix. You can create a job matrix by providing `input` and `output` arrays of matching length.

* config

  ```js
  export default {
    input: ['foo.yaml', 'bar.yaml'],
    output: ['src/foo', 'src/bar'],
  };
  ```

* example

  * src

    * foo

      * client/

        * …

      * core/

        * …

      * client.gen.ts

      * index.ts

      * sdk.gen.ts

      * types.gen.ts

    * bar

      * client/

        * …

      * core/

        * …

      * client.gen.ts

      * index.ts

      * sdk.gen.ts

      * types.gen.ts

### Merging inputs

[Section titled “Merging inputs”](#merging-inputs)

You can merge inputs by defining multiple inputs and a single output.

* config

  ```js
  export default {
    input: ['foo.yaml', 'bar.yaml'],
    output: 'src/client',
  };
  ```

* example

  * src

    * client

      * client/

        * …

      * core/

        * …

      * client.gen.ts

      * index.ts

      * sdk.gen.ts

      * types.gen.ts

## API

[Section titled “API”](#api)

You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/config/types.ts) interface.

## Examples

You can view live examples on [StackBlitz](https://stackblitz.com/orgs/github/hey-api/collections/openapi-ts-examples) or on [GitHub](https://github.com/hey-api/openapi-ts/tree/main/examples).
