Skip to content
Build a JSON Schema with functions
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
__tests__
lib
.gitignore
.npmignore
CHANGELOG.md
LICENSE
README.md
index.ts
package.json
tsconfig.json
yarn.lock

README.md

functional-json-schema

Build a JSON Schema with functions

target API for 1.0

import * as schema from 'functional-json-schema';

const JSONschema = schema.schema({
    person: {
        friends: schema.types.arrayOf(schema.types.definition('user')),
        id: 'string*',
        friend_ids: schema.types.arrayOf(schema.types.definition('User'), { required: true }),
    }
}, null, { schema: 'http://json-schema.org/draft-06/schema#' })

/*

=> {
  $schema: 'http://json-schema.org/draft-06/schema#',
  type: 'object',
  properties: {
    person: {
      type: 'object',
      properties: {
        friends: {
          "type": "array",
          "items": {
              "$ref": "#/definitions/User"
          }
        },
        (...)
      },
      required: ['friends', 'id']
    }
  }
}
*/
You can’t perform that action at this time.