1.3.0 • Published 5 months ago

@ts-to-json-schema/core v1.3.0

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

@ts-to-json-schema/core

Core functions for TypeScript to JSON Schema

Installation

npm install @ts-to-json-schema/core
npm install --save-dev typescript @ts-to-json-schema/transform

Obs: Follow the instructions in the @ts-to-json-schema/transform to configure in your bundler.

Configuration

{
  "compilerOptions": {
    "plugins": [
      { "transform": "@ts-to-json-schema/transform", "type": "program" }
    ]
  }
}

Obs: Follow the instructions in the @ts-to-json-schema/transform to configure in your bundler.

Usage

import { toJsonSchema } from "@ts-to-json-schema/core";

interface MyType {
  foo: string;
  bar?: number;
}

const schema = toJsonSchema<MyType>();

console.log(schema);

/*
* Output:
* {
*   type: 'object',
*   properties: {
*     foo: { type: 'string' },
*     bar: { type: 'number' }
*   },
*   required: ['foo']
* }
 */
1.3.0

5 months ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago