From 2aef107a7a639bd2014a0556688ea0f73e836743 Mon Sep 17 00:00:00 2001 From: marcopiii Date: Mon, 23 Jun 2025 19:21:20 +0200 Subject: [PATCH 1/2] feat: make getMatchingSchemas return keys matching propertyNames schema --- src/parser/jsonParser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parser/jsonParser.ts b/src/parser/jsonParser.ts index 14fd3876..fbe252ef 100644 --- a/src/parser/jsonParser.ts +++ b/src/parser/jsonParser.ts @@ -1095,7 +1095,7 @@ function validate(n: ASTNode | undefined, schema: JSONSchema, validationResult: for (const f of node.properties) { const key = f.keyNode; if (key) { - validate(key, propertyNames, validationResult, NoOpSchemaCollector.instance, context); + validate(key, propertyNames, validationResult, matchingSchemas, context); } } } From 9da411f10e696692cfae59708426fa5569295f4e Mon Sep 17 00:00:00 2001 From: marcopiii Date: Fri, 3 Oct 2025 10:57:24 +0200 Subject: [PATCH 2/2] test: add test for schema matching on propertyNames --- src/test/schema.test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/test/schema.test.ts b/src/test/schema.test.ts index e4b4492f..06166d1a 100644 --- a/src/test/schema.test.ts +++ b/src/test/schema.test.ts @@ -1790,6 +1790,10 @@ suite('JSON Schema', () => { baz: { type: 'boolean', $comment: 'baz', + }, + key: { + type: 'string', + $comment: 'key', } }, properties: { @@ -1806,6 +1810,9 @@ suite('JSON Schema', () => { } } } + }, + propertyNames: { + $ref: "#/definitions/key" } }; @@ -1824,6 +1831,7 @@ suite('JSON Schema', () => { assert.fail("No node at offset " + nodeOffset); } assertMatchingSchema(ms, 0, 'schema'); + assertMatchingSchema(ms, 1, 'key'); assertMatchingSchema(ms, 7, 'foo'); assertMatchingSchema(ms, 14, 'bar'); assertMatchingSchema(ms, 22, 'baz');