Input ​
You must set the input so we can load your OpenAPI specification.
Input ​
Input 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.
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.
Hey API Platform options ​
You might want to use the Hey API Platform to store your specifications. If you do so, the input
object provides options to help with constructing the correct URL.
export default {
input: {
path: 'https://get.heyapi.dev/',
branch: 'main',
project: 'backend',
},
};
Request options ​
You can pass any valid Fetch API options to the request for fetching your specification. This is useful if your file is behind auth for example.
export default {
input: {
path: 'https://secret.com/protected-spec',
fetch: {
headers: {
Authorization: 'Bearer xxx',
},
},
},
};
Watch Mode ​
WARNING
Watch mode currently supports only remote files via URL.
If your schema changes frequently, you may want to automatically regenerate the output during development. To watch your input file for changes, enable input.watch
mode in your configuration or pass the --watch
flag to the CLI.
export default {
input: {
path: 'https://get.heyapi.dev/hey-api/backend',
watch: true,
},
};
npx @hey-api/openapi-ts \
-i https://get.heyapi.dev/hey-api/backend \
-o src/client \
-w
Examples ​
You can view live examples on StackBlitz.
Sponsors ​
Love Hey API? Become our sponsor.