REST API Reference๏
The API is documented interactively via Springdoc OpenAPI and is always in sync with the source code.
Swagger UI (Live)๏
When the application is running locally:
http://localhost:8080/swagger-ui.html
The OpenAPI JSON specification can be downloaded from:
http://localhost:8080/v3/api-docs
Endpoints Summary๏
Books๏
Method |
Path |
Description |
|---|---|---|
|
|
List all books |
|
|
Get book by ID |
|
|
Add a new book |
|
|
Update a book |
|
|
Delete a book |
Users๏
Method |
Path |
Description |
|---|---|---|
|
|
List all users |
|
|
Get user by ID |
|
|
Register a new user |
|
|
Delete a user |
Borrowings๏
Method |
Path |
Description |
|---|---|---|
|
|
List all borrowings |
|
|
Borrow a book |
|
|
Return a borrowed book |
|
|
Get borrowings for a user |
Request / Response Examples๏
Borrow a book๏
Request:
POST /api/borrowings
Content-Type: application/json
{
"userId": 1,
"bookId": 42
}
Response 201 Created:
{
"id": 7,
"userId": 1,
"bookId": 42,
"borrowDate": "2025-04-20",
"returnDate": null,
"status": "BORROWED"
}
Return a book๏
PUT /api/borrowings/7/return
Response 200 OK:
{
"id": 7,
"returnDate": "2025-04-22",
"status": "RETURNED"
}