Implement an endpoint to update an existing book record in the database. The endpoint should validate input and only update the specified book.
User Story
Given a book already exists
When I send a request to update the book
Then the book record should be updated in the database
Endpoint
Request Body
{
"name": "Updated Book Name",
"author": ["Updated Author"],
"price": 150,
"publisher": "Updated Publisher"
}
Validation Rules
-
id (from params)
-
name
-
author
-
price
-
publisher
Tasks
Acceptance Criteria
Testing Steps
Definition of Done
Implement an endpoint to update an existing book record in the database. The endpoint should validate input and only update the specified book.
User Story
Given a book already exists
When I send a request to update the book
Then the book record should be updated in the database
Endpoint
Request Body
{ "name": "Updated Book Name", "author": ["Updated Author"], "price": 150, "publisher": "Updated Publisher" }Validation Rules
id(from params)nameauthorpricepublisherTasks
Create
PUT /book/:idrouteCreate/update controller for edit functionality
Validate route param (
id)Validate request body fields
Check if book exists
404 Not Foundif not existsUpdate record in
bookstableReturn success response
Add Swagger documentation
Acceptance Criteria
400 Bad Request404 Not FoundTesting Steps
Create a book (via POST
/book)Copy its
idSend PUT request to:
Provide updated fields
Verify response is
200 OKRun SQL query:
Confirm fields are updated correctly
Definition of Done