-
Notifications
You must be signed in to change notification settings - Fork 29.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[json] Support json-schema draft 2020-12 #165219
Comments
Looking at the content of the schema, most schema rules are extracted into different files listed in "$vocabulary", which we unfortunately don't understand. |
Happy to answer any questions... |
This would be extremely useful to have for schema authors. It doesn't affect users of schemas as much, but it's very impactful for schema authors. If you're defining a new schema or meta-schema it's frustrating and, more importantly, error-prone to lose validation and IntelliSense when you move into any object-value keyword from the top-level. The support that 2020-12 lays down for defining schema dialects is wildly useful for schema authors, but hand-crafting those definitions in VS Code means constantly moving from the editor to a CLI tool to validate the schema. Nearly all of the author-time development experience is lost. An example of a useful schema dialect is actually for defining a schema that uses VS Code's own annotation keywords: {
// Spec keywords
// VSCode extensions
defaultSnippets?: { label?: string; description?: string; markdownDescription?: string; body?: any; bodyText?: string; }[]; // VSCode extension: body: a object that will be converted to a JSON string. bodyText: text with \t and \n
errorMessage?: string; // VSCode extension
patternErrorMessage?: string; // VSCode extension
deprecationMessage?: string; // VSCode extension
enumDescriptions?: string[]; // VSCode extension
markdownEnumDescriptions?: string[]; // VSCode extension
markdownDescription?: string; // VSCode extension
doNotSuggest?: boolean; // VSCode extension
suggestSortText?: string; // VSCode extension
allowComments?: boolean; // VSCode extension
allowTrailingCommas?: boolean; // VSCode extension
} Having schema dialects for people authoring a schema who want to have the best possible UX for folks filling out a document adhering to that schema would be great. I work on a lot of side projects that involve writing schemas for configuration files and documenting configurations. While I could pin those schemas to using draft 7, it's more maintainable for me to use 2020-12, especially when you consider annotations like versioning information or the link to online docs: {
"title": "Cache Busters",
"description": "Defines a list of sources and targets to re-process assets for supporting Tailwind's JIT compiler.",
"markdownDescription": "...", // longer block with pretty-rendering info
"minimumVersion": "0.112.0",
"docsUrl": "https://gohugo.io/getting-started/configuration/#configure-cache-busters",
"type": "array",
"uniqueItems": true,
"items": {
// definition for a cache buster
}
} I don't think I'd be very helpful for implementing 2020-12 support, but I'd be happy to test things out and to help with the documentation. VS Code's support for using JSON schemas is wildly good. Being able to get IntelliSense, high-quality validation error messages, and contextual documentation makes filling out schematized documents in VS Code so much easier than keeping the reference to the schema open and re-running a validator every few minutes. I'd love to see VS Code's support for authoring schemas match that experience, and 2020-12 support, which makes authoring new vocabulary so much easier, is a huge part of that. |
@michaeltlombardi thanks for adding in your use case. It's very enlightening. Regarding custom dilect support, it's important to remember that any implementation (whether its a validator or an editor or something else) can only support vocabularies that it's been programmed to understand. There's nothing yet defined that provides a machine-readable format that allows implementations to automatically understand new vocabularies. That said, we (the JSON Schema team) are working on defining that. Until then |
@gregsdennis yup! For right now, I've only been defining/using annotation keywords, even though I keep finding useful ideas for other keywords. |
Is it still the case today? The site has the section on bundling schemas, which relies on different |
Type: Bug
When using json-schema draft 2020-12 in VS Code the code completion no longer works anywhere except for the root level of the json object.
Steps to reproduce:
Expected behaviour:
The code completion should work everywhere in the document.
Screenshots:
System information:
VS Code version: Code 1.72.2 (d045a5e, 2022-10-12T22:15:18.074Z)
OS version: Windows_NT x64 10.0.19044
Modes:
Sandboxed: No
System Info
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Extensions (15)
A/B Experiments
The text was updated successfully, but these errors were encountered: