Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/7nohe/vite-plugin-openapi-typescript-codegen
OpenAPI Typescript Codegen for Vite
https://github.com/7nohe/vite-plugin-openapi-typescript-codegen
openapi typescri
Last synced: 17 days ago
JSON representation
OpenAPI Typescript Codegen for Vite
- Host: GitHub
- URL: https://github.com/7nohe/vite-plugin-openapi-typescript-codegen
- Owner: 7nohe
- Created: 2022-07-14T15:13:04.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-06T14:06:16.000Z (about 2 years ago)
- Last Synced: 2024-10-15T02:32:38.194Z (about 1 month ago)
- Topics: openapi, typescri
- Language: TypeScript
- Homepage:
- Size: 80.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# vite-plugin-openapi-typescript-codegen
[OpenAPI Typescript Codegen](https://github.com/ferdikoomen/openapi-typescript-codegen) for Vite
## Install
```bash
npm install -D @7nohe/vite-plugin-openapi-typescript-codegen
```## Usage
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.
## Options
| name | type | describe |
| --------------- | ----------------- | ------------------------------------------- |
| input | string | OpenAPI specification file (required) |
| output | string | Output directory (default: `openapi`) |
| watch.interval | number | Interval of file watching (default: `1000`) |
| watch.disabled | boolean | Disable file watching (default: `false`) |[OpenAPI Typescript Codegen options](https://github.com/ferdikoomen/openapi-typescript-codegen#usage) are also available.
## License
MIT