Project from the online course Spring Framework 5: Beginner to Guru by John Thompson — Section 26.
- Introduction
- New Spring Boot Project
- Creating Data Model and Repositories
- Create Vendor Data Model, Populate Data
- Create Category Controller
- Testing Category Controller
- Create Get Endpoints for Vendors
- Create Category with POST
- Update Category with PUT
- Implement POST for Vendors
- Implement PUT for Vendors
- Update Category with PATCH
- Implement PATCH for Vendors
- Conclusion
- Project: Gradle
- Java: 11
- Spring Boot: 2.5.0
- Dependencies
- Spring Data Reactive MongoDB
- Spring Reactive Web
- Spring Boot Starter Test
- Embedded MongoDB Database
- Reactor Test
- Lombok
- Spring Boot DevTools
- Spring Security
- Plugins
- Spring Boot
- Spring Dependency Management
- Java
- JaCoCo
Retrieves a list of all customers.
GET /api/v1/customers
[
{
"id": "614bf84ede8d0275d4cdc884",
"first_name": "Alice",
"last_name": "Foo"
},
{
"id": "614bf8c8de8d0275d4cdc886",
"first_name": "Bob",
"last_name": "Bar"
}
]
Retrieves one customer.
GET /api/v1/customers/:id
{
"id": "60c060942f63c12e4a1bb782",
"first_name": "First",
"last_name": "Last"
}
Add a new customer to the application.
POST /api/v1/customers
{
"name": "Test"
}
Update customer information by ID or create a new customer if the ID does not exist.
PUT /api/v1/customers/:id
{
"name": "Updated or Created Customer"
}
{
"id": "614bf84bde8d0275d4cdc883",
"name": "Updated or Created Customer"
}
Update existing customer information by ID.
PATCH /api/v1/customers/:id
{
"name": "Updated Customer"
}
{
"id": "614bf84bde8d0275d4cdc883",
"name": "Updated Customer"
}
If the customer does not exist, the server returns a 500 Internal Server Error.
Retrieves a list of all categories.
GET /api/v1/categories
[
{
"id": "60c060942f63c12e4a1bb77d",
"name": "Category A"
},
{
"id": "60c060942f63c12e4a1bb77e",
"name": "Category B"
}
]
Retrieves one category.
GET /api/v1/categories/:id
{
"id": "60c060942f63c12e4a1bb77d",
"name": "Category"
}
Add a new category to the application.
POST /api/v1/categories
{
"first_name": "Test",
"last_name": "Test"
}
Update category information by ID or create a new category if the ID does not exist.
PUT /api/v1/categories/:id
{
"first_name": "Updated or Created",
"last_name": "Category"
}
{
"id": "614bf84ede8d0275d4cdc884",
"first_name": "Updated or Created",
"last_name": "Category"
}
Update existing category information by ID.
PATCH /api/v1/categories/:id
{
"first_name": "Updated",
"last_name": "Category"
}
{
"id": "614bf84ede8d0275d4cdc884",
"first_name": "Updated",
"last_name": "Category"
}
If the category does not exist, the server returns a 500 Internal Server Error.
API deployed on Heroku