jsg07

1.0.4 • Public • Published

JSON Schema Generator

Build Status Coverage Status

Spec: http://json-schema.org/latest/json-schema-validation.html

Install

npm install --save jsg07

Usage

const jsg = require('jsg07');
 
let schema = jsg.infer({
    name: 'Mike',
    male: true,
    tags: ['Gentle', 'Nice']
});
console.log(JSON.stringify(schema, null, 4));

Output

{
    "title": "An object value",
    "required": [
        "name",
        "male",
        "tags"
    ],
    "properties": {
        "name": {
            "title": "A string value",
            "default": "",
            "pattern": "^(.*)$",
            "examples": [
                "Mike"
            ],
            "$id": "#/properties/name",
            "type": "string"
        },
        "male": {
            "title": "A boolean value",
            "default": false,
            "examples": [
                true
            ],
            "$id": "#/properties/male",
            "type": "boolean"
        },
        "tags": {
            "title": "An array of items",
            "items": {
                "title": "A string value",
                "default": "",
                "pattern": "^(.*)$",
                "examples": [
                    "Gentle"
                ],
                "$id": "#/properties/tags/items",
                "type": "string"
            },
            "$id": "#/properties/tags",
            "type": "array"
        }
    },
    "$id": "http://example.org/root.json#",
    "type": "object",
    "definitions": {},
    "$schema": "http://json-schema.org/draft-07/schema#"
}

Readme

Keywords

none

Package Sidebar

Install

npm i jsg07

Weekly Downloads

1

Version

1.0.4

License

MIT

Unpacked Size

30.3 kB

Total Files

10

Last publish

Collaborators

  • harttle