How to add support for a JSON schema stored online?
kanitw opened this issue · 5 comments
E.g., with http://schemastore.org/json/
I have never actually done this, but you should be able to do this:
export default {
getSchemaURI() {
return 'http://schemastore.org/json/your-schema';
},
getFilePattern() {
return 'your-json.json';
}
};
Will take a look at this tomorrow
I released a new version - v1.11.0 which takes care of this. An example of loading a remote schema:
export default {
getSchemaURI() {
return 'http://json.schemastore.org/pattern'
},
getFilePattern() {
return 'pattern.json';
}
};
But be careful, there is a reason, why I'm not using these schemas! There are a lots of things in them, that are not sensible and are not handled too gracefully by my autocomplete plugin. Examples are: instead of an enum, they are using regex patterns a lot, omitting explicit type declarations, and so on. In most of the cases I downloaded and improved the schemas to get the best proposals possible.
Let me know how it works for you!
Also updated the docs on this. Now only real URIs are accepted from getSchemaURI()
https://github.com/bali182/autocomplete-json/wiki/SchemaProvider
Now if you check the 5.0.x version, it automatically loads the appropriate schema for your json file, when ctrl+space (or whatever your shortcut is) pressed.
Note, that the schema has to have the fileMatch
field here http://schemastore.org/api/json/catalog.json otherwise it won't work.