-
Notifications
You must be signed in to change notification settings - Fork 29k
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 setting schema associations at runtime #96120
Comments
How would the dynamic configurator know what schemes applies to which file? |
In my case, there are some twin files like this:
I wanna to configure a specified JSON Schema to validate As you see, static glob is not working. Any workarounds or a more graceful solution will be great as well. |
One possible solution is to specify the schema in the JSON file |
Not really bad, but it's a little bit dirty for someone who reads and parses JSON key-values from the original file. And all consumers (such as our source code analysis service, native application...) have to take care of But anyway I think it's accepted for this case, so you can close this or take it into consideration for other clean approaches in the future. Thanks a lot. |
I have a use case for this. In my scenario, the schema of the JSON file changes based on the plugins specified, for example: {
"incremental": true,
"lineWidth": 160,
"json": {
"indentWidth": 2,
},
"typescript": {
"useTabs": true
},
"includes": [
"**/*.{ts,tsx,js,jsx,json}"
],
"plugins": [
"https://plugins.dprint.dev/typescript-0.48.0.wasm",
"https://plugins.dprint.dev/json-0.12.1.wasm"
]
} Given the plugins specified, the schema of the plugin specific properties change (ex. in this case the "typescript" and "json" properties are added to the schema). I previously thought #98443 would solve my use case, but it has the problem of the Instead, it would be neat if the dprint vscode extension could programatically generate a schema based on the plugins in the plugins array and use that to help set the schema of the file (so this would be ideally programatically specified rather than a uri, but as a workaround I could create a web server route with some query parameters to make this work). |
@aeschli oh great! That looks like it will work. Thanks so much! |
Related PR: #73424
Related FR: #69868
Feature Request: Configure
jsonValidation
contribution point dynamically.Use Case: Twin json files like
myFile.json
andmyFile.js
, which file name is the same as another file under the same directory, but file extension name is normal.json
. So, glob matching or content detection does not work well, dynamic configuration is required.The text was updated successfully, but these errors were encountered: