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

Method removeSchema

lib/core.ts:548–581  ·  view source on GitHub ↗
(schemaKeyRef?: AnySchema | string | RegExp)

Source from the content-addressed store, hash-verified

546 // If RegExp is passed all schemas with key/id matching pattern but meta-schemas are removed.
547 // Even if schema is referenced by other schemas it still can be removed as other schemas have local references.
548 removeSchema(schemaKeyRef?: AnySchema | string | RegExp): Ajv {
549 if (schemaKeyRef instanceof RegExp) {
550 this._removeAllSchemas(this.schemas, schemaKeyRef)
551 this._removeAllSchemas(this.refs, schemaKeyRef)
552 return this
553 }
554 switch (typeof schemaKeyRef) {
555 case "undefined":
556 this._removeAllSchemas(this.schemas)
557 this._removeAllSchemas(this.refs)
558 this._cache.clear()
559 return this
560 case "string": {
561 const sch = getSchEnv.call(this, schemaKeyRef)
562 if (typeof sch == "object") this._cache.delete(sch.schema)
563 delete this.schemas[schemaKeyRef]
564 delete this.refs[schemaKeyRef]
565 return this
566 }
567 case "object": {
568 const cacheKey = schemaKeyRef
569 this._cache.delete(cacheKey)
570 let id = schemaKeyRef[this.opts.schemaId]
571 if (id) {
572 id = normalizeId(id)
573 delete this.schemas[id]
574 delete this.refs[id]
575 }
576 return this
577 }
578 default:
579 throw new Error("ajv.removeSchema: invalid parameter")
580 }
581 }
582
583 // add "vocabulary" - a collection of keywords
584 addVocabulary(definitions: Vocabulary): Ajv {

Callers 2

ajv.spec.tsFile · 0.80
keyword.spec.tsFile · 0.80

Calls 2

_removeAllSchemasMethod · 0.95
normalizeIdFunction · 0.90

Tested by

no test coverage detected