Skip to content

Editing Schemas

A schema can be edited in three ways:

Detailed Element Editing
Edit the details of individual element selected from the Schema Tree
Elements Editor Table
A table of sub-elements of a parent object selected from the Schema Tree
SWAGGER Editor
Edit OAPI directly in the Generate tab, SWAGGER editor section.

The Schema Tree

The Schema tree in the Schema tab looks like:

It contains the two sections- Header and the Main Section.

Sections

Schema name / Selected schema Displays the schema name / complete navigation path
Edit Schema Button Used to edit schema (only if the schema was created using the SQL import)
Duplicate Schema Button Used to copy the schema with a different name
Save Schema Button Used to save the schema on the server

Schema name / Selected schema

The name or the schema or the navigation path in case you navigate to the other schema for viewing the schema refs.

Edit Schema Button

Edit the schema using the button. This button is visible only if the schema was created using the SQL import.

After the schema is created, it can be edited anytime later by clicking the button.

Duplicate Schema Button

Use the button to create a copy of the existing schema. On clicking the button, a popup form appears

Enter the name of the new schema you want to create and click "Create". The duplicate schema is created!

Save Schema Button

Use the button to create a copy of the schema on the server. When you click this button, a popup form appears.

Enter the desired name and description and click The schema is saved!

Schema Tree Section

This section shows the expandable/collapsible hierarchical tree view of the schema selected.

The curly braces after the field name indicate that the element is an object type.

The square brackets after the field name indicate that the element is array type whose elements could be object type or the elementary data types.

The model Types: allOf, oneOf and anyOf and the ref type fields are also depicted in the schema tree, like in the following example.

Detailed Element Editing

The basic or elementary data type properties can be edited by selecting an the element in the schema tree and editing the detail in the form which appears on the right side.

The detail form contains a combination of the following input fields shown in the table below. The Details Form format varies depending on the basic data type.

Field Description Corresponding Swagger field
Type The type of element to be selected from the dropdown list type
Example Editable, can be comma separated multiple values example (an array)
X-Column Column name in the DB2 Table or Physical File x-column
Key If the selected field is the key-field x-key (boolean)
Description Description of the field description
MaxLength The maximum length in case of string type elements maxLength
Maximum This parameter is also considered for identifying the maximum decimal positions when the data type is “number”. maximum
For example, if the maximum is set to 9.9999999, that means the variable will be declared with 10s,6 (if “x-ibmitype” is set as “zoned”).
Otherwise, it will be defined as 10p, 6. maximum
IBMI-Type Possible values are “zoned”, “packed” or "binary" when the item type is “number” or “integer” x-ibmitype
Possible values are “char” or “varchar” when the item type is “string”
Format The possible values for this entry could be “int32” or "int64” for “integer” type format
and that for “number” type could be “float” or “double". The format “int32” causes the variable definition with 10i,0 or 10p,0 or 10s,0 depending on whether IBMI-Type is specified or not
When “int64” is there, the length 10 becomes 20. The format “float” causes the variable to be defined as 9b,5
whereas "double" causes 16p,11 or 16s,11 or 9b,5 definition depending on IBMI-Type.
For "string" type, the possible values are 'date' or 'string'*
MultipleOf This parameter tells the domain of the values but here it is used to identify the number of decimal positions. multipleOf
As an example, if the value is multipleOf: 0.0001 and the data type is “number”, that means the decimal positions are 4.

Basic Data Types

String Type

Consider the following schema example. The detail form for editing the string type variables looks like:

Basic type - String:Schema Detail

The corresponding Swagger object for the selected property "Department" looks like:

Basic type - String:Schema Detail

Integer Type

Consider the following schema example. The detail form for editing the string type variables looks like:

Basic type - Integer:Schema Detail

The corresponding Swagger object for the selected property "population4" looks like:

Basic type - Integer:Schema Detail

Number Type

Consider the same schema example used for the integer type property. The detail form for editing the number type variables looks like:

Basic type - Number:Schema Detail

We are viewing the details of the number type field: "countrycode"

The corresponding Swagger object for the selected property "countrycode" looks like:

The corresponding Swagger object for the selected property "Department" looks like:

Basic type - String:Schema Detail

Generate MDR_jsonPathV

Use the button on the header of the Detail Section, to generate the RPGLE snippet. This logic can be used to parse the value from this schema element of the selected property in the schema.

In the example below we have generated the MDR_jsonPathV syntax of the field named "display_name". The popup shows the generated MDR_jsonPathV statement

The value can be copied using the "Copy" button provided alongside and pasted into your RPGLE program.

For example, take the request body JSON sample below:

{
  "clientid": "8403211024083",
  "name": "Daisy",
  "surname": "Doolittle",
  "title": "Mrs",
  "phone": "0115557777",
  "email": "daisy@soc.gov",
  "addr1": "1 Impala Avenue",
  "addr2": "Buckburg",
  "addr3": "",
  "pcode": "9203",
  "language": "E"
}

In a provider program, the rpg logic below, will return the value Mrs into the title subfield for qualified data structure clientrec:

dcl-ds clientrec qualified;                                                                        
  clientid  varchar(15)     inz;                                                                   
  name      varchar(30)     inz;                                                                   
  surname   varchar(30)     inz;                                                                   
  title     varchar(30)     inz;                                                                   
  phone     varchar(15)     inz;                                                                   
  email     varchar(100)    inz;                                                                   
  addr1     varchar(30)     inz;                                                                   
  addr2     varchar(30)     inz;                                                                   
  addr3     varchar(30)     inz;                                                                   
  pcode     varchar(15)     inz;                                                                   
  language  varchar(1)      inz;                                                                   
end-ds

clientrec.title = MDR_jsonPathV(handle:'title');

Elements Editor Table

This section lets you view / edit / add / delete fields in the object / array element selected on the Schema Tree

Re-Order the fields

Click on the icon to drag and drop the fields.

For Example:

If we bring the field "name" to the top, the schema screen looks like

Delete a field

Click on the button under the Actions column to delete a field.

Copy a field

Click on the button under the Actions column to copy a field.

Add a field

Add the API Field name, Select the data type from the dropdown list and add the Max Length. The new field is created!

JSON Structure Editing:

The non-basic element types are included in this section.

The JSON Structure can be edited using the Details Form.

Objects {}

Clicking on the object element in the schema brings up the details of the selected object. The data type can be changed by selecting the value from the dropdown list but it comes with a word of caution. Changing the data type from object to any other data type would delete all the fields (the immediate children) that the object contains.

Consider the following schema example where we click the field "repository" which is object type. Following details come up:

Object type Field Details

The table shown inside the details form gives summarised detail of the child fields of the selected object. In our example the two fields owner and links are object type, so the total number of object fields is 2. Similarly it gives the summarised information for all the data types.

Object Type Detail Form

Below the details form, the Sub-Element Editor Table containing the fields that are the immediate children of the selected object. You can add, edit, re-order, delete, copy the fields in the table.

Object Type Sub-Element Editor Table

Arrays []

Arrays are defined and have Items. Item types can be any of the following:

Basic Item Type

(string, boolean, integer, number)

Consider the following example.

Detail section- Array with basic type element

The selected field - "Sizes" is an array of string type elements.

In case of array type elements and basic/elementary data type elements, following additional fields are provided.

Field Description Corresponding Swagger key in items object
Item Type The type of array elements to be selected from the dropdown list type
Example Editable, can be comma separated multiple values in case of string elements example (an array)
Maximum Items The maximum size of the array maxItems
MaxLength The maximum length in case of string type array elements maxLength
Maximum This parameter is also considered for identifying the maximum decimal positions when the data type is “number”.
For example, if the maximum is set to 9.9999999, that means the variable will be declared with 10s,6 (if “x-ibmitype” is set as “zoned”).
Otherwise, it will be defined as 10p, 6.
maximum
IBMI-Type Possible values are “zoned”, “packed” or "binary" when the item type is “number” or “integer”.
Possible values are “char” or “varchar” when the item type is “string”
x-ibmitype
Format The possible values for this entry could be “int32” or "int64” for “integer” type.

For “number” type could be “float” or “double".

The format “int32” causes the variable definition with 10i,0 or 10p,0 or 10s,0 depending on whether IBMI-Type is specified or not.

When “int64” is there, the length 10 becomes 20. The format “float” causes the variable to be defined as 9b,5, whereas double causes 16p,11 or 16s,11 or 9b,5 definition, depending on IBMI-Type.

For "string" type, the possible values are 'date' or 'string'
format

Edited Detail section- Array with basic type element

The swagger gets updated for the selected element "Sizes"

Updated Swagger Definition for the Edited Field

Object Item Type

Please refer to the example below. The selected field "changes" is an array with object type elements.

Array of object type items

The fields of the object type array elements are also shown in the Sub-Element Editor Table.

Nested Arrays

Here is an example where the array element has items of type arrays of strings.

{
  "stringArray": [
    ["string1", "string2"],
    ["string3", "string4"]
  ],
  "objectArray": [
    {"object1": "value"},
    {"object2": "value"}
  ]
}

This how it will be defined in the UI

Array of arrays of strings

Here is another example where the array element has items of type arrays of objects.

Array of arrays of objects

Again changing the data type or item type (data type of the array elements) is permitted but comes with a word of caution. You could end up getting the child elements deleted!

$ref Type

If you click on the ref type fields

If you click on the link in the $Ref field in the details section,

the schema tree would show the selected schema

Clicking on the field iban would bring up:

Using Sub-Element Editor Table

This section lets you view / edit / add / delete fields in the object / array element selected on the Schema Tree

Re-Order the fields

Click on the icon to drag and drop the fields.

eg.

If we bring the field "name" to the top, the schema screen looks like

Delete a field

Click on the button under the Actions column to delete a field.

Copy a field

Click on the button under the Actions column to copy a field.

Add a field

Add the API Field name, Select the data type from the dropdown list and add the Max Length. The new field is created!