support for jsonValidationCatalogs - #327104
Conversation
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Raymond Zhao (@rzhao271)Matched files:
|
There was a problem hiding this comment.
Pull request overview
Adds extension-contributed, dynamically watched JSON validation catalogs.
Changes:
- Registers and types
jsonValidationCatalogs. - Loads and watches catalog resources in the JSON language client.
- Converts built-in schema associations to the catalog format.
Show a summary per file
| File | Description |
|---|---|
extensionPoints.json |
Registers the contribution point. |
extensionManifestPropertiesService.ts |
Allows it in Sessions. |
settingsFilesystemProvider.ts |
Emits catalog-formatted associations. |
jsonValidationExtensionPoint.ts |
Defines and validates contributions. |
extensions.ts |
Adds manifest typings. |
package.json |
Contributes the built-in catalog. |
jsonClient.ts |
Loads, watches, and forwards catalogs. |
Review details
Comments suppressed due to low confidence (1)
extensions/json-language-features/client/src/jsonClient.ts:857
- A catalog is runtime JSON, so
schemascan containnull. Accessingschema.urlthen throws into the outer catch and skips every valid association that follows it in this catalog. Use a null-safe item check so malformed entries are ignored individually as intended.
if (typeof schema.url === 'string' && Array.isArray(schema.fileMatch) && schema.fileMatch.every(fileMatch => typeof fileMatch === 'string')) {
- Files reviewed: 7/7 changed files
- Comments generated: 3
- Review effort level: Medium
| const refresh = async () => { | ||
| client.sendNotification(SchemaAssociationNotification.type, await getSchemaAssociations(true)); | ||
| }; |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| } | ||
|
|
||
| async function getDynamicSchemaAssociations(): Promise<ISchemaAssociation[]> { | ||
| function getSchemaCatalogUris(): Uri[] { |
There was a problem hiding this comment.
How is the catalog set to the https://www.schemastore.org/api/json/catalog.json default value? I'm not seeing this anywhere.
There was a problem hiding this comment.
In the current form it's not for loading directly 'https://www.schemastore.org/api/json/catalog.json', but for extensions to dynamically provide associations. The URI that an extension can pass is either a static resource that is part of the extension, or a dynamic URI from a virtual file system that is set up by the extension.
An extension could use it to feed associations from https://www.schemastore.org/api/json/catalog.json, via such a file system dapter.
We can extend this to also allow loading from URI, but we want users to have control over which associations are used. So I would not suggest to use this contribution point directly on the http URI.
There was a problem hiding this comment.
so any user would still need to install an additional extension that'd get the schema store catalog and feed it to the JSON language extension with this design? (assuming such an extension ever gets built)
While I understand the "taking a dependency on a 3rd party service in a first party extension" concern, I'm questioning the parity aspect with the YAML extension. This extension supports the schema store natively (no additional extension/configuration required from the user). Are you planning to implement the schema store extension as a first party one?
Also, with this approach, would the user still have to manually map the file to schema association in the settings, even though the "partner extension" already provided all the associations? Or would that be automatic?
There was a problem hiding this comment.
this PR is not directly related to adding support from reading https://www.schemastore.org/api/json/catalog.json. The contribution point name catalog is misguiding.
It's been a longstanding request that extension can dynamically contribute schema associations: #96120
You could add support for loading 'https://www.schemastore.org/api/json/catalog.json'' via that contribution point (from a built-in or from an external extension), but you can also directly add it in code at the same place where then new extension point is read.
There was a problem hiding this comment.
If I understand correctly this last comment, you wouldn't be opposed to having the "load from json schema catalog to the contribution point" also implemented in the first party extension?
There was a problem hiding this comment.
Martin Aeschlimann (@aeschli) I can see your thumb up, so should I essentially rebase and cleanup my other PR onto this one? Or are you planning to fast follow yourself?
There was a problem hiding this comment.
I had copilot put this together #327297
One thing I'm not sure about is the new entry under the one you added for the contribution. In this case where this is internal, would you expect a new entry here? or the extension to publish to its own subscription?
There was a problem hiding this comment.
I suggest to start fresh once this PR has been merged. Please aim for a minimal PR.
| debuggers?: IDebugger[]; | ||
| grammars?: IGrammar[]; | ||
| jsonValidation?: IJSONValidation[]; | ||
| jsonValidationCatalogs?: IJSONValidationCatalog[]; |
There was a problem hiding this comment.
Is "catalog" a standard term for a collection of json validators? It's not a term we use elsewhere.
|
TylerLeonhardt FYI, I'll add you to the codeowners. |
cd707eb
Alex Ross (alexr00)
left a comment
There was a problem hiding this comment.
Thanks for changing!
Fixes #96120