Skip to content

cbfacademy/recipe-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A Cooking Recipe API

Java Language JVM Platform JUnit5 Testing Framework Maven Dependency Manager Spring Boot

The purpose of this project is to build a simple web (JSON over HTTP) API to manage recipes, following a test-driven development approach.

We want to ensure that the emphasis is on practicing all the concepts covered during the course. Therefore, in building this simple API, we will focus on happy path scenarios only.

Note: for brevity, not all ingredients and instructions are displayed in the examples below.

Retrieve recipes

As a user (through a client of this web API)
I want to be able to retrieve all the recipes
So that I can choose what I will cook today.

Example

Given there are 2 recipes in our recipe management system
When I request to see their details via the GET /recipes endpoint
Then I should get a 200 OK HTTP response with:

[
    {
        "id": 1,
        "name": "Creamy courgette lasagne",
        "ingredients": [
            {
                "name": "dried lasagne sheets",
                "quantity": "9"
            },
            {
                "name": "courgette coarsely grated",
                "quantity": "700g (about 6)"
            }
        ],
        "instructions": "Heat oven to 220C/fan 200C/gas 7. Put a pan of water on to boil, then cook the lasagne sheets for about 5 mins until softened, but not cooked through..."
    },
    {
        "id": 2,
        "name": "Blackberry pie",
        "ingredients": [
            {
                "name": "blackberries",
                "quantity": "600g"
            },
            {
                "name": "self-raising flour",
                "quantity": "300g (plus extra for dusting)"
            }
        ],
        "instructions": "First, make the pastry. Tip both flours and the sugar into a bowl with a large pinch of salt..."
    }
]

Create a recipe

As a user (through a client of this web API)
I want to be able to create a new recipe as needed
So that I add to my collection of recipes.

Example

Given the ingredients and instructions of a new recipe below
When I request to create a new recipe via the POST /recipes endpoint
Then I should get a 201 CREATED HTTP response.

{
    "name": "Aubergine parmigiana lasagne",
    "ingredients": [
        {
            "name": "large aubergines, trimmed and thinly sliced lengthways",
            "quanity": "3"
        },
        {
            "name": "vegetarian mozzarella, drained and coarsely grated",
            "quanity": "250g"
        }
    ],
    "instructions": "Heat a griddle or large frying pan over a medium-high heat. Brush the aubergine slices on both sides with the olive oil and season with a little salt, then griddle in batches until the slices are softened and slightly charred..."
}

Change a recipe

As a user (through a client of this web API)
I want to be able to edit a recipe
So that I keep an accurate record of my recipes.

Examples

Given the new (partial) instructions of an existing recipe below
When I request to update a recipe via the PUT /recipes/{id} endpoint
Then I should get a 204 NO CONTENT HTTP response.

{
    "name": "Aubergine parmigiana lasagne",
    "instructions": "Heat a griddle or large frying pan over a medium-high heat. Brush the aubergine slices on both sides with the olive oil and season with a little salt, then griddle in batches until the slices are softened and slightly charred (ensure the heat isn’t too high or the aubergine will char before it softens). Transfer the cooked slices to a plate as you go..."
}

Given the updated list of ingredients of an existing recipe below
When I request to update a recipe via the PUT /recipes/{id} endpoint
Then I should get a 204 NO CONTENT HTTP response.

{
    "name": "Aubergine parmigiana lasagne",
    "ingredients": [
        {
            "name": "garlic cloves, finely sliced",
            "quanity": "6"
        },
        {
            "name": "chopped tomatoes",
            "quanity": "3 x 400g cans"
        }
    ]
}

Delete a recipe

As a user (through a client of this web API)
I want to be able to delete a recipe
When I no longer need it.

Example

Given a recipe we no longer need in our system
When I request to delete it via the DELETE /recipes/{id} endpoint
Then I should get a 204 NO CONTENT response.

About

A simple web (JSON over HTTP) API to manage cooking recipes.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages