| 1 | import type Ajv from "../../core" |
| 2 | import type {AnySchemaObject} from "../../types" |
| 3 | import * as metaSchema from "./schema.json" |
| 4 | import * as applicator from "./meta/applicator.json" |
| 5 | import * as unevaluated from "./meta/unevaluated.json" |
| 6 | import * as content from "./meta/content.json" |
| 7 | import * as core from "./meta/core.json" |
| 8 | import * as format from "./meta/format-annotation.json" |
| 9 | import * as metadata from "./meta/meta-data.json" |
| 10 | import * as validation from "./meta/validation.json" |
| 11 | |
| 12 | const META_SUPPORT_DATA = ["/properties"] |
| 13 | |
| 14 | export default function addMetaSchema2020(this: Ajv, $data?: boolean): Ajv { |
| 15 | ;[ |
| 16 | metaSchema, |
| 17 | applicator, |
| 18 | unevaluated, |
| 19 | content, |
| 20 | core, |
| 21 | with$data(this, format), |
| 22 | metadata, |
| 23 | with$data(this, validation), |
| 24 | ].forEach((sch) => this.addMetaSchema(sch, undefined, false)) |
| 25 | return this |
| 26 | |
| 27 | function with$data(ajv: Ajv, sch: AnySchemaObject): AnySchemaObject { |
| 28 | return $data ? ajv.$dataMetaSchema(sch, META_SUPPORT_DATA) : sch |
| 29 | } |
| 30 | } |