swagger-petstore icon indicating copy to clipboard operation
swagger-petstore copied to clipboard

Petstore API as REST API?

Open ueberfuhr opened this issue 2 years ago • 2 comments

Wouldn't it be a good idea to design the API as a REST API? I'd like to show this sample in REST trainings, but unfortunately, it does not fit the guidelines.

Main points are

  • URLs:
    • pets instead of pet, users instead of user
    • findByStatus and findByTags as parameters of GET /pets
    • image upload with PUT /pets/{petId}/image
    • Login/Logout (if done via the API) by using POST

(Wouldn't have any problem to provide a merge request, but maybe it is a conscious decision to NOT fit REST guidelines?)

ueberfuhr avatar Dec 05 '23 06:12 ueberfuhr

How about adding a comment to the readme that this is an example of a real world api and not an example of good api design.

There are for example conflicts and edge cases like:

  • username login or logout
  • update pet with POST and update user with PUT
  • two pet updates routes that do the same.

mknj avatar Jul 09 '24 11:07 mknj

Wow, in my real world, there are always good API designs! 😇😂

The pet store is the default sample in the Swagger Editor. And this is used esp. for (good) API design. So beginners might copy and customize fragments from this sample into their own API. Not a good role model... 😵😉

ralf-ueberfuhr-ars avatar Jul 09 '24 12:07 ralf-ueberfuhr-ars