From 0ef2f37d157a51e509e3635f0e602dbd10e0f904 Mon Sep 17 00:00:00 2001 From: "g. nicholas d'andrea" Date: Tue, 4 Feb 2025 01:10:15 -0500 Subject: [PATCH] Parse schema YAML using anchor merges from 1.1 --- packages/format/src/describe.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/format/src/describe.ts b/packages/format/src/describe.ts index f5d1a0acf..f12eb3260 100644 --- a/packages/format/src/describe.ts +++ b/packages/format/src/describe.ts @@ -21,6 +21,11 @@ export interface SchemaInfo { rootSchema: JSONSchema; } +const parseOptions = { + // merge keys were removed from YAML 1.2 spec but used by these schemas + merge: true +}; + export function describeSchema({ schema, pointer @@ -55,8 +60,8 @@ function describeSchemaById({ const yaml = pointToYaml(rootYaml, pointer); - const schema = YAML.parse(yaml); - const rootSchema = YAML.parse(rootYaml); + const schema = YAML.parse(yaml, parseOptions); + const rootSchema = YAML.parse(rootYaml, parseOptions); return { id, @@ -73,8 +78,8 @@ function describeSchemaByYaml({ }: DescribeSchemaOptions): SchemaInfo { const yaml = pointToYaml(referencedYaml, pointer); - const schema = YAML.parse(yaml); - const rootSchema = YAML.parse(referencedYaml); + const schema = YAML.parse(yaml, parseOptions); + const rootSchema = YAML.parse(referencedYaml, parseOptions); const id = schema.$id; @@ -104,7 +109,7 @@ function describeSchemaByObject({ const yaml = pointToYaml(rootYaml, pointer); - const schema = YAML.parse(yaml); + const schema = YAML.parse(yaml, parseOptions); const id = schema.$id;