How to model multiple URIs in REST Services (APIs)


#1

I am using Visual Paradigm version 15.2 (evaluation edition) to model a REST API based platform. So, my need is to model the below:

GET /API/Products/{code} - get details of an individual Product
POST /API/Products - create a new Product

With all the documentation I have seen on this topic, I can model the GET OR POST URIs, but I cannot design / model both within the same REST Service.

I have also tried creating two REST Services called Products and model the GET API in one and the POST API in the other, but that is also not possible (because I am trying to create two REST Services with the same name).

I hope I have overlooked some simple feature. Appreciate your help.


#2

Disclaimer: I know my way around Visual Paradigm but my experience with REST is limited. Still, we’ll see where this goes :wink:

Now, I’m assuming you followed this tutorial:

… and therefor you’re using a class diagram for all this. And I think to see where things are going wrong.

VP 15.2 names the model a REST service but, as you can also see in the preview above, I think you should actually consider it a single REST resource, the service is basically displayed by the entire diagram.

One resource handles the POST action whereas the other handles the GET.


#3

hi ShelLuser,

Thanks for our response. Yes, I have read the tutorial. What I am looking to do is understand how to create the “Pet” class as in the example shown in https://petstore.swagger.io/. Here, Pet provides many services such as POST - add a pet to the pet store and PUT - update an existing Pet. My question is, how do I implement this in VP?

Many thanks


#4

Hi Rana,

You should model each req/rsp method (REST Service) vp%20product as you can see in the image uploaded.

In the REST Name and OperationID use the same name (createProduct & readProduct)
In the path (URI) use /product

then VP will generate both method for the same path without any trouble.

Unfortunatelly, in VP you cannot define tags.