Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

7nohe/vite-plugin-openapi-typescript-codegen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Feb 24, 2025
c2b64a0 · Feb 24, 2025

History

23 Commits
Jul 14, 2022
Sep 6, 2022
Feb 24, 2025
Jul 14, 2022
Jul 14, 2022
Feb 24, 2025
Feb 24, 2025
Feb 24, 2025
Feb 24, 2025
Jul 14, 2022
Jul 14, 2022

Repository files navigation

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

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 are also available.

License

MIT