Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create spec for REST API in Enterprise Architect

My customer wants me to create a specification for a future REST API by using Enterprise Architect (SparxSystems). The deliverable should be well formatted text (can be html, docx or rtf). A class diagram should give a picture of the message body.

The only thing I found so far was https://github.com/bayeslife/api-add-in , a plugin for EA to generate RAML and more. Does anybody have a better approach?

like image 390
www.admiraalit.nl Avatar asked Jun 29 '16 11:06

www.admiraalit.nl


People also ask

How do I design a REST API?

You can design your REST API by drawing a class diagram that represents your resource, the request and response body. A REST resource is the fundamental unit of a web service that conforms to REST.

How do I create a rest resource in Visual Studio?

Select Diagram > New from the application toolbar. In the New Diagram window, select Class Diagram and the click Next. Enter the diagram name and description and then click OK. Select REST Resource in the diagram toolbar. Click on the diagram to create a REST Resource.

What does the REST API editor do?

The REST API editor creates and modifies a Swagger document that is compliant with version 2.0 of the Swagger specification. The Swagger document can be used with the Graphical Data Mapping editor to implement operations in the REST API as well as a wide range of external tools, such as Swagger UI, Swagger Codegen, and IBM API Management.

How do I draw a rest resource in Revit?

To draw a REST resource: Select Diagram > New from the application toolbar. In the New Diagram window, select Class Diagram and the click Next. Enter the diagram name and description and then click OK. Select REST Resource in the diagram toolbar.


2 Answers

The presentation 'Modeling Microservices' by Sander Hoogendoorn contains some interesting slides about modeling a REST API in Enterprise Architect. The presentation is available on slideshare.net. The most interesting slide is slide #75. Here is the picture shown on that slide:

Class model of REST service

(Class and attribute names are in Dutch. Verklaring means Declaration and Verklaringen means Declarations. But the business behind this example is not relevant.)

It would be nice if someone would have a plugin for Enterprise Architect to convert these class diagrams into Swagger specs (Open API specs).

like image 81
www.admiraalit.nl Avatar answered Oct 17 '22 16:10

www.admiraalit.nl


Update 2019/03/18

Use this plugin and guideline: https://sparxsystems.us/go/restapi/

Original answer

I'm using Enterprise Architect at this moment to model an API. For this projects you have users that are granted a budget to buy certain products. The model is not yet complete, but I'm adding it here as reference.

In EA I added some additional stereotypes: Path, Resource and Representation + a new datatype ParamQuery.

To model the API you create a new class diagram and start by the root of your API as a class of stereotype "Application". Next you add your Resources and Paths. For each Resource you add the necessary GET, POST, PUT etc. operations. If QueryParams are passed along in the string for the GET operations you add them as Parameters for the operation, but as type QueryParam (you need to create it the first time). For the messagebody of POST operations you add a parameter of the class type it represents.

Next you add the "representation" classes, used by the Resources.

enter image description here

like image 32
Chris Aelbrecht Avatar answered Oct 17 '22 15:10

Chris Aelbrecht