IBM Support

Open API 3.0 support in Rational Software Architect Designer and Rational Software Architect Designer for WebSphere Software

General Page

OpenAPI 3.0 support in Rational Software Architect Designer/Rational Software Architect Designer for WebSphere Software 9.7.1

OpenAPI 3.0 support in Rational Software Architect Designer/Rational Software Architect Designer for WebSphere Software

Introduction

The OpenAPI Specification (OAS) defines a standard, language-agnostic interface to RESTful APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined, a consumer can understand and interact with the remote service with a minimal amount of implementation logic.

An OpenAPI definition can then be used by documentation generation tools to display the API, code generation tools to generate servers and clients in various programming languages, testing tools, and many other use cases.

Refer to below links for more details about OpenAPI specification:

https://swagger.io/specification/

https://swagger.io/docs/specification/about/

Since Rational Software Architect Designer 9.7.1 and Rational Software Architect Designer for WebSphere Software 9.7.1, support for modeling and generation of OpenAPI 3.0 specification based Representational State Transfer (REST) web services is provided.

Palette tools, template models, and profiles to model RESTful web services are enhanced to support OpenAPI3.0-specific capabilities.

Creating REST models by using template models

By using the Representational State Transfer (REST) or OpenAPI template models, you can create a UML model that has the corresponding profile applied and reference library elements imported so that you can model REST web service elements and OpenAPI elements etc.

Before you begin

To model Rest web services, you must have the REST Modeling capability enabled. To model OpenAPI capabilities by using stereotypes in the OpenAPI, you must have the OpenAPI Modeling capability enabled.

Procedure

  1. Click File > New > Model.
  2. On the Create Model page, click Standard template; then click Next.
  3. On the next Create Model page, in the Categories pane, click REST Modeling, and in the Templates pane, complete one of the following steps:
    • To create a OpenAPI3 REST Model, click REST Service Model (OpenAPI3). If you select this option, the generated model has both REST and OpenAPI3 profiles applied and also it imports the OpenAPI3 reference library.
      Tip: If these templates are not displayed, select the Show All Templates check box.
  4. In the File name field, type a name for the model and browse to a destination folder.
  5. Click Finish.

Results

The new model is created and displayed in the Project Explorer view. The new model and its default diagram are opened for editing. You can now model REST web service model elements or OpenAPI3 elements.

Modeling OpenAPI3 elements

You can now update OpenAPI3 REST Service model by using the OpenAPI Specification (formerly known as the Swagger Specification) version 3.0 elements that are available in the Palette under OpenAPI3 drawer.

For example, add the REST Application and Resources elements as required.

Below sections explain the steps for modeling i) Global Parameters and Global Responses and ii) Inline Schemas.

Procedure

  1. Modeling Global Parameters and Global Responses
    1. Creation of Global Parameters and Global Responses
      1. Select OpenAPI Application Class from OpenAPI3 palette and drop on to the UML diagram.
      2. OpenAPI3 application class element is added to the model.
      3. Newly added class element has Globals as the default UML Operation.
      4. Adding Global responses:
        1. Select OpenAPI Response Parameter from OpenAPI3 palette and add to the Globals operation.
        2. Ensure that the other details of OpenAPI response parameter are set as needed.
      5. Adding Global parameters:
        1. Select OpenAPI Parameter from the OpenAPI3 palette and add to the Globals operation.
        2. Ensure that the other details of OpenAPI parameter are set as needed.
    2. Referencing Global parameter and Response from Resource operations
      1. Select OpenAPI Parameter or OpenAPI Response Parameter from OpenAPI3 palette.
      2. While adding OpenAPI Parameter or OpenAPI Response Parameter to a Resource operation, options to select an existing element or to create a new element appears.
      3. Select the Select Existing element option to open a Select Element dialog box.
      4. Select the global response or parameter and click OK.
  2. Modeling the Inline schemas
To model an inline schema for a OpenAPI Parameter or a OpenAPI Response Object, you need to perform the following steps:
    1. Select the OpenAPI Parameter or OpenAPI Response Object element in Project Explorer
    2. Open the Properties view.
    3. Ensure that the type is set to the corresponding schema definition class.
    4. Open the REST tab and enable the Inline Schema option.

Transforming REST models and REST service elements

You can transform a UML model that has both Representational State Transfer (REST) profile and OpenAPI3 profile applied into corresponding OpenAPI3 artifact and vice versa.

Transforming REST or OpenAPI3 models into OpenAPI3

To transform a REST service model into OpenAPI3, configure a REST Service Model to OpenAPI 3.0 transformation, and then run the transformation.

Before you begin

You must be in the Modeling perspective and the REST Modeling capability must be enabled.

Procedure

  1. Create a REST Service Model to OpenAPI 3.0 transformation configuration:
    Click File > New > Transformation Configuration, select REST Service Model to OpenAPI 3.0 under Service Oriented Architecture Transformations category, and complete the steps in the wizard. Specify the following values in the transformation configuration file:
    1. On the Source and Target Page, select valid source and target elements.

Valid transformation sources

You must specify a UML model as the source of the transformation.

If you select a model or package in the Project Explorer view instead of using the Transformation Configuration editor, the model or package that you select overrides the source model or elements that you specify in the transformation configuration.

If you select a model or package in the Project Explorer view instead of using the Transformation Configuration editor, the model or package that you select overrides the source model or elements that you specify in the transformation configuration.

Valid transformation targets

You must specify a Project or a folder as the target of the transformation.

    1. Optional: Specify additional properties that are unique to the REST Service model to OpenAPI 3.0 transformation:

Generate flat OpenAPI Schemas

Select this check box to generate only the referenced schemas in the target openapi file and not the parent or child definitions of the referenced schema.

Generate folders for UML Packages

This option is enabled by default. Select this check box to generate a folder in the target openapi project corresponding to the UML package under which a openapi application element is present in the source model. The target openapi file gets generated under this folder.

Prompt to over-write existing files

This option is enabled by default. Select this check box to bring up a prompt to over-write existing target files and give an option to the user to select the target files that needs to be over-written after running REST Service Model to OpenAPI 3.0 transformation.

Generate empty descriptions for Response Objects

Select this check box to generate the description with empty strings for response objects even if they don't have the documentation text.

Check for cyclic dependencies among definitions

Select this check box to verify if there are any cyclic dependencies in the OpenAPI schemas. If there are any circular references found, a dialog will be displayed which contains information about the circular references found among openapi schemas with openapi schemas details.

Generate Quotes for YAML Artifact

Select this option to generate double quotes around the values of operations in the YAML file. The option is not selected by default.

  • Click File > Save.
  • In the Transformation configuration editor, click Run to run the transformation. The transformation runs and generates a OpenAPI3 file from the source Model in the target Project or folder.

Note: A OpenAPI3 file that is compliant with OpenAPI Specification version 3.0 is generated.

Transforming OpenAPI3 into elements in UML models

To transform OpenAPI3 into a UML model with the corresponding stereotypes applied, configure a OpenAPI 3.0 to REST Service Model transformation and then run the transformation.

Before you begin

You must be in the Modeling perspective and the REST Modeling capability must be enabled.

Procedure

  1. To create a model project and a model from the REST Service Model (OpenAPI3) template, complete the following steps:
    1. Click File > New > Model Project, and complete the pages in the Model Project wizard.
    2. On the Create Model page of the wizard, in the Categories pane, click REST Modeling, then in the Templates pane, click REST Service Model (OpenAPI3).
    3. Optional: Complete the remaining pages in the wizard.
    4. Click Finish. The modeling project is displayed in the Project Explorer view and the REST and OpenAPI3 profiles are applied to the model.
  2. Create a OpenAPI 3.0 to REST Service Model transformation configuration:
    Click File > New > Transformation Configuration, select OpenAPI 3.0 to REST Service Model under Service Oriented Architecture Transformations category, and complete the steps in the wizard. Specify the following values in the transformation configuration file:
    1. On the Source and Target Page, select the OpenAPI3 input file as source and select the model that is created as target.
      Note: The OpenAPI3 input file must be compliant with the OpenAPI Specification version 3.0.
    2. Optional: Specify additional properties that are unique to the OpenAPI3 to REST model transformation:
Generate a UML association for each OpenAPI Schema type
Select this check box to generate a UML association for every OpenAPI schema type.
Set minItems to 1 for required array type OpenAPI properties
Set the default value for minItems to 1 for the array type OpenAPI properties.
  1. Click File > Save.
  2. In the Transformation configuration editor, click Run to run the transformation. The transformation is run and a model is generated from the source OpenAPI3 file.
Stereotypes of the OpenAPI3 profile

The OpenAPI3 profile contains stereotypes that you can apply to model Representational State Transfer (REST) elements such as application, resource classes, and resource methods.

To use these stereotypes, the OpenAPI3 profile must be applied to your UML model. If you use the stereotypes in the OpenAPI3 profile, you must also apply the REST profile to the model; the OpenAPI3 stereotypes and type library extend the REST profile and type library.

The following table lists the stereotypes that you can apply to elements in a model on which the OpenAPI3 profile is applied. In some cases since the OpenAPI3 stereotypes extend REST stereotypes, the REST stereotype must also be applied with it.

Stereotype

Applicable UML element Required

Stereotype from REST Profile

Comments

«OpenAPIApp»

Class

«Application»

Represents a OpenAPI Object (root document object)

«OpenAPIOperation»

Operation

«GET»

«PUT»

«POST»

«DELETE»

«HEAD»

«PATCH»

«OPTIONS»

Represents a OpenAPI Operation Object

«OpenAPIParam»

Parameter

«Param»

Represents a OpenAPI Parameter Object

«OpenAPIRequestBody»

Parameter

-

Represents a OpenAPI RequestBody Object

«OpenAPIResponse»

Parameter

-

Represents a OpenAPI Response Object

«OpenAPISchema»

Class

-

Represents a OpenAPI schema object

«OpenAPIPrimitiveDefinition»

Class

-

Represents a OpenAPI schema object of primitive type

«OpenAPIProperty»

Property

-

Represents a Property of a OpenAPI schema object

«OpenAPIHeader»

Property

-

Represents a OpenAPI Header object

«OpenAPITag»

Class

-

Represents a OpenAPI Tag object

«OpenAPISecurityBasic»

Class

-

Represents a OpenAPI Basic Security schema object

«OpenAPISecurityApiKey»

Class

-

Represents a OpenAPI API Key Security schema object

«OpenAPISecurityOAuth2»

Class

-

Represents a OpenAPI OAuth2 Security schema object

Migration of Swagger 2.0 YAML/JSON artifacts to OpenAPI 3.0

By using the Swagger 2.0 to OpenAPI 3.0 migration utility, you can migrate the existing Swagger 2.0 YAML/JSON artifacts to corresponding OpenAPI 3.0 YAML/JSON artifacts.

Before you begin

You must be in the Modeling perspective and the REST Modeling capability must be enabled.

Procedure

To migrate the Swagger 2.0 YAML/JSON files to OpenAPI 3.0, complete the following steps:
  1. Right click on the Swagger 2.0 YAML/JSON file and click Generate OpenAPI 3.0.
  2. In the Swagger to OpenAPI convertor wizard, specify the Target file name and Target file format.
  3. Click on Finish.
The converted OpenAPI 3.0 YAML/JSON file will be generated and displayed in the Project Explorer view.
Note: Location will be same as input Swagger 2.0 YAML/JSON file.

[{"Type":"MASTER","Line of Business":{"code":"LOB36","label":"IBM Automation"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSYK2S","label":"Rational Software Architect Designer"},"ARM Category":[{"code":"a8m50000000L1nBAAS","label":"Rational Software Architect"}],"ARM Case Number":"","Platform":[{"code":"PF016","label":"Linux"},{"code":"PF017","label":"Mac OS"},{"code":"PF033","label":"Windows"}],"Version":"9.7.1"},{"Type":"MASTER","Line of Business":{"code":"LOB45","label":"Automation"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSYKBQ","label":"Rational Software Architect Designer for WebSphere Software"},"ARM Category":[{"code":"a8m50000000L1nBAAS","label":"Rational Software Architect"}],"Platform":[{"code":"PF016","label":"Linux"},{"code":"PF017","label":"Mac OS"},{"code":"PF033","label":"Windows"}],"Version":"9.7.1"}]

Document Information

Modified date:
14 September 2021

UID

ibm16473441