Skip to content

Creating a New Schema

A new schema can be created manually using schema editing tools, or importing information from various sources.

Imputing is handled by MDRest4i SDK reverse engineering APIs, that derive this structure from various input types. The derived schema is then inserted as a schema component in the underlying OAPI/SWAGGER specification in the compo.

The schema can be derived from the following import types:

Import JSON Import JSON sample from a local file, or edit sample JSON manually
Importing DB2 DDS Import from DB2 DDS/Tables on IBM i
Importing DS RPGLE Extract OAPI schema(s) from RPGLE Data Structure in source file
Importing DS COBOL Extract OAPI schema(s) from Cobol Data Structure in source file
Importing Saved Schemas Upload the schema from a JSON schema file saved on the server

Importing JSON

JSON can either be imported from a local file or edited directly in the provided JSON editor. The JSON is then parsed and the OAPI schema inserted as a schema to the components section of the OAPI specification.

  1. In the "Schema" tab, click the button to add a new schema
  2. Enter the model name


JSON Import Schema Creation

Click

The schema import editor comes up. You can upload a file from your local file system or enter the JSON into the editor.

Click the button

The Components object in the Swagger specification would be updated as:

Swagger definition update

The schema gets created!


The created new Schema

!!! tip title="Adding Schema Manually"

To manually create a schema using the [schema editing tools](editing-schemas.md), select **JSON** as the type of import, use either an empty object or array sample and select import

Importing DB2 DDS

MDRest4i uses an API on the IBM i to derive a JSON schema structure from the physical file definition.

  1. Click the button to add a new schema
  2. Select the "import Type" as "Database" from the dropdown list.
  3. Enter the library name (X-Library)and the physical file name(PF Name) which would be validated from the server.
  4. Click the button

Note: The library name and PF name are validated on the IBM i using an Accelerator REST API written using iCore. So the "Next" button would be enabled only after they are validated (the green checkbox on the right of each field) and if model with the entered name does not exist.

Database Schema Extraction

After the button is clicked, the list of fields in the PF file LXCLIENT in Library MDRST comes up

Field Selection

Select all the fields by clicking on the check box in the top left corner. This information is extracted in real-time by another iCore REST API on the IBM i. The API field name is taken from the field text and the x-column from the PF field name itself.

Click to continue.

The newly created schema is gets created and is added to the list of models.

! Created Schema

The Components object would contain a new object in the Swagger specification.

Updated Swagger

Importing from RPGLE Data Structure

MDRest4i SDK can derive a payload definition from data structures defined in RPGLE source.

  1. In the "Schema" tab, click the button to add a new schema
  2. Enter the model name


DS-RPGLE Import Schema extraction

  1. Provide the complete path for the Cobol file in the "Source Path"


DS-RPGLE Import Schema extraction - Source Path

Click

The schemas extracted from the Cobol data-structure are listed.


Schemas extracted

Please select the schemas you want to import. The model names can also be renamed by editing the names in the second column of the table.

Click the button.


Successful Schemas extraction

Importing from COBOL Data Structure

MDRest4i SDK can derive a payload definition from data structures defined in COBOL source.

  1. In the "Schema" tab, click the button to add a new schema
  2. Enter the model name


DS-COBOL Import Schema extraction

  1. Provide the complete path for the Cobol file in the "Source Path"


DS-COBOL Import Schema extraction - Source Path

Click

The schemas extracted from the Cobol data-structure are listed.


Schemas extracted

Please select the schemas you want to import. The model names can also be renamed by editing the names in the second column of the table.

Note: In our source file, there was only one schema. There could be multiple schemas too, in other cases.*

Click the button.


Successful Schemas extraction

Importing Saved Schemas

Schemas already created and saved on the server, can be imported to a specification.

Use this option to import a schema already saved on the server by any user using the Save Schema button.


Import Saved Schema

On selecting the "Import Type", the dropdown list of the saved schemas appears from which you can select the one you wish to import.


Schema Selection

Select the "Done" button.

The new schema gets imported and created.

Saving Schema

Schemas can be saved on the server, and shared with other developers by importing saved schemas.

Use the button on the schema tree (left side) 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 button. The schema is saved!