This article describes a frequently asked question (FAQ) about defining Thing Specification Language (TSL) models for a product, and provides an answer to the question.

What can I do if the verification fails when I import a TSL model file?

Problem description: The verification fails when a TSL model file is imported, as shown in the following figure.

Failed verification

Solution:

  • Solution 1: Check the format of the TSL model file and correctly format it in JSON.
  • Solution 2: Click Download and View to obtain an errors.txt file. Troubleshoot and correct the issues based on the errors.txt file.

    For more information about an errors.txt file, see the following sample file.

    Sample TSL model file:

    {
        "schema":"https://iotx-tsl.oss-ap-southeast-1.aliyuncs.com/schema.json",
        "profile":{
            "productKey":"a1Jk***"
        },
        "services":[],
        "properties": 1,
        "events": [],
        "functionBlockId": "**mtest",
        "functionBlockName": "Custom module 1"
    }

    Sample errors.txt file:

    [
      {
        "path": [
          "properties"
        ],
        "property": "instance.properties",
        "message": "is not of a type(s) array",
        "schema": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/propertyDefinition"
          }
        },
        "instance": 1,
        "name": "type",
        "argument": [
          "array"
        ],
        "stack": "instance.properties is not of a type(s) array"
      },
      {
        "path": [
          "functionBlockId"
        ],
        "property": "instance.functionBlockId",
        "message": "does not match pattern \"^[_a-zA-Z0-9]{1,30}$\"",
        "schema": {
          "type": "string",
          "pattern": "^[_a-zA-Z0-9]{1,30}$"
        },
        "instance": "**mtest",
        "name": "pattern",
        "argument": "^[_a-zA-Z0-9]{1,30}$",
        "stack": "instance.functionBlockId does not match pattern \"^[_a-zA-Z0-9]{1,30}$\""
      }
    ]
    Parameter Description
    path The path of the error. In this example, the following two errors are detected:
    // The value of the properties parameter is not an array.
    "path": [
          "properties"
        ]
    
    // The value of the functionBlockId parameter contains invalid characters.
    "path": [
          "functionBlockId"
        ]
    property The invalid property in "path".

    For example, in "path": ["functionBlockId" ], the value of the instance.functionBlockId property is invalid.

    message The error message.

    For example, in "path": ["functionBlockId" ], the error message does not match pattern \"^[_a-zA-Z0-9]{1,30}$\" is returned for the instance.functionBlockId property.

    schema The rule that is used to verify the TSL model file.

    For example, in "path": ["functionBlockId" ], the type and pattern rules are used.

    For more information about the rules, see schama.

    instance The object that is verified.

    For example, in "path": ["functionBlockId" ], the setting of "functionBlockId": "**mtest" is verified.

    name The name of the rule that failed the verification.

    For example, in "path": ["functionBlockId" ], the value of **mtest does not comply with the pattern rule.

    argument The definition of the rule that failed the verification.

    For example, in "path": ["functionBlockId" ], the definition of the pattern rule is ^[_a-zA-Z0-9]{1,30}$.

    stack The concatenated information, which combines the values of the property and message parameters.

For more information, see Description of jsonschema.