A tool to generate UML models from OpenAPI definitions.
To generate UML models:
- Eclipse Modeling tools (it can be found here).
To visualize the generated UML models:
- A UML 2.5 modeling environment in Eclipse such as Papyrus or UMLDesigner (we tested the tool with Papyrus).
- Open Eclipse IDE
- Click on Help / Install New Software...
- Click on Add... and fill in the form as indicated (the update site is https://som-research.github.io/openapi-to-uml/update/) then click on OK.
- Select OpenAPI to UML then click on Next.
- Follow the the rest of the steps (license, etc...) and reboot Eclipse.
- Create a Project or use an existing project in your workspace.
- Import the JSON file of your OpenAPI definition.
- Right-click on the definition file and select OpenAPI to UML/Generate a Class diagram. This will generate the UML model corresponding to the input definition under the folder src-gen of your project (check petstore.uml, the generated model from the Petstore example).
Instructions:
- Install Papyrus if you didn't do it yet (You can find the instructions here).
- Open the perspective Papyrus.
- Right-click on the generated UML model and select New -> Papyrus Model.
- Follow the steps in the wizard to initialize a Class diagram (keep everything as predefined except in the Initializtion information step where you should check Class Diagram as the Respresentation kind).
- Drag-and-drop the UML elements from the Model Expoler into the editor.
- Align and arrange the layout as you prefer.
- Save.
- Each schema definition (#/definitions) of type
object
is represented as a class. - All associations are of type aggregation.
- The location of an operation (i.e., in which class it should be) is decided based on the schema this operation produces (response 2xx schema), the schema it consumes (parameter of type body), or the tags properties of the operation. When no class is a good fit for the operation, an artificial class is created to host the operation. The name of such class is inferred from the path of the operation.
- The name of an operation is taken from
operationId
of the operation definition. If such information is not provided the name is created by concatenating the method of the operation (e.g., get, post) plus the name of its class. - The cardinalities of attributes and parameters are inferred from:
- the
type
field (array
for multivalued) - the
required
field in the OpenAPI definition (note that a required parameter or property of typearray
doesn't not mean that the lower bound should be 1. Empty arrays are still valid). minItems
andmaxItems
forarray
types.
- the
N.B. This tool relies on the OpenAPI metamodel located here.