Skip to content

Commit

Permalink
Fixed merge key error
Browse files Browse the repository at this point in the history
  • Loading branch information
JPinkney committed Jan 21, 2020
1 parent 76e1472 commit 4e09e0e
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/languageservice/parser/jsonParser07.ts
Original file line number Diff line number Diff line change
Expand Up @@ -837,8 +837,37 @@ function validate(node: ASTNode, schema: JSONSchema, validationResult: Validatio
const unprocessedProperties: string[] = [];
for (const propertyNode of node.properties) {
const key = propertyNode.keyNode.value;
seenKeys[key] = propertyNode.valueNode;
unprocessedProperties.push(key);

//Replace the merge key with the actual values of what the node value points to in seen keys
if (key === '<<' && propertyNode.valueNode) {

switch (propertyNode.valueNode.type) {
case 'object': {
propertyNode.valueNode['properties'].forEach(propASTNode => {
const propKey = propASTNode.keyNode.value;
seenKeys[propKey] = propASTNode.valueNode;
unprocessedProperties.push(propKey);
});
break;
}
case 'array': {
propertyNode.valueNode['items'].forEach(sequenceNode => {
sequenceNode['properties'].forEach(propASTNode => {
const seqKey = propASTNode.keyNode.value;
seenKeys[seqKey] = propASTNode.valueNode;
unprocessedProperties.push(seqKey);
});
});
break;
}
default: {
break;
}
}
} else {
seenKeys[key] = propertyNode.valueNode;
unprocessedProperties.push(key);
}
}

if (Array.isArray(schema.required)) {
Expand Down

0 comments on commit 4e09e0e

Please sign in to comment.