Skip to content

vacoola1/restaurantvote

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pandoc -f docbook -t asciidoc api.xml -o api.txt

RESTful "Restaurant vote" API Documentation (generated by Spring restdocs)

Maven/ Spring/ JPA(Hibernate)/ Spring MVC/ REST(Jackson)/ JUnit/ Spring rest docs.

The task is:
Maven/ Spring/ JPA(Hibernate)/ Spring MVC/ REST(Jackson)/ JUnit/ Spring rest docs.

Design and implement a JSON API using Hibernate/Spring/SpringMVC without frontend.

    Build a voting system for deciding where to have lunch.
    - 2 types of users: admin and regular users
    - Admin can input a restaurant and it's lunch menu of the day (2-5 items usually, just a dish name and price)
    - Menu changes each day (admins do the updates)
    - Users can vote on which restaurant they want to have lunch at
    - Only one vote counted per user
    - If user votes again the same day:
    - If it is before 11:00 we asume that he changed his mind.
    - If it is after 11:00 then it is too late, vote can't be changed

    Each restaurant provides new menu each day.

    P.S.: Asume that your API will used by a frontend developer to build frontend on top of that.

HTTP verbs

RESTful notes tries to adhere as closely as possible to standard HTTP and REST conventions in its use of HTTP verbs.

Verb Usage

GET

Used to retrieve a resource

POST

Used to create a new resource

PATCH

Used to update an existing resource, including partial updates

DELETE

Used to delete an existing resource

HTTP status codes

RESTful notes tries to adhere as closely as possible to standard HTTP and REST conventions in its use of HTTP status codes.

Status code Usage

200 OK

The request completed successfully

201 Created

A new resource has been created successfully. The resource’s URI is available from the response’s Location header

204 No Content

An update to an existing resource has been applied successfully

400 Bad Request

The request was malformed. The response body will include an error providing further information

404 Not Found

The requested resource did not exist

Hypermedia

RESTful Notes uses hypermedia and resources include links to other resources in their responses. Responses are in Hypertext Application from resource to resource. Language (HAL) format. Links can be found beneath the _links key. Users of the API should not create URIs themselves, instead they should use the above-described links to navigate

Resources

Restaurants

The Notes resources is used to create and list notes

Creating a restaurant

A POST request is used to cratee a restaurant

Request structure
Path Type Description

name

String

Name of the restaurant

Example request
$ curl 'http://localhost:8080/rest/admin/restaurants/' -i -X POST -H 'Content-Type: application/json;charset=UTF-8' -d '{
  "name" : "Шотиииииии"
}'
Example response
HTTP/1.1 201 Created
Location: http://localhost:8080/rest/admin/restaurants/100029
Content-Type: application/json;charset=UTF-8
Content-Length: 57

{
  "id" : 100029,
  "name" : "Шотиииииии"
}

About

Restaurant vote

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors