Definition file annotations
Preserving the name of data types and attributes during import
You can control whether data type and attribute names are automatically adapted or preserved in their original form using specific annotations.
| Annotation | Purpose |
|---|---|
x-ibm-decision-adapt-type-name |
When set to false, preserves the original data type name. |
x-ibm-decision-adapt-property-name |
When set to false, preserves the original attribute name. |
Consider 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
x-ibm-decision-adapt-type-nameset tofalse, the data type nameRadioNetworkControllerRolewould be automatically adapted toradio network controller roleduring import. - Without
x-ibm-decision-adapt-property-nameset tofalse, the enum valuesD_NRCandS_NRCwould be adapted toD NRCandS NRCduring import.
By setting both annotations to false, the original names are preserved exactly
as defined:
- Data type:
RadioNetworkControllerRole - Attributes:
D_NRC,S_NRC
Sharing data types between schemas
When importing schemas that contain identically named types into different data models, conflicts
can occur. Types with the same name but created in different packages are treated as distinct types,
even if they have identical verbalizations. For example, 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 data models at the same time.
x-ibm-pattern-to-package annotation to specify a shared package
for common types across schemas. The following example shows the
x-ibm-pattern-to-package used in an OpenAPI
schema:{
"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.