Importing a data model definition file

You can automatically populate a data model with composite types and enumeration types that are imported from a JSON schema file.

About this task

The following JSON schema formats are supported:
  • Swagger 2.0
  • OpenAPI 2.0
  • OpenAPI 3.0
  • OpenAPI 3.1
  • JSON schema draft 04
  • JSON schema draft 06
  • JSON schema draft 07
  • JSON schema draft 2019-09
  • JSON schema draft 2020-12
The following example shows a Swagger 2.0 definition file that contains a definitions element. Inside the definitions element, two data types are described:
  • A composite type person with multiple attributes.
  • An enumeration type status with three values, Married, Single, and Divorced.
{
  "swagger": "2.0",
  "info": {
    "title": "Swagger definition file",
    "description": "Simple definition file"
  },
  "definitions": {
    "Person": {
      "type": "object",
      "properties": {
        "firstName": {
          "type": "string"
        },
        "dateOfBirth": {
          "type": "string",
          "format": "date-time"
        },
        "dateOfLoanStart": {
          "type": "string",
          "format": "date"
        },
        "numberOfChildren": {
          "type": "integer"
        },
        "income": {
          "type": "number"
        },
        "noBankrupcy": {
          "type": "boolean"
        },
        "lastName": {
          "type": "string"
        },
        "status": {
          "type": "string",
          "enum": [
            "Married",
            "Single",
            "Divorced"
          ]
        },
        "descendants": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Person"
          }
        }
      }
    }
  }
}
You can annotate schemas to preserve the data types and attributes that you want to import. The following tags are available:
  • x-ibm-decision-adapt-type-name: when set to false, the name of the data type is preserved.
  • x-ibm-decision-adapt-property-name: when set to false, the name of the attribute is preserved.

Take the following example:

"RadioNetworkControllerRole": {
    "x-ibm-decision-adapt-type-name" : false,
    "x-ibm-decision-adapt-property-name" : false,
    "enum": [
      "D_NRC",
      "S_NRC"
    ],
    "type": "string"
  }

Without the x-ibm-decision-adapt-type-name tag set to false, the data type name would appear as radio network controller role once imported into Decision Designer.

Without the x-ibm-decision-adapt-type-name tag set to false, the two attributes would appear as D NRC and S NRC once imported into Decision Designer.

Procedure

  1. Open the Data tab in your decision service and click Create.
  2. Enter a name for the data model.
  3. Drag your definition file into the drop target area.
    Alternatively, you can click the drop target area and navigate to the definition file on your local system.
  4. Click Create.

Results

Your data model opens. You can now start to use the data types that it contains in your decision service. For more information, see Using data models in other decision artifacts.