Author - Mercy Awopetu Tolulope
This documentation provides instructions on how to use and interact with the API endpoints created
- URL:
/api/{name} - Method:
GET - Description: Retrieves details of a person by their name.
- Request Parameters:
{name}(String) -Name of the person - Sample Request:
curl -X GET http://localhost:8080/api/john - Expected Response (200 OK):
[
{
"id": 1,
"name": "John Doe"
}
]- URL:
/api/{user_id} - Method:
GET - Description: Retrieves details of a person by their ID.
- Request Parameters:
{user_id}(Long) -User ID of the person - Sample Request:
curl -X GET http://localhost:8080/api/1 - Expected Response (200 OK):
[
{
"id": 1,
"name": "John Doe"
}
]- URL:
/api/ - Method:
POST - Description: Creates a new person.
- Request Body: JSON object with
name(String) - Sample Request:
curl -X POST -H "Content-Type: application/json" -d '{"name": "Alice Johnson"}' http://localhost:8080/api - Expected Response (201 Created):
[
{
"id": 4,
"name": "Alice Johnson"
}
]- URL:
/api/{user_id} - Method:
PUT - Description: Updates details of an existing person by their ID.
- Request Parameters:
{id}(Long) - ID of the person. - Request Body: JSON object with updated
name(String). - Sample Request:
curl -X PUT -H "Content-Type: application/json" -d '{"name": "Alice Smith"}' http://localhost:8080/api/4 - Expected Response (200 OK)
{
"id": 4,
"name": "Alice Smith",
"age": 26
}URL: /api/{user_id}
- Method:
DELETE - Description: Deletes details of a person by their ID.
- Request Parameters:
{id}(Long) - ID of the person. - Sample Request:
curl -X DELETE http://localhost:8080/api/4 - Expected Response (204 No Content): No response body
- Error handling and validation for other use cases are not extensively covered in this API but should be implemented for a production-ready API
- The name property is not sufficient enough to describe a person, other properties should be added on in the future.
To set up and deploy the API follow these steps:
- Clone the GitHub Repository: Link to Repository.
- Navigate to the project directory.
- Configure your database connection in
application.properties. - Build the project using maven or your preferred build tool.
- Run the application.
- Your API should be accessible at http://localhost:8080/api
For more detailed instructions on how to interact with the endpoints, please refer to the README.md in the repository
Live Link to the API: Link
A link to the UML Class Diagram can also be found here: UML Diagram