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); } } } diff --git a/src/test/schema.test.ts b/src/test/schema.test.ts index e34950c4..de4a001e 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');