Validating a declaration

In this section, we show you how to validate an AS3 declaration against the schema using Microsoft Visual Studio Code. Using this type of validation is useful when composing a declaration manually, or to check the accuracy of a declaration before deployment.

For more information on editing JSON with Visual Studio Code, see this Microsoft document.

Note

If you are not using the AS3 class (see AS3 Class) in a declaration you are validating, the validation process incorrectly warns that the first class in a declaration must be “AS3”. It is perfectly acceptable to ignore this warning and omit the AS3 class, and start with the ADC class.

To validate a declaration

Use the following procedure to validate a declaration.

  1. Download and install Visual Studio Code.

  2. Go to the schema directory of the AS3 repo on GitHub.

    • Click either latest or the specific AS3 version you are using.
    • Click the as3-schema.json file (both files in each directory are the same), and then click the Raw tab.
    • Copy the URL of the raw schema file.
  3. Open Visual Studio Code, and use File > New File start a new JSON file. In our example, we name our file myDeclaration.json. You must save the file in order for Visual Studio Code to recognize it as a JSON file.

  4. At the top of your schema file, type the following code:

    {
        "$schema": "",
    
  5. Paste the GitHub raw URL you copied (if you downloaded the schema file, use the path to the file on your device) between the quotes. When you are finished with this step, your code should look like the following (you may have a different directory than latest):

    {
        "$schema": "https://raw.githubusercontent.com/F5Networks/f5-appsvcs-extension/master/schema/latest/as3-schema.json",
    
  6. Begin to type your declaration (if validating an existing declaration, see step 7)


    • You can also hover on a red wavy line (for JSON syntax errors), or a green wavy line (schema validation errors) to see the problem. In the following example, we have the declaration property, but have not yet included any of the required properties for declaration.

      ../_images/validate-declaration.png

    • It also suggests valid options for a property in the declaration:

      ../_images/validate-version.png

    • And informs you of required values:

      ../_images/validate-class.png

  7. You can also validate an existing declaration by pasting only the $schema line between the opening bracket of the file and the first property of the declaration.

    • In this example, the validator discovers a typo of the word Tenant.

      ../_images/validate-existing.png

    • For a full declaration, it is often easier to view the Problems (View > Problems). In this example, the validator discovers a number of issues. You can click individual problems to go directly to the line with the issue.

      ../_images/validate-problems.png