I would like to be able to use another object than the schema as a base object. Currently this requires iterating over the entire root object and calling addSchema for each schema found.
For example when using OpenAPI:
import { Validator } from 'jsonschema';
const validator = new Validator();
const api = {
components: {
schemas: {
Foo: {
type: 'object',
properties: {
bar: { $ref: '#/components/schemas/Bar' }
}
},
Bar: {
type: 'object',
properties: {
baz: { type: 'string' }
}
}
}
}
};
validator.validate('123', api.components.schemas.Foo, { baseObj: api });
This example is simplified. In reality JSON schemas may occur in many places inside an OpenAPI document.
I would like to be able to use another object than the schema as a base object. Currently this requires iterating over the entire root object and calling
addSchema
for each schema found.For example when using OpenAPI:
This example is simplified. In reality JSON schemas may occur in many places inside an OpenAPI document.