Configuration ​
@hey-api/openapi-ts
supports loading configuration from any file inside your project root folder supported by jiti loader. Below are the most common file formats.
import { defineConfig } from '@hey-api/openapi-ts';
export default defineConfig({
input: 'https://get.heyapi.dev/hey-api/backend',
output: 'src/client',
});
/** @type {import('@hey-api/openapi-ts').UserConfig} */
module.exports = {
input: 'https://get.heyapi.dev/hey-api/backend',
output: 'src/client',
};
/** @type {import('@hey-api/openapi-ts').UserConfig} */
export default {
input: 'https://get.heyapi.dev/hey-api/backend',
output: 'src/client',
};
Alternatively, you can use openapi-ts.config.js
and configure the export statement depending on your project setup.
Input ​
You must set the input so we can load your OpenAPI specification. It can be a path or URL, object containing a path or URL, or an object representing an OpenAPI specification. Hey API supports all valid OpenAPI versions and file formats.
You can learn more on the Input page.
export default {
input: './path/to/openapi.json',
};
export default {
input: 'https://get.heyapi.dev/hey-api/backend',
};
export default {
input: {
path: 'https://get.heyapi.dev/hey-api/backend',
// ...other options
},
};
export default {
input: {
openapi: '3.1.1',
// ...rest of your spec
},
};
INFO
If you use an HTTPS URL with a self-signed certificate in development, you will need to set NODE_TLS_REJECT_UNAUTHORIZED=0
in your environment.
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 page.
export default {
input: 'https://get.heyapi.dev/hey-api/backend',
output: 'src/client',
};
export default {
input: 'https://get.heyapi.dev/hey-api/backend',
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 ​
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 page.
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 page.
Config API ​
You can view the complete list of options in the UserConfig interface.
Examples ​
You can view live examples on StackBlitz.
Sponsors ​
Love Hey API? Become our sponsor.