Input
You must provide an input so we can load your OpenAPI specification.
Input
The input can be a string path, URL, API registry, an object containing any of these, 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', // sign up at app.heyapi.dev
};
export default {
input: 'hey-api/backend', // sign up at app.heyapi.dev
};
export default {
input: {
path: 'hey-api/backend', // sign up at app.heyapi.dev
// ...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.
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',
},
},
},
};
API Registry
You can store your specifications in an API registry to serve as a single source of truth. This helps prevent drift, improves discoverability, enables version tracking, and more.
Hey API
You can learn more about Hey API Platform on the Integrations page.
export default {
input: 'hey-api/backend', // sign up at app.heyapi.dev
};
The input
object lets you provide additional options to construct the correct URL.
export default {
input: {
path: 'hey-api/backend', // sign up at app.heyapi.dev
branch: 'main',
},
};
We also provide shorthands for other registries:
Scalar
Prefix your input with scalar:
to use the Scalar API Registry.
export default {
input: 'scalar:@scalar/access-service',
};
ReadMe
Prefix your input with readme:
to use the ReadMe API Registry.
export default {
input: 'readme:nysezql0wwo236',
};
export default {
input: 'readme:@developers/v2.0#nysezql0wwo236',
};
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: 'hey-api/backend', // sign up at app.heyapi.dev
watch: true,
},
};
npx @hey-api/openapi-ts \
-i hey-api/backend \
-o src/client \
-w
Examples
You can view live examples on StackBlitz.
Sponsors
Help Hey API stay around for the long haul by becoming a sponsor.