/** * @license * Copyright 2024 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import type { JSONSchema4 } from "json-schema"; export type JsonSubSchemaAnalysis = { isSubSchema: true; details?: never; } | { isSubSchema: false; details: JsonSubSchemaAnalysisDetail[]; }; export interface JsonSubSchemaAnalysisDetail { pathA: Array; pathB: Array; } interface Context { pathA: Array; pathB: Array; details: JsonSubSchemaAnalysisDetail[]; } /** * Given the JSON Schemas `a` and `b`, determine whether `a` is a sub-schema of * `b`, and if not explain why. * * We say that `a` is a sub-schema of `b` if every JSON Schema constraint in `b` * is also present in `a` at an equal or higher strictness. Examples: * * - If `b` enforces type `string OR number`, then `a` must enforce either * `string`, `number`, or `string OR number`. * - If `b` enforces `maxLength` 4, then `a` must enforce `maxLength <= 4` . * * Note that the following JSON Schema features are NOT yet implemented by this * function: * * - ~~$ref~~ * - ~~allOf / oneOf / not~~ * - ~~const~~ * - ~~contains~~ * - ~~contentEncoding / contentMediaType~~ * - ~~dependentRequired / dependentSchemas / dependencies~~ * - ~~exclusiveMinimum / exclusiveMaximum~~ * - ~~if / then / else~~ * - ~~minContains / maxContains~~ * - ~~minItems / maxItems~~ * - ~~minProperties / maxProperties~~ * - ~~multipleOf~~ * - ~~prefixItems / uniqueItems / unevaluatedItems~~ * - ~~propertyNames / patternProperties / unevaluatedProperties~~ * - ~~tuple~~ * * @param a The JSON Schema that is potentially a subset of `b`. * @param b The JSON Schema that is potentially a superset of `a`. * * @returns A {@link JsonSubSchemaAnalysis} object. Use the * {@link JsonSubSchemaAnalysis.isSubSchema} property to check whether `a` is a * subschema of `b`. When {@link JsonSubSchemaAnalysis.isSubSchema} is `false`, * use the {@link JsonSubSchemaAnalysis.details} property to get a detailed * explanation of why `a` is not a subschema of `b`. */ export declare function analyzeIsJsonSubSchema(a: JSONSchema4, b: JSONSchema4, context?: Context): JsonSubSchemaAnalysis; export {}; //# sourceMappingURL=subschema.d.ts.map