ttomtsis / newspaper-app

Complex Spring Boot REST API with MySQL Database, Tests and RBAC
1 stars 0 forks source link

Questions regarding API design #6

Closed ttomtsis closed 1 year ago

ttomtsis commented 1 year ago

This issue is referenced in Issue #3

1) Should the state changing endpoints be grouped under a single endpoint ?

HTTP methods should solely indicate the type of operation performed on the resource, so cannot group the reject endpoints ( which delete a resource ) under the same mapping

2) Is it better to use the PATCH http method when updating a single field like state ?

The PATCH method will be used when updating the state of an entity

ttomtsis commented 1 year ago

3) When should the PATCH HTTP method be used ?

4) Merge modify topic and update topic state into a single PUT endpoint ? PUT /topics/ {id}

Will not merge endpoints for the following reasons:

5) When updating the state of the topic, should the client request include an entire representation of the new Topic ?

If using PATCH to update the state, simply include the state field, else if using PUT include the entire object in the body

ttomtsis commented 1 year ago

6) Create a DELETE mapping in order to reject ( delete ) comments, topics and stories ?

DELETE mapping created, also removed the REJECTED state.

Previous implementation violated the principle: HTTP Methods should be idempotent