Transforming REST or OpenAPI3 models into OpenAPI3
To transform a REST service model into OpenAPI3, configure
a REST Service Model to OpenAPI3 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
- To create a model project and a model from the REST Service Model (OpenAPI3) template, complete
the following steps:
- Click File > New > Model Project, and complete the pages in the Model Project wizard.
- 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).
- Optional: Complete the remaining pages in the wizard.
- Click Finish. The modeling project is displayed in the Project Explorer view and the model has the REST and OpenAPI3 profiles applied.
- In the model, create the REST Application and Resources as required.
- 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:
- On the Source and Target Page, select the model that is created as the source and select a Project or Folder as the target.
- 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 definition in the target openapi file and not the parent or child definitions of the referenced definition.
- 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.
- Optional: Generate code in the target language
- To generate code in the target language from REST Swagger model, select the check box Generate output in following language.
- Select the desired target language from the list of supported languages in the combo.
- The code gets generated inside the generated_code folder under the target project, after REST Service Model to Swagger transformation.
- 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.
Feedback