@doubter/json-schema
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

Doubter × JSON Schema

Converts Doubter shapes from and to JSON schemas.

[!WARNING]
This project is at the early development stage.

npm install --save-prod @doubter/json-schema

Define a shape:

import * as d from 'doubter';
import { toJSONSchema } from '@doubter/json-schema';

const shape = d.object({
  name: d.string(),
  age: d.number().gt(10).optional()
});
// ⮕ Shape<{ name: string, age?: number | undefined }>

const schema = toJSONSchema(shape);

The schema is a JSON schema object:

{
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "age": {
      "type": "number",
      "exclusiveMinimum": 10
    }
  },
  "required": ["name"]
}

Readme

Keywords

Package Sidebar

Install

npm i @doubter/json-schema

Weekly Downloads

3

Version

0.0.5

License

MIT

Unpacked Size

44.9 kB

Total Files

10

Last publish

Collaborators

  • smikhalevski