0.2.0 • Published 8 months ago

@7nohe/vite-plugin-openapi-typescript-codegen v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

!IMPORTANT This library has been archived. This library is no longer maintained because OpenAPI Typescript Codegen is no longer maintained.

vite-plugin-openapi-typescript-codegen

OpenAPI Typescript Codegen for Vite

Install

npm install -D @7nohe/vite-plugin-openapi-typescript-codegen

Usage

Add to your vite.config.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

nametypedescribe
inputstringOpenAPI specification file (required)
outputstringOutput directory (default: openapi)
watch.intervalnumberInterval of file watching (default: 1000)
watch.disabledbooleanDisable file watching (default: false)

OpenAPI Typescript Codegen options are also available.

License

MIT