OpenAPI Typescript Codegen for Vite
npm install @7nohe/vite-plugin-openapi-typescript-codegen> [!IMPORTANT]
> This library has been archived.
> This library is no longer maintained because OpenAPI Typescript Codegen is no longer maintained.
OpenAPI Typescript Codegen for Vite
``bash`
npm install -D @7nohe/vite-plugin-openapi-typescript-codegen
Add to your vite.config.ts
`ts
import { defineConfig } from "vite";
import openApiTypescriptCodegen from "@7nohe/vite-plugin-openapi-typescript-codegen";
export default defineConfig({
plugins: [
openApiTypescriptCodegen({
input: "./petstore.yaml",
output: "./openapi",
watch: {
interval: 500,
disabled: process.env.NODE_ENV === "production",
},
}),
],
});
`
petstore.yaml is the schema file based on OpenAPI specification.
This plugin generates TypeScript clients by running vite/vite build.
It also detects changes in the schema file and regenerates the client files.
| name | type | describe |
| -------------- | ------- | ------------------------------------------- |
| input | string | OpenAPI specification file (required) |
| output | string | Output directory (default: openapi) |1000
| watch.interval | number | Interval of file watching (default: ) |false`) |
| watch.disabled | boolean | Disable file watching (default:
OpenAPI Typescript Codegen options are also available.
MIT