Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/parser/jsonParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,12 @@ function validate(n: ASTNode | undefined, schema: JSONSchema, validationResult:
}

let deprecationMessage = schema.deprecationMessage;
if ((deprecationMessage || schema.deprecated) && node.parent) {
if (deprecationMessage || schema.deprecated) {
deprecationMessage = deprecationMessage || l10n.t('Value is deprecated');
let targetNode = node.parent?.type === 'property' ? node.parent : node;

validationResult.problems.push({
location: { offset: node.parent.offset, length: node.parent.length },
location: { offset: targetNode.offset, length: targetNode.length },
severity: DiagnosticSeverity.Warning,
message: deprecationMessage,
code: ErrorCode.Deprecated
Expand Down
10 changes: 10 additions & 0 deletions src/test/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2389,6 +2389,16 @@ suite('JSON Parser', () => {
assert.strictEqual(semanticErrors!.length, 1);
}

schema = {
deprecated: true,
type: 'object'
};
{
const { textDoc, jsonDoc } = toDocument('{"prop": 42}');
const semanticErrors = validate2(jsonDoc, textDoc, schema);
assert.strictEqual(semanticErrors!.length, 1);
}

});

test('Strings with spaces', function () {
Expand Down