{
    "swagger": "2.0",
    "info": {
        "version": "1.0.0",
        "title": "PizzaShackAPI",
        "description": "This document describe a ** RESTFul API ** for ** Pizza Shack** online pizza delivery store.\n",
        "contact": {
            "name": "PizzaShack",
            "url": "http://PizzaShack.lk",
            "email": "architecture@PizzaShack.com"
        },
        "license": {
            "name": "Apache 2.0",
            "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
        }
    },
    "consumes": [
        "application/json"
    ],
    "produces": [
        "application/json"
    ],
    "schemes": [
        "https"
    ],
    "paths": {
        "/menu": {
            "get": {
                "description": "Return a list of available menu items",
                "parameters": [
                    {
                        "name": "limit",
                        "in": "query",
                        "description": "Maximum size of API array to return.",
                        "default": 25,
                        "type": "number",
                        "format": "double"
                    },
                    {
                        "name": "offset",
                        "in": "query",
                        "description": "Starting point of the item list.",
                        "default": 0,
                        "type": "number",
                        "format": "double"
                    },
                    {
                        "name": "query",
                        "in": "query",
                        "description": "Search by menu item name or ingredients\n",
                        "type": "string"
                    },
                    {
                        "name": "Accept",
                        "in": "header",
                        "description": "Media types for the response. Should denote XML or JSON, default is JSON.",
                        "type": "string"
                    },
                    {
                        "name": "Content-Type",
                        "in": "header",
                        "description": "Media type of the entity in the request body. Should denote XML or JSON, default is JSON.",
                        "type": "string"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK. List of APIs is returned.",
                        "schema": {
                            "title": "Menu",
                            "type": "object",
                            "properties": {
                                "count": {
                                    "type": "string"
                                },
                                "next": {
                                    "type": "string",
                                    "description": "Link for next page. Undefined if no next page."
                                },
                                "previous": {
                                    "type": "string",
                                    "description": "Link for previous page. Undefined if no previous page."
                                },
                                "list": {
                                    "type": "array",
                                    "items": {
                                        "$ref": "#/definitions/MenuItem"
                                    }
                                }
                            }
                        },
                        "headers": {
                            "Content-Type": {
                                "description": "The content type of the body.",
                                "type": "string"
                            },
                            "ETag": {
                                "description": "Entity Tag of the response resource. Used by caches, or in conditional requests.",
                                "type": "string"
                            }
                        }
                    },
                    "304": {
                        "description": "Not Modified. Empty body because the client has already the latest version of the requested resource."
                    },
                    "406": {
                        "description": "Not Acceptable. The requested media type is not supported",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            }
        },
        "/order": {
            "post": {
                "description": "Create a new Order",
                "parameters": [
                    {
                        "in": "body",
                        "name": "body",
                        "description": "Order object that needs to be added",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/Order"
                        }
                    },
                    {
                        "name": "Content-Type",
                        "in": "header",
                        "description": "Media type of the entity in the request body. Should denote XML or JSON, default is JSON.",
                        "type": "string"
                    }
                ],
                "responses": {
                    "201": {
                        "description": "Created. Successful response with the newly created object as entity in the body. Location header contains URL of newly created entity.",
                        "schema": {
                            "$ref": "#/definitions/Order"
                        },
                        "headers": {
                            "Location": {
                                "description": "The URL of the newly created resource.",
                                "type": "string"
                            },
                            "Content-Type": {
                                "description": "The content type of the body.",
                                "type": "string"
                            },
                            "ETag": {
                                "description": "Entity Tag of the response resource. Used by caches, or in conditional request",
                                "type": "string"
                            }
                        }
                    },
                    "400": {
                        "description": "Bad Request. Invalid request or validation error.",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    },
                    "415": {
                        "description": "Unsupported Media Type. The entity of the request was in a not supported format.",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            }
        },
        "/order/{orderId}": {
            "get": {
                "description": "Get details of an Order",
                "parameters": [
                    {
                        "name": "orderId",
                        "in": "path",
                        "description": "Order Id",
                        "required": true,
                        "type": "number",
                        "format": "integer"
                    },
                    {
                        "name": "Accept",
                        "in": "header",
                        "description": "Media types for the response. Should denote XML or JSON, default is JSON.",
                        "type": "string"
                    },
                    {
                        "name": "If-None-Match",
                        "in": "header",
                        "description": "Validator for conditional requests; based on ETag.",
                        "type": "string"
                    },
                    {
                        "name": "If-Modified-Since",
                        "in": "header",
                        "description": "Validator for conditional requests; based on Last Modified header.",
                        "type": "string"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK Requested Order will be returned",
                        "headers": {
                            "Content-Type": {
                                "description": "The content type of the body.",
                                "type": "string"
                            },
                            "ETag": {
                                "description": "Entity Tag of the response resource. Used by caches, or in conditional requests.",
                                "type": "string"
                            },
                            "Last-Modified": {
                                "description": "Date and time the resource has been modifed the last time. Used by caches, or in conditional reuquests.",
                                "type": "string"
                            }
                        },
                        "schema": {
                            "$ref": "#/definitions/Order"
                        }
                    },
                    "304": {
                        "description": "Not Modified. Empty body because the client has already the latest version of the requested resource."
                    },
                    "404": {
                        "description": "Not Found. Requested API does not exist.",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    },
                    "406": {
                        "description": "Not Acceptable. The requested media type is not supported",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            },
            "put": {
                "description": "Update an existing Order",
                "parameters": [
                    {
                        "name": "orderId",
                        "in": "path",
                        "description": "Order Id",
                        "required": true,
                        "type": "number",
                        "format": "integer"
                    },
                    {
                        "in": "body",
                        "name": "body",
                        "description": "API object that needs to be added",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/Order"
                        }
                    },
                    {
                        "name": "Content-Type",
                        "in": "header",
                        "description": "Media type of the entity in the request body. Should denote XML or JSON, default is JSON.",
                        "type": "string"
                    },
                    {
                        "name": "If-Match",
                        "in": "header",
                        "description": "Validator for conditional requests; based on ETag.",
                        "type": "string"
                    },
                    {
                        "name": "If-Unmodified-Since",
                        "in": "header",
                        "description": "Validator for conditional requests; based on Last Modified header.",
                        "type": "string"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK. Successful response with updated Order",
                        "schema": {
                            "$ref": "#/definitions/Order"
                        },
                        "headers": {
                            "Location": {
                                "description": "The URL of the newly created resource.",
                                "type": "string"
                            },
                            "Content-Type": {
                                "description": "The content type of the body.",
                                "type": "string"
                            },
                            "ETag": {
                                "description": "Entity Tag of the response resource. Used by caches, or in conditional request",
                                "type": "string"
                            },
                            "Last-Modified": {
                                "description": "Date and time the resource has been modifed the last time. Used by caches, or in conditional reuquests.",
                                "type": "string"
                            }
                        }
                    },
                    "400": {
                        "description": "Bad Request. Invalid request or validation error",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    },
                    "404": {
                        "description": "Not Found. The resource to be updated does not exist.",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    },
                    "412": {
                        "description": "Precondition Failed. The request has not been performed because one of the preconditions is not met.",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            },
            "delete": {
                "description": "Delete an existing Order",
                "parameters": [
                    {
                        "name": "orderId",
                        "in": "path",
                        "description": "Order Id",
                        "required": true,
                        "type": "number",
                        "format": "integer"
                    },
                    {
                        "name": "If-Match",
                        "in": "header",
                        "description": "Validator for conditional requests; based on ETag.",
                        "type": "string"
                    },
                    {
                        "name": "If-Unmodified-Since",
                        "in": "header",
                        "description": "Validator for conditional requests; based on Last Modified header.",
                        "type": "string"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK. Resource successfully deleted."
                    },
                    "404": {
                        "description": "Not Found. Resource to be deleted does not exist.",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    },
                    "412": {
                        "description": "Precondition Failed. The request has not been performed because one of the preconditions is not met.",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            }
        },
        "/deliver-order": {
            "get": {
                "description": "Get Available List of Orders to delivery.",
                "parameters": [
                    {
                        "name": "Accept",
                        "in": "header",
                        "description": "Media types for the response. Should denote XML or JSON, default is JSON.",
                        "type": "string"
                    },
                    {
                        "name": "If-None-Match",
                        "in": "header",
                        "description": "Validator for conditional requests; based on ETag.",
                        "type": "string"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK List of tiers returned.",
                        "schema": {
                            "type": "array",
                            "items": {
                                "$ref": "#/definitions/Order"
                            }
                        },
                        "headers": {
                            "Content-Type": {
                                "description": "The content type of the body.",
                                "type": "string"
                            },
                            "ETag": {
                                "description": "Entity Tag of the response resource. Used by caches, or in conditional requests.",
                                "type": "string"
                            }
                        }
                    },
                    "304": {
                        "description": "Not Modified. Empty body because the client has already the latest version of the requested resource."
                    },
                    "406": {
                        "description": "Not Acceptable. The requested media type is not supported",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "MenuItem": {
            "title": "Pizza menu Item",
            "required": [
                "name"
            ],
            "properties": {
                "name": {
                    "type": "string"
                },
                "description": {
                    "type": "string"
                },
                "price": {
                    "type": "string"
                },
                "image": {
                    "type": "string"
                }
            }
        },
        "Order": {
            "title": "Pizza Order",
            "required": [
                "orderId"
            ],
            "properties": {
                "orderId": {
                    "type": "integer"
                },
                "pizzaType": {
                    "type": "string"
                },
                "quantity": {
                    "type": "number"
                },
                "customerName": {
                    "type": "string"
                },
                "creditCardNumber": {
                    "type": "string"
                },
                "address": {
                    "type": "string"
                },
                "delivered": {
                    "type": "boolean"
                }
            }
        },
        "Error": {
            "title": "Error object returned with 4XX HTTP status",
            "required": [
                "code",
                "message"
            ],
            "properties": {
                "code": {
                    "type": "integer",
                    "format": "int64"
                },
                "message": {
                    "type": "string",
                    "description": "Error message."
                },
                "description": {
                    "type": "string",
                    "description": "A detail description about the error message."
                },
                "moreInfo": {
                    "type": "string",
                    "description": "Preferably an url with more details about the error."
                },
                "error": {
                    "type": "array",
                    "description": "If there are more than one error list them out. Ex. list out validation errors by each field.",
                    "items": {
                        "$ref": "#/definitions/ErrorListItem"
                    }
                }
            }
        },
        "ErrorListItem": {
            "title": "Description of individual errors that may have occored during a request.",
            "required": [
                "code",
                "message"
            ],
            "properties": {
                "code": {
                    "type": "integer",
                    "format": "int64"
                },
                "message": {
                    "type": "string",
                    "description": "Description about individual errors occored"
                }
            }
        }
    }
}