JSPM

json-schema-from-path

2.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 267
  • Score
    100M100P100Q88198F
  • License MIT

A utility to get the sub-schema from a JSON-schema from the path in an object

Package Exports

  • json-schema-from-path

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (json-schema-from-path) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

json-schema-from-path

A utility to get the sub-schema from a JSON-schema from the path in an object

Supports schemas that use:

  • properties (type object)
  • additionalProperties (type object)
  • patternProperties (type object)
  • items (type array)
  • paths that use either / or . as separators
var getSchemaFromPath = require("json-schema-from-path");

var someSchema = {
    properties: {
        foo: {
            properties: {
                bar: {
                    type: "string"
                }
            }
        }
    }
};

var mypath = "foo/bar";

var theSchema = getSchemaFromPath(someSchema, path);

theSchema === someSchema.properties.foo.properties.bar

If a schema object doesn't exist for the given path, null is returned.