# vite-plugin-type-to-schema

> > Plugin that converts types to JSON Schemas just via suffixed import

Latest version **0.0.2** (published 2023-03-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install vite-plugin-type-to-schema
pnpm add vite-plugin-type-to-schema
yarn add vite-plugin-type-to-schema
bun add vite-plugin-type-to-schema
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2023-03-27 |
| First published | 2022-09-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Lucifurry |
| Maintainers | lucifurry |
| Keywords | vite, vite-plugin, type-to-schema, vite-plugin-type-to-schema, ts-json-schema-generator, ts-to-json-schema |

## Links

- npm: https://www.npmjs.com/package/vite-plugin-type-to-schema
- Repository: https://github.com/TheLucifurry/vite-plugin-type-to-schema
- Homepage: https://github.com/TheLucifurry/vite-plugin-type-to-schema#readme
- Issues: https://github.com/TheLucifurry/vite-plugin-type-to-schema/issues
- npm.io page: https://npm.io/package/vite-plugin-type-to-schema

## Dependencies (1)

- [ts-json-schema-generator](https://npm.io/package/ts-json-schema-generator.md) ^1.2.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.0.2 (latest) — 2023-03-27
- 0.0.1 — 2022-09-24

## README

# 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
```js
// vite.config.js
import typeToSchema from 'vite-plugin-type-to-schema';
import { defineConfig } from 'vite';

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

## ⚙️ Options 
[Source](./src/types.ts#L12)
#### name(optionality): defaultValue // Description
```js
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](./tests/compile.test.ts) and [fixture](./tests/fixtures/richType.ts) to learn behaviour of schema compiling

---
_Source: https://npm.io/package/vite-plugin-type-to-schema · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
