loadSchema(uri) {
        let url = uri;
        // resolve any URIs that don't already have a protocol scheme
        if (!uriHasProtocol(url)) {
            url = this.resolveSchemaUri(uri);
            this.log.debug(`Resolved schema uri ${uri} to ${url}.`);
        }
        this.log.info(`Loading schema at ${url}`);
        return urlGetObject(url)
        .then((schema) => {
            this.log.debug({ schema }, `Loaded schema at ${url}`);

            // Assume that all schemas hosted at json-schema.org are meta schemas.
            // This allows us to support automatically adding JSONSchema meta schemas
            // (schemas for schemas) and avoid infinite loadSchema recursion.
            // Since meta schemas usually referencet themselves with $schema,
            // loading meta schema that AJV was not yet initialized yet
            // can cause infinite recursion.
            // We shouldn't need to check if this url has already been added
            // as a metaschema, as loadSchema shouldn't be called if it was.
            if (this.metaSchemaUriRegex && url.match(this.metaSchemaUriRegex)) {
                this.log.debug(`Adding schema at ${url} as meta schema.`);
                this.ajv.addMetaSchema(schema, url);
            }

            return schema;
        });
    }
/**
     * This function is used as the ajv loadSchema option.  It is
     * also used by validatorFor to load a schema
     * from an event's configured schema_uri_field (default '$schema').
     *
     * We need to be able to handle both relative event schema URIs
     * (which should be prepended with the schema_base_uri), as well
     * as absolute meta $schema URLs, e.g. http://json-schema.org/draft-07/schema#.
     * To do this, only URIs without protocol schemes will be passed
     * through this.resolveSchemaUri() before attempting to download the content.
     * loadSchema will then return a Promise of the schema content at the URL.
     *
     * A note about $refs: If a $ref is not an absolute URL or an aboslute path
     * (starting with /), it will be passed to this function by ajv relative
     * to the enclosing schema's $id field. See: https://ajv.js.org/#ref.
     * E.g. if the enclosing schema has $id: /mediawiki/revision/create/0.0.3
     * a $ref of meta/0.0.2 will be given to this function as
     * mediawiki/revision/create/meta/0.0.2, which is likely wrong.
     * However, if the $ref is /meta/0.0.2, it will be passed as is.
     * We need to make sure that any event schema URIs that are not
     * absolute URLs (i.e. with a protocol scheme) including
     * ones used in $ref start with '/'. That will allow us to resolve
     * both $refs (given by AJV) and event schema URIs using the provided
     * this.resolveSchemaUri function.
     * @param {string} uri
     * @return {Promise<Object>}
     */
This function is used as the ajv loadSchema option.  It is
also used by validatorFor to load a schema
from an event's configured schema_uri_field (default '$schema').

We need to be able to handle both relative event schema URIs
(which should be prepended with the schema_base_uri), as well
as absolute meta $schema URLs, e.g.

A note about $refs: If a $ref is not an absolute URL or an aboslute path
(starting with /), it will be passed to this function by ajv relative
to the enclosing schema's $id field.
This function is used as the ajv loadSchema option . It is also used by validatorFor to load a schema from an event ' s configured schema_uri_field ( default ' $schema ' ) . We need to be able to handle both relative event schema URIs ( which should be prepended with the schema_base_uri ) as well as absolute meta $schema URLs e . g . A note about $refs : If a $ref is not an absolute URL or an aboslute path ( starting with / ) it will be passed to this function by ajv relative to the enclosing schema ' s $id field .
loadSchema(uri) {
        let url = uri;
        if (!uriHasProtocol(url)) {
            url = this.resolveSchemaUri(uri);
            this.log.debug(`Resolved schema uri ${uri} to ${url}.`);
        }
        this.log.info(`Loading schema at ${url}`);
        return urlGetObject(url)
        .then((schema) => {
            this.log.debug({ schema }, `Loaded schema at ${url}`);
            if (this.metaSchemaUriRegex && url.match(this.metaSchemaUriRegex)) {
                this.log.debug(`Adding schema at ${url} as meta schema.`);
                this.ajv.addMetaSchema(schema, url);
            }
            return schema;
        });
    }
loadSchema ( uri ) { let url = uri ; if ( ! uriHasProtocol ( url ) ) { url = this . resolveSchemaUri ( uri ) ; this . log . debug ( ` ${ uri } ${ url } ` ) ; } this . log . info ( ` ${ url } ` ) ; return urlGetObject ( url ) . then ( ( schema ) => { this . log . debug ( { schema } , ` ${ url } ` ) ; if ( this . metaSchemaUriRegex && url . match ( this . metaSchemaUriRegex ) ) { this . log . debug ( ` ${ url } ` ) ; this . ajv . addMetaSchema ( schema , url ) ; } return schema ; } ) ; }
This function is used as the ajv loadSchema option.
This function is used as the ajv loadSchema option .
// resolve any URIs that don't already have a protocol scheme // Assume that all schemas hosted at json-schema.org are meta schemas. // This allows us to support automatically adding JSONSchema meta schemas // (schemas for schemas) and avoid infinite loadSchema recursion. // Since meta schemas usually referencet themselves with $schema, // loading meta schema that AJV was not yet initialized yet // can cause infinite recursion. // We shouldn't need to check if this url has already been added // as a metaschema, as loadSchema shouldn't be called if it was.