TheLucifurry / vite-plugin-type-to-schema

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vite-plugin-type-to-schema

Plugin that converts types to JSON Schemas just via suffixed import

๐Ÿ’ฟ Installation

pnpm i -D vite-plugin-type-to-schema # (or npm instead of pnpm)
# or
yarn add vite-plugin-type-to-schema --dev

๐Ÿ‘€ Usage

// vite.config.js
import typeToSchema from 'vite-plugin-type-to-schema';
import { defineConfig } from 'vite';

export default defineConfig({
  plugins: [typeToSchema()]
});

โš™๏ธ Options

Source

name(optionality): defaultValue // Description

typeToSchema({
  suffix?: '?schema' // Import path suffix
  dts?: 'schemas.d.ts' // Disable (false), or change path (string) of dts file 
  options?: {} // https://github.com/vega/ts-json-schema-generator#options
})

๐Ÿ“ƒ Details

See this test and fixture to learn behaviour of schema compiling

About

License:MIT License


Languages

Language:TypeScript 100.0%