python-jsonschema / python-jsonschema/jsonschema-lexer
Edge cases and Gotchas
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1
- Forks
- 1
- Avg merge
- 9h 47m
- Merged PRs (30d)
- 2
Description
Here are a few things to look out for when implementing something like this.
The set of properties that are considered keywords depends on the dialect
In the following example, additionalItems should not be highlighted as a keyword because it was removed in 2020-12.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [true],
"additionalItems": false, // <- not a keyword
"items": false,
"definitions": {} // <- not a keyword
"aaa": 42 // <- not a keyword
}
When we change the dialect, the properties that are considered keywords changes.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"prefixItems": [true], // <- not a keyword
"additionalItems": false,
"items": false
"definitions": {}
"aaa": 42 // <- not a keyword
}
Properties are only keywords inside schemas
Not every object in a JSON Schema document is a schema, so you need to know when you're in a schema and when you're not. Here are a couple examples.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"$id": "foo" // <- not a keyword
}
}
In the next example, $id isn't considered a keyword because definitions isn't a keyword in 2020-12. Therefore, their values aren't schemas and the properties of those values shouldn't be considered keywords.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"definitions": {
"foo": {
"type": "string" // <- not a keyword
}
}
}
Embedded schemas can have a different dialect
It's possible for embedded schemas to have a different dialect than their parent schema. In the following example, the same keywords are highlighted differently depending on which schema resource the keyword appears in.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [true],
"additionalItems": false, // <- not a keyword
"items": false,
"$defs": {
"foo": {
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://example.com/schema/embedded",
"prefixItems": [true], // <- not a keyword
"additionalItems": false,
"items": false,
"definitions": {}
}
}
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files, tests, or entry points are named. Start by reviewing the repository and the JSON Schema examples in this issue, then identify how dialect changes, schema context, and embedded dialects should affect highlighting; done means these cases have defined and verified behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100