To read about hexagonal architecture : https://www.urbanisation-si.com/architecture-hexagonale-un-exemple-de-mise-en-pratique-de-la-methode-ddd-domain-driven-design-1
- Spring Web
- Spring Data JPA
- Hibernate validator
- Lombok
- MapsStruct
- H2 database
Use this endpoint: http://localhost:8080/v1/books
Body value :
{
"name": "Java for beginners",
"description": "Java for beginners",
"numberOfPages": 20
}
Use this endpoint: http://localhost:8080/v1/books/:id
where id
is the identifier of book.
Response:
{
"id": 1,
"name": "Java for beginners",
"description": "Java for beginners",
"numberOfPages": 20
}
Try to create a book with numberOfPages
less than 5 or greater than 200, you should receive Bad request
error.
Request :
{
"name": "Java for beginners",
"description": "Java for beginners",
"numberOfPages": 2
}
Response:
400 Bad Request
{
"date": "2022-06-21T12:02:42.934",
"message": "Validation Failed",
"details": [
"A Book should have 5 or more than 5 pages"
]
}