Skip to content

Add Diagnostic provider to Schema Validation, improve JSON Pointer handling and add Dialect support#7

Open
srivastava-diya wants to merge 6 commits into
hyperjump-io:mainfrom
srivastava-diya:feature/schema-validation
Open

Add Diagnostic provider to Schema Validation, improve JSON Pointer handling and add Dialect support#7
srivastava-diya wants to merge 6 commits into
hyperjump-io:mainfrom
srivastava-diya:feature/schema-validation

Conversation

@srivastava-diya
Copy link
Copy Markdown
Collaborator

@srivastava-diya srivastava-diya commented Jun 1, 2026

Description

Based on feedback from our call, i have made the following changes

  1. build-server.ts : Added support for all JSON Schema dialects (draft-04 through draft-2020-12).
  2. SchemaValidation.ts : Replaced the instanceLocation.slice(2).split("/") path resolution with findNodeByPointer a helper Fn that uses @hyperjump/json-pointer's pointerSegments to correctly handle escape sequences and array indices.
  3. language-server.test.ts : Added test with property names containing / (escape sequence)

@srivastava-diya srivastava-diya changed the title Add Diagnostic provider to Schema Validation Add Diagnostic provider to Schema Validation, improve JSON Pointer handling and add Dialect support Jun 3, 2026
Copy link
Copy Markdown
Collaborator

@jdesrosiers jdesrosiers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's start organizing our tests. There should be a separate test file for each feature. So, src/features/SchemaValidation.test.ts, src/features/SyntaxValidation.test.ts, etc.

if (pointer === "#") {
return node;
}
const segments = [...pointerSegments(pointer.slice(1))];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember that pointer is a URI and could have URI escaped characters that need to be decoded. pointerSegments will only handle JSON Pointer escaped characters, not URI escaped characters.

return node;
}
const segments = [...pointerSegments(pointer.slice(1))];
const path = segments.map((s) => /^\d+$/.test(s) ? parseInt(s) : s);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't quite right. Consider,

{
  "42": ["foo"]
}

Given the pointer, /42/0, the path should be ["42", 0], not [42, 0]. So, you can't just match anything that looks like an integer and parse it. You have to take the type at that location into account.

So, you won't be able to use fineNodeAtLocation for this. You'll need to walk the AST for each segment and only parse to a number if the current node is an array.

};

const formatError = (error: ErrorObject, depth = 0): string => {
let msg = error.message;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's best to avoid abbreviations.

Suggested change
let msg = error.message;
let message = error.message;

@jdesrosiers
Copy link
Copy Markdown
Collaborator

image

Merging "main" into a feature branch can cause problems. Prefer rebasing feature branches and only merging into "main".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants