Validate Documents Against a Schema

The VS Code extension for Rapid Adapter Builder has a JSON schema packaged with it. The extension validates all adapter definition documents it generates against the schema.

If a file name ends with the suffix .add.json, the extension automatically validates the document against the JSON schema. You can review the validation errors, if any, in the VS Code editor.

Using the schema-validation feature, you can perform several tasks, such as viewing error highlights, viewing descriptions for valid keys, and viewing code hints.

To perform these tasks, open an adapter definition document in the VS Code editor.

  1. In VS Code, click Explorer Explorer icon on the sidebar.
    The directory structure of your workspace folder is displayed.
  2. Within the definitions directory listing, click the adapter definition document that you want to work on.
    The document is displayed in the VS Code editor.

    Note:

    The file name of the document you select must have the suffix .add.json.
  3. See the following topics for details on each schema-validation feature and how to use it:

View Error Highlights

If a key or value in your document does not comply with the vocabulary described in the JSON schema, the VS Code extension highlights the violations.

  1. In the VS Code editor, check for error highlights in your document.
  2. Fix the highlighted violations, if any.

Here are some examples of schema-validation errors:

  • Invalid Key


    Invalid key highlight

  • Invalid Value


    Invalid value highlight

  • Missing Required Property


    Missing property message

View Descriptions for Valid Keys

If a key in your document is valid (that is, complaint with the vocabulary in the JSON schema), the VS Code extension provides a description for the key. This description is displayed as a tooltip.

  1. In your document, point to a valid key to view its description.
  2. Enter a value for the key according to the information in the description.

Here's an example description:


key description

View Code Hints

The VS Code extension can suggest relevant keys or values to add to your document at a particular location. It suggests keys or values that are driven by the packaged JSON schema.

  1. To view code hints in your document, enter the double quotation mark (") at the location where you want to add a new key or value.
  2. Select an appropriate key or value from the suggestions.

    Note:

    For the suggestions to appear for a value field, the value expected needs to be of an enumerated type.

Here are a few example suggestions:

  • Key Hints


    Key hints

  • Value Hints


    Value hints