1.2.6 • Published 3 months ago

json-schema-it v1.2.6

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

json-schema-it

NPM

NPM version build codecov

JSON Schema generator.

Quick Start

import { generateSchema } from 'json-schema-it';

generateSchema(42); // { type: 'integer' }

Installation

NPM:

npm install json-schema-it

Yarn:

yarn add json-schema-it

Usage

ES Modules:

import { generateSchema } from 'json-schema-it';

CommonJS:

const { generateSchema } = require('json-schema-it');

Generate JSON Schema:

generateSchema({
  productId: 1,
  productName: 'A green door',
  price: 12.5,
  tags: ['home', 'green'],
});

Output:

{
  type: 'object',
  properties: {
    productId: { type: 'integer' },
    productName: { type: 'string' },
    price: { type: 'number' },
    tags: { type: 'array', items: { type: 'string' } },
  },
}

An error will be thrown for an invalid JSON value:

generateSchema(undefined); // Uncaught TypeError: Invalid JSON value: undefined

Release

Release is automated with Release Please.

License

MIT

1.2.6

3 months ago

1.2.5

4 months ago

1.2.4

5 months ago

1.2.3

6 months ago

1.2.2

7 months ago

1.2.1

7 months ago

1.2.0

9 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago