MerryFairyTalesAD440 / API

1 stars 2 forks source link

BookId should not be changeble (PUT book) #95

Closed mcontado closed 5 years ago

mcontado commented 5 years ago

Steps to Repro:

  1. Post book https://melanieoneboxfunctionsprint3.azurewebsites.net/v1/books With the following request: { "title": "Test", "description": "TEST", "cover_image": "https://myimage", "author": "TEST" }

  2. Got a response of the bookId returned: bc9e0b1c-d51e-4bcb-a569-2efa122c3a38

  3. PUT /book https://melanieoneboxfunctionsprint3.azurewebsites.net/v1/books/bc9e0b1c-d51e-4bcb-a569-2efa122c3a38 With the following request: { "id":"changeID", "title": "Test", "description": "TEST", "cover_image": "https://myimage", "author": "TEST" }

  4. Got a response of the following book object: { "id": "changeID", "description": "TEST", "author": "TEST", "cover_image": "https://myimage", "title": "Test", "pages": null }

Just an opinion: When updating the book, it's better to only update all fields other than id. Reason is the user can use the existing id and we may have duplicated IDs.

Fremonster commented 5 years ago

Validation has been added to fix this bug.