GithubHelp home page GithubHelp logo

marthak1 / recipe-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cbfacademy/recipe-api

0.0 0.0 0.0 122 KB

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

License: MIT License

Java 100.00%

recipe-api's Introduction

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.

recipe-api's People

Contributors

solangeug avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.