Generate Types from OpenAPI
This tutorial shows you how to generate types in various programming languages for a chosen Open API specification.
First, you need to import the Open API specification from JSON or YAML format. You can initiate the import from:
- ribbon: Process tab / Reverse Engineering / Open API
- menu: Tools / Reverse Engineering / Open API
It shows the Open API Import dialog.
In the dialog, click on Add Files button and select the JSON or YAML files with the Open API specification. Then confirm the dialog using the OK button - the specification will be imported into the current project. The generated UML Open API Diagram for the imported Open API specification will show.
Copy Generated Code for Open API Types
You can generate classes in a chosen programming language and copy them to the clipboard this way:
- Select the desired classes in the diagram
- Open Generation sidebar (ribbon / View tab / Window group / Sidebars button / Generation item)
- Choose the desired programming language from the Language drop-down (e. g. TypeScript)
- Choose the Selected Element option for the Generate From setting
- Click on the Generate button
- the generated classes will show in the text area below. You can copy the generated code using CTRL - C.
Generate Files for Open API Types
You can generate the source code files for the chosen Open API specification types. Start the Source Code Generation dialog:
- from the ribbon: Process tab / Generation group / Source Code button
- from the menu: Tools / Generate Source Code
In the Source Code Generation dialog, choose the desired programming language in the Language drop-down (e. g. TypeScript, C#). In the project tree in the left part of the dialog, check the nodes of the specified types (represented as UML classes) you want to export to the source code. Do not forget to specify the Output directory, where the generated source code files will be saved. Then click on the Generate button.
The source code generator in Software Ideas Modeler allows you to produce the file for the following programming and scripting languages: ActionScript, C++, C#, Dart, Delphi, Java, JavaScript, JSON, PHP, Protocol Buffer, Python, Ruby, SQL DDL, TypeScript, VB6, VB.NET, XSD.
New Comment