Importing a data model definition file
About this task
- 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
- A composite type
personwith multiple attributes. - An enumeration type
statuswith three values,Married,Single, andDivorced.
{
"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"
}
}
}
}
}
}
Customizing names of data types and attributes that are imported
x-ibm-decision-adapt-type-name: when set tofalse, the name of the data type is preserved.x-ibm-decision-adapt-property-name: when set tofalse, 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 might appear as radio network controller role when it is
imported into Decision Designer.
Without the x-ibm-decision-adapt-property-name tag set to
false, the two attributes might appear as D NRC and S
NRC when it is imported into Decision Designer.
From 24.0.0-IF001Importing types that can be shared between schemas
If you import a schema that contains the type Person in data model 1, and
another schema that contains the same type Person in data model 2, you cannot use
both the data models at the same time.
- To have the data model 2 that depends on the data model 1
- To have a decision model that depends on both the data models
These two types are considered different in these cases as they are created in different packages, while they have the same verbalizations.
Use the annotation x-ibm-pattern-to-package in the imported schemas to select in
which package the shared types are placed so that they are considered the same type.
{
"openapi": "3.0.3",
"x-ibm-pattern-to-package" : {
"^Shared.*$" : "com.shared"
},The x-ibm-pattern-to-package annotation must be put at the top level. It can
contain several regular expressions and relate them to a package name. Here, all types that begin
with Shared in the schema is put in the com.shared package.
Apply the same x-ibm-pattern-to-package annotation to all the schemas that
contain the types to be shared. Each time a schema is imported, the shared types are created in the
shared packages.
Procedure
- Open the Data tab in your decision service and click Create.
- Enter a name for the data model.
- 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.
- Click Create.