How to provide different schema for different json

Answered

In my plugin, I add a schema using JavaScript.JsonSchema Extension Point. As we know It need to implement JsonSchemaProviderFactory.

My question is: how can I use different schema for different json? 
For example: if the json file's name is xxx-host.json, use host.schema.json; if the json file's name is xxx-client.json,  use client.schema.json; otherwise, don't use any schema.

I have read a lot of example in (https://plugins.jetbrains.com/intellij-platform-explorer/extensions?extensions=JavaScript.JsonSchema.ProviderFactory), but no suitable example was found.

I need help please.

1
2 comments

Hi,

You can create multiple schema file providers for each type of file and implement JsonSchemaFileProvider.isAvailable() to determine whether a given provider is dedicated for a given file.

1

It work! Thank you!

0

Please sign in to leave a comment.