How to use the json-schema/lib/validate.getLink function in json-schema

To help you get started, we’ve selected a few json-schema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github persvr / perstore / store / inherited.js View on Github external
/**
 * This store wrapper provides a means for creating a set of stores (from a single store)
 * that can inherit from each other with a superset/subset relation. One can use
 * schemas to indicate the hierarchy (with the "extends" property), and a property
 * is added to the instances to indicate what schema/model each instance belongs to.
 * See tests/inherited.js for an example.   
 */
var getLink = require("json-schema/lib/validate").getLink,
	promise = require("promised-io/promise"),
	subSchemas = {};
exports.Inherited = function(store, schemaProperty){
	// TODO: determine the schemaProperty from the schema's "schema" relation
	schemaProperty = schemaProperty || "__schema__";
	var hierarchy = [];
	var id = promise.defer();
	var inheritingStore = {};
	for(var i in store){
		inheritingStore[i] = store[i];
	}
	var schema;
	var originalSetSchema = store.setSchema;
	inheritingStore.setSchema = function(newSchema){
		schema = newSchema;
		originalSetSchema && originalSetSchema.call(store, schema);