Skip to content

Instantly share code, notes, and snippets.

@Faerbit

Faerbit/specs.md Secret

Created June 28, 2015 13:54

#Specs for Todobackend

This documents describes the specification covered by the tests. The URL schema used in the example is completely fictional. The tests actually doesn't impose any kind of URL schema so designing a URL schema is entirely up to you.

##API root

###GET

A GET request to the API root returns an array of all todo entries. A todo entry consist of three properties:

Property Description
title String which describes what needs to be done.
completed Boolean which describes if the task has been done.
url String which contains a URL to the entry object.
order Optional integer which specifies a priority of the task.

####Example Response:

[
    {
        "completed": false,
        "title": "Stuff",
        "url": "http://todobackend.com/1"
    },
    {
        "completed": false,
        "order": 15,
        "title": "More stuff",
        "url": "http://todobackend.com/2"
    }
]

###POST

A POST request to the API root which contains a new entry object will return the newly created entry object and add the new todo entry to the database on success.

A new todo entry must include a title and can include a order property.

New todo entries always have a completed property set to false.

Should return HTTP status code 400 with an error description if the request if malformed(no valid JSON, type error, ...).

####Example Request:

{
    "title": "Different stuff"
}

Response:

{
    "completed": false,
    "title": "Different stuff",
    "url": "http://todobackend.com/3"
}

###DELETE

A DELETE request to the API root deletes all todo entries in the database and returns a empty array.

####Example Response:

[]

##Entry URL The entry URL is the URL described by the url property.

###GET

A GET request to the entry URL return the entry.

####Example Response:

{
    "completed": false,
    "order": 15,
    "title": "More stuff",
    "url": "http://todobackend.com/2"
}

###PATCH

A PATCH request to the entry URL allows changing the properties of entry objects.

You can change the following properties:

  • completed
  • order
  • title

The new state of the todo entry is returned.

Should return HTTP status code 400 with an error description if the request if malformed(no valid JSON, type error, ...).

####Example Request:

{
    "title": "Not so much stuff",
    "order": 13
}

Response:

{
    "completed": false,
    "order": 13,
    "title": "Not so much stuff",
    "url": "http://todobackend.com/2"
}

###DELETE

A DELETE request to the entry url deletes the specified todo entry.

####Example Response:

{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment