Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
get(pointer, data) {
if (data) {
const result = jsl.getSchema(this.core, pointer, data, this.schema);
return copy(result);
}
if (this.cache[pointer] === undefined) {
const result = jsl.getSchema(this.core, pointer, this.data, this.schema);
if (result.variableSchema === true) {
// @special case: do not cache dynamic schema object (oneOf)
return result;
}
this.cache[pointer] = copy(result);
}
return this.cache[pointer];
}
get(pointer, data) {
if (data) {
const result = jsl.getSchema(this.core, pointer, data, this.schema);
return copy(result);
}
if (this.cache[pointer] === undefined) {
const result = jsl.getSchema(this.core, pointer, this.data, this.schema);
if (result.variableSchema === true) {
// @special case: do not cache dynamic schema object (oneOf)
return result;
}
this.cache[pointer] = copy(result);
}
return this.cache[pointer];
}
function extendSchema(rootSchema) {
rootSchema = JSON.parse(JSON.stringify(rootSchema));
eachSchema(rootSchema, childSchema => {
childSchema[UI_PROPERTY] = childSchema[UI_PROPERTY] || {};
childSchema[UI_PROPERTY] = Object.assign({
hidden: false,
title: childSchema.title || "",
description: childSchema.description || ""
}, childSchema.options, childSchema[UI_PROPERTY]); // @legacy options
});
return rootSchema;
}
setup: function (schema) {
return new jlib.cores.Draft04(schema);
},
test: function (instance, json, schema) {
const Core = require("json-schema-library").cores.JsonEditor;
const copy = require("./utils/copy");
const jsl = require("json-schema-library");
const getChildSchemaSelection = require("json-schema-library").getChildSchemaSelection;
/**
* Manages json-schema interactions and adds caching of reoccuring json-schema requests
*
* @param {Object} schema - json-schema
* @param {Object} [data={}] - data corresponding to json-schema
* @param {Core} [core={}] - instance of json-schema-library Core
*/
class SchemaService {
constructor(schema = {}, data = {}, core = new Core()) {
this.core = core;
const gp = require("gson-pointer");
const Core = require("json-schema-library").cores.JsonEditor;
const addValidator = require("json-schema-library/lib/addValidator");
const DataService = require("./services/DataService");
const SchemaService = require("./services/SchemaService");
const ValidationService = require("./services/ValidationService");
const LocationService = require("./services/LocationService");
const State = require("./services/State");
const selectEditor = require("./utils/selectEditor");
const _createElement = require("./utils/createElement");
const addItem = require("./utils/addItem");
const UISchema = require("./utils/UISchema");
const getID = require("./utils/getID");
const plugin = require("./plugin");
const i18n = require("./utils/i18n");
function isValidPointer(pointer) {
const mitt = require("mitt");
const Core = require("json-schema-library").cores.JsonEditor;
const State = require("./State");
const ActionCreators = require("./reducers/actions").ActionCreators;
const errorReducer = require("./reducers/errorReducer");
const Validation = require("./utils/Validation");
const BubblingCollectionObservable = require("./utils/BubblingCollectionObservable");
const EVENTS = {
BEFORE_VALIDATION: "beforeValidation",
AFTER_VALIDATION: "afterValidation",
ON_ERROR: "onError"
};
/**
* @class ValidationService
addFormatValidator(format, validator) {
addValidator.format(this.core, format, validator);
}
addKeywordValidator(datatype, keyword, validator) {
addValidator.keyword(this.core, datatype, keyword, validator);
}
Object.keys(refs).forEach(function (uri) {
ajv.addSchema(refs[uri], uri);
djv.addSchema(uri, refs[uri]);
jlib.addSchema(uri, refs[uri]);
});