{
  "swagger": "2.0",
  "info": {
    "version": "1.0.1",
    "title": "UpPeat API Specification",
    "description": "Specification for UpPeat API",
    "termsOfService": "http://swagger.io/terms/"
  },
  "basePath": "/uppeat",
  "tags" : [
    {
        "name": "Users", 
        "description": "CRUD operations for the User data"
    },
    {
        "name": "Distilleries", 
        "description": "CRUD operations for the Distillery data"
    },
    {
        "name": "Whiskeys", 
        "description": "CRUD operations for the Whiskey data"
    },
    {
        "name": "Locations", 
        "description": "CRUD operations for the Location data"
    },
    {
        "name": "Ratings", 
        "description": "CRUD operations for the Rating data"
    }
  ],
  "schemes": [
    "http"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "paths": {
    "/users": {
        "get":{
            "tags": ["Users"],
            "description": "Returns a list of all users",
            "operationId": "find",
            "produces": [
            "application/json"
            ],
            "responses": {
                "200": {
                "description": "response",
                "schema": {
                    "$ref": "#/definitions/user_schema"
                    }
                }
            }
        },
       "post": {
          "tags": ["Users"],
          "description": "Adds a new user",
          "operationId": "save",
          "produces": [
            "application/json"
          ],
          "parameters": [
              {
                "name": "user",
                "in": "body",
                "description": "The user to create",
                "required": true,
              "schema": {
                "$ref": "#/definitions/user_schema"
                }
            }
          ],
          "responses": {
            "200": {
              "description": "The created user",
              "schema": {
                 "$ref": "#/definitions/user_schema"
              }
            }
          }
        }
    },
    "/users/username/{user_name}": {
        "put": {
            "tags": ["Users"],
            "description": "Updates the given user (must be logged in as this user)",
            "operationId": "findOneAndUpdate",
            "produces": [
                "application/json"
            ],
            "parameters": [
            {
                "name": "user_name",
                "in": "query",
                "description": "The user name of the user to update",
                "required": true,
                "type": "string"
            },
            {
                "name": "user",
                "in": "body",
                "description": "The user details to update",
                "required": true,
                "schema": {
                    "$ref": "#/definitions/user_schema"
                }
            }
          ],
          "responses": {
            "200": {
                "description": "The updated user",
                "schema": {
                    "$ref": "#/definitions/user_schema"
                }
            },
            "403": {
                "description": "No user logged in or different user logged in",
                "schema":{
                    "$ref":"#/definitions/forbidden"
                    }
                }
            }
        },
        "delete":{
            "tags":["Users"],
            "description":"Deletes a user (must be logged in as this user)",
            "operationId":"findOneAndUpdate",
            "produces": [
            "application/json"
            ],
            "parameters":[
                {
                    "name": "user_name",
                    "in": "query",
                    "description": "The user name of the user to delete",
                    "required": true,
                    "type": "string"
                }
            ],
            "responses": {
            "200": {
                "description": "Delete response",
                "schema":{
                "$ref":"#/definitions/user_deleted"
                }
            },
            "403": {
                "description": "No user logged in or different user logged in",
                "schema":{
                    "$ref":"#/definitions/forbidden"
                }
            }
          }
        },
        "get":{
            "tags": ["Users"],
            "description": "Returns the given user (must be logged in as this user)",
            "operationId": "findById",
            "produces": [
            "application/json"
            ],
            "parameters":[
                {
                    "name": "user_name",
                    "in": "query",
                    "description": "The user name of the user to find",
                    "required": true,
                    "type": "string"
                }
            ],
            "responses": {
                "200": {
                    "description": "response",
                    "schema": {
                        "$ref": "#/definitions/user_schema"
                        }
                },
                "403": {
                    "description": "No user logged in or different user logged in",
                    "schema":{
                        "$ref":"#/definitions/forbidden"
                    }
                }
            }
        }
    },
    "/users/{_id}": {
        "put": {
            "tags": ["Users"],
            "description": "Updates the given user (must be logged in as this user)",
            "operationId": "findOneAndUpdate",
            "produces": [
                "application/json"
            ],
            "parameters": [
            {
                "name": "_id",
                "in": "query",
                "description": "The ObjectId(_id) of the user to update",
                "required": true,
                "type": "string"
            },
            {
                "name": "user",
                "in": "body",
                "description": "The user details to update",
                "required": true,
                "schema": {
                    "$ref": "#/definitions/user_schema"
                }
            }
          ],
          "responses": {
            "200": {
              "description": "The updated user",
              "schema": {
                 "$ref": "#/definitions/user_schema"
              }
            },
            "403": {
                "description": "No user logged in or different user logged in",
                "schema":{
                    "$ref":"#/definitions/forbidden"
                }
            }
          }
        },
        "delete":{
            "tags":["Users"],
            "description":"Deletes a user (must be logged in as this user)",
            "operationId":"findOneAndUpdate",
            "produces": [
            "application/json"
            ],
            "parameters":[
                {
                    "name": "_id",
                    "in": "query",
                    "description": "The ObjectId(_id) of the user to delete",
                    "required": true,
                    "type": "string"
                }
            ],
            "responses": {
            "200": {
                "description": "Delete response",
                "schema":{
                "$ref":"#/definitions/user_deleted"
                }
            },
            "403": {
                "description": "No user logged in or different user logged in",
                "schema":{
                    "$ref":"#/definitions/forbidden"
                }
            }
          }
        },
        "get":{
            "tags": ["Users"],
            "description": "Returns the given user (must be logged in as this user)",
            "operationId": "findById",
            "produces": [
            "application/json"
            ],
            "parameters":[
                {
                    "name": "_id",
                    "in": "query",
                    "description": "The ObjectId(_id) of the user to find",
                    "required": true,
                    "type": "string"
                }
            ],
            "responses": {
                "200": {
                "description": "response",
                "schema": {
                    "$ref": "#/definitions/user_schema"
                    }
                },
                "403": {
                    "description": "No user logged in or different user logged in",
                    "schema":{
                        "$ref":"#/definitions/forbidden"
                    }
                }
            }
        }
      },
    "/users/{_id}/ratings": {
        "get":{
            "tags": ["Users"],
            "description": "Returns the ratings for the given user",
            "operationId": "findById",
            "produces": [
            "application/json"
            ],
            "parameters":[
                {
                    "name": "_id",
                    "in": "query",
                    "description": "The ObjectId(_id) of the user to find ratings for",
                    "required": true,
                    "type": "string"
                }
            ],
            "responses": {
                "200": {
                "description": "response",
                "schema": {
                    "$ref": "#/definitions/rating_schema"
                    }
                }
            }
        }
    },
    "/users/login": {
        "post": {
            "tags": ["Users"],
            "description": "Logs in the given user",
            "operationId": "login",
            "produces": [
                "application/json"
            ],
            "parameters": [
            {
                "name": "user_name",
                "in": "body",
                "description": "The user name of the user to login",
                "required": true,
                "type": "string"
            },
            {
                "name": "password",
                "in": "body",
                "description": "The password to log in with",
                "required": true,
                "type": "string"
            }
          ],
          "responses": {
            "200": {
                "description": "The logged in user",
                "schema": {
                    "$ref": "#/definitions/user_schema"
                }
            },
            "500": {
                "description": "Reason the login failed",
                "properties": {
                    "message": {
                    "type": "string",
                    "example" : "User account is locked out"
                    }
                }
            } 
        }
      }
    },
    "/users/signup": {
        "post": {
            "tags": ["Users"],
            "description": "Signs up a new user",
            "operationId": "signup",
            "produces": [
                "application/json"
            ],
            "parameters": [
            {
                "name": "user",
                "in": "body",
                "description": "The user to sign up with as the plain JSON body",
                "required": true,
                "schema": {
                    "$ref": "#/definitions/user_schema"
                }
            }
          ],
          "responses": {
            "200": {
                "description": "The signed up user",
                "schema": {
                    "$ref": "#/definitions/user_schema"
                }
            },
            "500": {
                "description": "Reason the sign up failed",
                "properties": {
                    "message": {
                    "type": "string",
                    "example" : "User name already exists"
                    }
            }
          }
        }
      }
    },
    "/users/logout": {
        "post": {
            "tags": ["Users"],
            "description": "Logs out the current user",
            "operationId": "logout",
            "produces": [
                "application/json"
            ],
          "responses": {
            "200": {
                "description": "Confirmation of logout",
                "properties": {
                    "message": {
                    "type": "string",
                    "example" : "User logged out"
                    }
                }
            }
          }
        }
      },
    "/distilleries": {
        "get":{
            "tags": ["Distilleries"],
            "description": "Returns a list of all distilleries",
            "operationId": "find",
            "produces": [
            "application/json"
            ],
            "responses": {
                "200": {
                "description": "response",
                "schema": {
                    "$ref": "#/definitions/distillery_schema"
                    }
                }
            }
        },
       "post": {
          "tags": ["Distilleries"],
          "description": "Adds a new distillery",
          "operationId": "save",
          "produces": [
            "application/json"
          ],
          "parameters": [
              {
                "name": "distillery",
                "in": "body",
                "description": "The distillery to create",
                "required": true,
              "schema": {
                "$ref": "#/definitions/distillery_schema"
                }
            }
          ],
          "responses": {
            "200": {
              "description": "The created distillery",
              "schema": {
                 "$ref": "#/definitions/distillery_schema"
              }
            }
          }
        }
    },
    "/distilleries/{_id}": {
        "put": {
            "tags": ["Distilleries"],
            "description": "Updates the given distillery",
            "operationId": "findOneAndUpdate",
            "produces": [
                "application/json"
            ],
            "parameters": [
            {
                "name": "_id",
                "in": "query",
                "description": "The ObjectId(_id) of the distillery to update",
                "required": true,
                "type": "string"
            },
            {
                "name": "distillery",
                "in": "body",
                "description": "The distillery details to update",
                "required": true,
                "schema": {
                    "$ref": "#/definitions/distillery_schema"
                }
            }
          ],
          "responses": {
            "200": {
              "description": "The updated distillery",
              "schema": {
                 "$ref": "#/definitions/distillery_schema"
              }
            }
          }
        },
        "delete":{
            "tags":["Distilleries"],
            "description":"Deletes a distillery",
            "operationId":"findOneAndUpdate",
            "produces": [
            "application/json"
            ],
            "parameters":[
                {
                    "name": "_id",
                    "in": "query",
                    "description": "The ObjectId(_id) of the distillery to delete",
                    "required": true,
                    "type": "string"
                }
            ],
            "responses": {
            "200": {
                "description": "Delete response",
                "schema":{
                "$ref":"#/definitions/distillery_deleted"
                }
            }
          }
        },
        "get":{
            "tags": ["Distilleries"],
            "description": "Returns the given distillery",
            "operationId": "findById",
            "produces": [
            "application/json"
            ],
            "parameters":[
                {
                    "name": "_id",
                    "in": "query",
                    "description": "The ObjectId(_id) of the distillery to find",
                    "required": true,
                    "type": "string"
                }
            ],
            "responses": {
                "200": {
                "description": "response",
                "schema": {
                    "$ref": "#/definitions/distillery_schema"
                    }
                }
            }
        }
    },
    "/distilleries/{distilleryId}/whiskeys": {
        "get":{
            "tags": ["Distilleries"],
            "description": "Returns the whiskeys for the given distillery",
            "operationId": "find",
            "produces": [
            "application/json"
            ],
            "parameters":[
                {
                    "name": "distilleryId",
                    "in": "query",
                    "description": "The ObjectId(_id) of the distillery to find whiskeys for",
                    "required": true,
                    "type": "string"
                }
            ],
            "responses": {
                "200": {
                "description": "response",
                "schema": {
                    "$ref": "#/definitions/whiskey_schema"
                    }
                }
            }
        }
    },
    "/whiskeys": {
        "get":{
            "tags": ["Whiskeys"],
            "description": "Returns a list of all whiskeys",
            "operationId": "find",
            "produces": [
            "application/json"
            ],
            "responses": {
                "200": {
                "description": "response",
                "schema": {
                    "$ref": "#/definitions/whiskey_schema"
                    }
                }
            }
        },
       "post": {
          "tags": ["Whiskeys"],
          "description": "Adds a new whiskey",
          "operationId": "save",
          "produces": [
            "application/json"
          ],
          "parameters": [
              {
                "name": "whiskey",
                "in": "body",
                "description": "The whiskey to create",
                "required": true,
              "schema": {
                "$ref": "#/definitions/whiskey_schema"
                }
            }
          ],
          "responses": {
            "200": {
              "description": "The created whiskey",
              "schema": {
                 "$ref": "#/definitions/whiskey_schema"
              }
            }
          }
        }
    },
    "/whiskeys/{_id}": {
        "put": {
            "tags": ["Whiskeys"],
            "description": "Updates the given whiskey",
            "operationId": "findOneAndUpdate",
            "produces": [
                "application/json"
            ],
            "parameters": [
            {
                "name": "_id",
                "in": "query",
                "description": "The ObjectId(_id) of the whiskey to update",
                "required": true,
                "type": "string"
            },
            {
                "name": "whiskey",
                "in": "body",
                "description": "The whiskey details to update",
                "required": true,
                "schema": {
                    "$ref": "#/definitions/whiskey_schema"
                }
            }
          ],
          "responses": {
            "200": {
              "description": "The updated whiskey",
              "schema": {
                 "$ref": "#/definitions/whiskey_schema"
              }
            }
          }
        },
        "delete":{
            "tags":["Whiskeys"],
            "description":"Deletes a whiskey",
            "operationId":"findOneAndUpdate",
            "produces": [
                "application/json"
            ],
            "parameters":[
                {
                    "name": "_id",
                    "in": "query",
                    "description": "The ObjectId(_id) of the whiskey to delete",
                    "required": true,
                    "type": "string"
                }
            ],
            "responses": {
            "200": {
                "description": "Delete response",
                "schema":{
                "$ref":"#/definitions/whiskey_deleted"
                }
            }
          }
        },
        "get":{
            "tags": ["Whiskeys"],
            "description": "Returns the given whiskey",
            "operationId": "findById",
            "produces": [
                "application/json"
            ],
            "parameters":[
                {
                    "name": "_id",
                    "in": "query",
                    "description": "The ObjectId(_id) of the whiskey to find",
                    "required": true,
                    "type": "string"
                }
            ],
            "responses": {
                "200": {
                "description": "response",
                "schema": {
                    "$ref": "#/definitions/whiskey_schema"
                    }
                }
            }
        }
    },
    "/whiskeys/{_id}/ratings": {
        "get":{
            "tags": ["Whiskeys"],
            "description": "Returns the ratings for the given whiskey",
            "operationId": "findById",
            "produces": [
                "application/json"
            ],
            "parameters":[
                {
                    "name": "_id",
                    "in": "query",
                    "description": "The ObjectId(_id) of the whiskey to find ratings for",
                    "required": true,
                    "type": "string"
                }
            ],
            "responses": {
                "200": {
                "description": "response",
                "schema": {
                    "$ref": "#/definitions/rating_schema"
                    }
                }
            }
        }
    },
    "/locations": {
        "get":{
            "tags": ["Locations"],
            "description": "Returns a list of all locations",
            "operationId": "find",
            "produces": [
            "application/json"
            ],
            "responses": {
                "200": {
                "description": "response",
                "schema": {
                    "$ref": "#/definitions/location_schema"
                    }
                }
            }
        },
       "post": {
          "tags": ["Locations"],
          "description": "Adds a new location",
          "operationId": "save",
          "produces": [
            "application/json"
          ],
          "parameters": [
              {
                "name": "location",
                "in": "body",
                "description": "The location to create",
                "required": true,
              "schema": {
                "$ref": "#/definitions/location_schema"
                }
            }
          ],
          "responses": {
            "200": {
              "description": "The created location",
              "schema": {
                 "$ref": "#/definitions/location_schema"
              }
            }
          }
        }
    },
    "/locations/{_id}": {
        "put": {
            "tags": ["Locations"],
            "description": "Updates the given location",
            "operationId": "findOneAndUpdate",
            "produces": [
                "application/json"
            ],
            "parameters": [
            {
                "name": "_id",
                "in": "query",
                "description": "The ObjectId(_id) of the location to update",
                "required": true,
                "type": "string"
            },
            {
                "name": "location",
                "in": "body",
                "description": "The location details to update",
                "required": true,
                "schema": {
                    "$ref": "#/definitions/location_schema"
                }
            }
          ],
          "responses": {
            "200": {
              "description": "The updated location",
              "schema": {
                 "$ref": "#/definitions/location_schema"
              }
            }
          }
        },
        "delete":{
            "tags":["Locations"],
            "description":"Deletes a location",
            "operationId":"findOneAndUpdate",
            "produces": [
            "application/json"
            ],
            "parameters":[
                {
                    "name": "_id",
                    "in": "query",
                    "description": "The ObjectId(_id) of the location to delete",
                    "required": true,
                    "type": "string"
                }
            ],
            "responses": {
            "200": {
                "description": "Delete response",
                "schema":{
                "$ref":"#/definitions/location_deleted"
                }
            }
          }
        },
        "get":{
            "tags": ["Locations"],
            "description": "Returns the given location",
            "operationId": "findById",
            "produces": [
            "application/json"
            ],
            "parameters":[
                {
                    "name": "_id",
                    "in": "query",
                    "description": "The ObjectId(_id) of the location to find",
                    "required": true,
                    "type": "string"
                }
            ],
            "responses": {
                "200": {
                "description": "response",
                "schema": {
                    "$ref": "#/definitions/location_schema"
                    }
                }
            }
        }
    },
    "/locations/{_id}/ratings": {
        "get":{
            "tags": ["Locations"],
            "description": "Returns the ratings for the given location",
            "operationId": "findById",
            "produces": [
            "application/json"
            ],
            "parameters":[
                {
                    "name": "_id",
                    "in": "query",
                    "description": "The ObjectId(_id) of the location to find ratings for",
                    "required": true,
                    "type": "string"
                }
            ],
            "responses": {
                "200": {
                "description": "response",
                "schema": {
                    "$ref": "#/definitions/rating_schema"
                    }
                }
            }
        }
    },
    "/ratings": {
        "get":{
            "tags": ["Ratings"],
            "description": "Returns a list of all ratings",
            "operationId": "find",
            "produces": [
            "application/json"
            ],
            "responses": {
                "200": {
                "description": "response",
                "schema": {
                    "$ref": "#/definitions/rating_schema"
                    }
                }
            }
        },
       "post": {
          "tags": ["Ratings"],
          "description": "Adds a new rating",
          "operationId": "save",
          "produces": [
            "application/json"
          ],
          "parameters": [
              {
                "name": "rating",
                "in": "body",
                "description": "The rating to create",
                "required": true,
              "schema": {
                "$ref": "#/definitions/rating_schema"
                }
            }
          ],
          "responses": {
            "200": {
              "description": "The created rating",
              "schema": {
                 "$ref": "#/definitions/rating_schema"
              }
            }
          }
        }
    },
    "/ratings/{_id}": {
        "put": {
            "tags": ["Ratings"],
            "description": "Updates the given rating (must be logged in as the user who created the rating)",
            "operationId": "findOneAndUpdate",
            "produces": [
                "application/json"
            ],
            "parameters": [
            {
                "name": "_id",
                "in": "query",
                "description": "The ObjectId(_id) of the rating to update",
                "required": true,
                "type": "string"
            },
            {
                "name": "rating",
                "in": "body",
                "description": "The rating details to update",
                "required": true,
                "schema": {
                    "$ref": "#/definitions/rating_schema"
                }
            },
            {
                "name": "user_id",
                "in": "query",
                "description": "The ObjectId(_id) of the user who is editing the rating",
                "required": true,
                "type": "string"
            }
          ],
          "responses": {
            "200": {
              "description": "The updated rating",
                "schema": {
                    "$ref": "#/definitions/rating_schema"
                }
            },
            "403": {
                "description": "User forbidden from deleting rating",
                "schema":{
                    "$ref":"#/definitions/forbidden"
                }
            },
            "404": {
                "description": "User or rating not found",
                "properties": {
                    "message": {
                    "type": "string",
                    "example" : "No rating found with given details"
                    }
                }
            }
          }
        },
        "delete":{
            "tags":["Ratings"],
            "description":"Deletes a rating (must be logged in as the user who created the rating)",
            "operationId":"findOneAndUpdate",
            "produces": [
            "application/json"
            ],
            "parameters":[
                {
                    "name": "_id",
                    "in": "query",
                    "description": "The ObjectId(_id) of the rating to delete",
                    "required": true,
                    "type": "string"
                },
                {
                    "name": "user_id",
                    "in": "query",
                    "description": "The ObjectId(_id) of the user who is deleting the rating",
                    "required": true,
                    "type": "string"
                }
            ],
            "responses": {
            "200": {
                "description": "Delete response",
                "schema":{
                    "$ref":"#/definitions/rating_deleted"
                },
            },
            "403": {
                "description": "User forbidden from deleting rating",
                "schema":{
                    "$ref":"#/definitions/forbidden"
                },
            },
            "404": {
                "description": "User or rating not found",
                "properties": {
                    "message": {
                    "type": "string",
                    "example" : "No rating found with given details"
                    }
                }
            }
          }
        },
        "get":{
            "tags": ["Ratings"],
            "description": "Returns the given rating",
            "operationId": "findById",
            "produces": [
            "application/json"
            ],
            "parameters":[
                {
                    "name": "_id",
                    "in": "query",
                    "description": "The ObjectId(_id) of the rating to find",
                    "required": true,
                    "type": "string"
                }
            ],
            "responses": {
                "200": {
                "description": "response",
                "schema": {
                    "$ref": "#/definitions/rating_schema"
                    }
                }
            }
        }
    }
  },
  "definitions": {
    "user_schema": {
        "properties": {
                "first_name": {
                "required":true,
                "type": "string",
                "example": "Joe"
            },
                "surname": {
                "required":true,
                "type": "string",
                "example": "Bloggs"
            },
                "full_name": {
                "type": "string",
                "example": "Joe Bloggs",
                "description": "Automatically generated property, not passed in"
            },
                "user_name": {
                "required":true,
                "type": "string",
                "pattern": "/^[a-zA-Z0-9_]*$/",
                "minLength": 5,
                "maxLength": 20,
                "example": "Joe_Bloggs99"
            },
                "email": {
                "required":true,
                "type": "string",
                "pattern": "/^([\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4})?$/",
                "example": "joe@bloggs.com"
            },
                "password": {
                "required":true,
                "type": "string",
                "minLength": 5,
                "maxLength": 20,
                "pattern": "/^(?=.*[a-zA-Z_])(?=.*[0-9_]+).*$/",
                "example": "joe_999"
            },
                "ctime": {
                    "$ref": "#/definitions/ctime"
            },
                "mtime": {
                    "$ref": "#/definitions/mtime"
            },
                "loginAttempts": {
                "required":true,
                "type": "number",
                "default": 0
            },
                "lockUntil": {
                "type": "number"
            },
                "isLocked": {
                "type": "boolean"
            }
        }
    },
    "distillery_schema": {
        "properties": {
                "name": {
                "required":true,
                "type": "string",
                "example": "Joe's Distillery"
            },
                "description": {
                "type": "string"
            },
                "location_id" : {
                "type": "string",
                "description": "The ObjectId (_id) of the location where the distillery is based"
            },
                "ctime": {
                    "$ref": "#/definitions/ctime"
            },
                "mtime": {
                    "$ref": "#/definitions/mtime"
            },
                "tags": {
                    "$ref": "#/definitions/tags"
            },
                "links": {
                    "$ref": "#/definitions/links"
            }
        }
    },
    "whiskey_schema": {
        "properties": {
                "name": {
                "required":true,
                "type": "string",
                "example": "Joe's 10 Year Whiskey"
            },
                "abv": {
                "required":true,
                "type": "number",
                "minimum": 0,
                "maximum": 100
            },
                "distillery_id": {
                "required":true,
                "type": "string",
                "description": "The ObjectId (_id) of the distillery the whiskey belongs to"
            },
                "ctime": {
                    "$ref": "#/definitions/ctime"
            },
                "mtime": {
                    "$ref": "#/definitions/mtime"
            },
                "tags": {
                    "$ref": "#/definitions/tags"
            },
                "description": {
                "type": "string"
            },
                "type": {
                "required":true,
                "type": "string",
                "enum": ["malt", "grain", "blended", "single pot", "bourbon", "tennessee", "rye", "corn"]
            }
        }
    },
    "rating_schema": {
        "properties": {
                "rating": {
                "required":true,
                "type": "number",
                "minimum": 0,
                "maximum": 10
            },
                "comments": {
                "type": "string"
            },
                "whiskey_id": {
                "required":true,
                "type": "string",
                "description": "The ObjectId (_id) of the whiskey being rated"
            },
                "created_by": {
                "type": "string",
                "description": "The ObjectId (_id) of the user adding the rating (set automatically when creating and editing ratings)"
            },
                "tags": {
                    "$ref": "#/definitions/tags"
            },
                "location_id" : {
                "type": "string",
                "description": "The ObjectId (_id) of the location where the rating was added"
            },
                "profile": {
                    "appearance": {
                        "properties": {
                            "colour": "string",
                            "clarity": "string",
                            "viscosity": "string"
                        }
                    },
                        "nose": {
                        "type": "string"
                    },
                        "palate": {
                        "type": "string"
                    },
                        "finish": {
                        "type": "string"
                    },
                        "base_notes": {
                        "type": "string"
                    }
            },
                "ctime": {
                    "$ref": "#/definitions/ctime"
            },
                "mtime": {
                    "$ref": "#/definitions/mtime"
            }
        }
    },
    "location_schema": {
        "properties": {
                "name": {
                "required": true,
                "type": "string"
            },
                "description": {
                "type": "string"
            },
                "place_id" : {
                "type": "string",
                "description": "The maps place id for this location"
            },
                "ctime": {
                    "$ref": "#/definitions/ctime"
            },
                "mtime": {
                    "$ref": "#/definitions/mtime"
            },
                "tags": {
                    "$ref": "#/definitions/tags"
            },
                "distillery_ids" : {
                    "description": "An array of distilleries distilling from this location by ObjectId (_id)",
                    "properties": {
                        "tag": "string"
                    },
                    "type": "array"
            }
        }
    },
    "tags" : {
        "description": "An array of tagged strings",
        "properties": {
            "tag": "string"
        },
        "type": "array"
    },
    "ctime" : {
        "description": "Time of creation",
        "properties": {
            "ctime": {
                "type": "datetime"
            }
        }
    },
    "mtime" : {
        "description": "Time of last modification",
        "properties": {
            "mtime": {
                "type": "datetime"
            }
        }
    },
    "user_deleted" : {
       "properties": {
        "message": {
          "type": "string",
          "example" : "User successfully deleted"
        }
      }
    },
    "distillery_deleted" : {
       "properties": {
        "message": {
          "type": "string",
          "example" : "Distillery successfully deleted"
        }
      }
    },
    "whiskey_deleted" : {
       "properties": {
        "message": {
          "type": "string",
          "example" : "Whiskey successfully deleted"
        }
      }
    },
    "location_deleted" : {
       "properties": {
        "message": {
          "type": "string",
          "example" : "Location successfully deleted"
        }
      }
    },
    "rating_deleted" : {
       "properties": {
        "message": {
          "type": "string",
          "example" : "Rating successfully deleted"
        }
      }
    },
    "forbidden" : {
       "properties": {
        "message": {
          "type": "string",
          "example" : "User does not have permission to delete this data"
        }
      }
    },
    "links" : {
       "properties": {
        "twitter": {
          "type": "string"
        },
        "facebook": {
          "type": "string"
        },
        "instagram": {
          "type": "string"
        },
        "website": {
          "type": "string"
        },
        "foursquare": {
          "type": "string"
        },
        "yelp": {
          "type": "string"
        }
      }
    }
  }
}