MCPcopy
hub / github.com/ajv-validator/ajv / getSchema

Method getSchema

lib/core.ts:531–542  ·  view source on GitHub ↗
(keyRef: string)

Source from the content-addressed store, hash-verified

529 // Get compiled schema by `key` or `ref`.
530 // (`key` that was passed to `addSchema` or full schema reference - `schema.$id` or resolved id)
531 getSchema<T = unknown>(keyRef: string): AnyValidateFunction<T> | undefined {
532 let sch
533 while (typeof (sch = getSchEnv.call(this, keyRef)) == "string") keyRef = sch
534 if (sch === undefined) {
535 const {schemaId} = this.opts
536 const root = new SchemaEnv({schema: {}, schemaId})
537 sch = resolveSchema.call(this, root, keyRef)
538 if (!sch) return
539 this.refs[keyRef] = sch
540 }
541 return (sch.validate || this._compileSchemaEnv(sch)) as AnyValidateFunction<T> | undefined
542 }
543
544 // Remove cached schema(s).
545 // If no parameter is passed all schemas but meta-schemas are removed.

Callers 15

defaultMetaMethod · 0.95
defaultMetaMethod · 0.95
validateMethod · 0.95
loadMetaSchemaMethod · 0.95
defaultMetaMethod · 0.45
defaultMetaMethod · 0.45
resolve.spec.tsFile · 0.45
testSchemasFunction · 0.45
ajv.spec.tsFile · 0.45
macroFunction · 0.45
testOptionMetaFunction · 0.45

Calls 1

_compileSchemaEnvMethod · 0.95

Tested by 4

testSchemasFunction · 0.36
macroFunction · 0.36
testOptionMetaFunction · 0.36
testFunction · 0.36