feat(json-schema-2020-12): add support for const keyword (#8622)

Refs #8513
This commit is contained in:
Vladimír Gorej
2023-05-07 16:49:23 +02:00
committed by GitHub
parent b4e5af901d
commit 8e4fde5ddd
7 changed files with 69 additions and 1 deletions

View File

@@ -159,6 +159,22 @@ export const isExpandable = (schema) => {
fn.hasKeyword(schema, "propertyNames") ||
fn.hasKeyword(schema, "unevaluatedItems") ||
fn.hasKeyword(schema, "unevaluatedProperties") ||
schema?.description
schema?.description ||
fn.hasKeyword(schema, "const")
)
}
export const stringify = (value) => {
if (
value === null ||
["number", "bigint", "boolean"].includes(typeof value)
) {
return String(value)
}
if (Array.isArray(value)) {
return `[${value.map(stringify).join(", ")}]`
}
return JSON.stringify(value)
}