540co/ads-bpa

View on GitHub
server/routes/swagger.json

Summary

Maintainability
Test Coverage
{
  "swagger": "2.0",
  "info": {
    "version": "1.0.0",
    "description": ""
  },
  "host": "",
  "basePath": "/api",
  "schemes": [
    ""
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "paths": {
    "/reactions": {
      "get": {
        "description": "Get list of reactions that are currently available withing the reaction lookup dictionary",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "The total number of reactions that will be returned (default = 25, limit = 200)",
            "required": false,
            "type": "integer"
          },
          {
            "name": "offset",
            "in": "query",
            "description": "The offset to pagination thru the results",
            "required": false,
            "type": "integer"
          }
        ],
        "operationId": "getReactionList",
        "produces": [
          "application/json"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "required": [
                "meta",
                "data"
              ],
              "title": " ",
              "properties": {
                "meta": {
                  "description": "Object container for request metadata",
                  "required": [
                    "total_count",
                    "execution_time"
                  ],
                  "title": "Meta",
                  "properties": {
                    "limit": {
                      "description": "The limit used when making the request based upon what was passed in or defaults",
                      "type": "String"
                    },
                    "offset": {
                      "description": "The offset used when making the request based upon what was passed in or defaults",
                      "type": "String"
                    },
                    "total_count": {
                      "description": "The total count of reactions available",
                      "type": "integer"
                    },
                    "execution_time": {
                      "description": "Amount of time to make the request",
                      "type": "String"
                    }
                  }
                },
                "data": {
                  "description": "Object container for response data",
                  "type": "array",
                  "items": {
                    "$ref": "#/definitions/Reaction"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid header (requires application/json)"
          },
          "404": {
            "description": "Reactions not found (will occur it an offset < 0 is provided)"
          },
          "[all errors]": {
            "description": "All errors",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        },
        "tags": [
          "reactions"
        ]
      },
      "post": {
        "description": "Post a new reaction.  API will reach out to possible definition sources and create definition list.",
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "description": "The reaction term you would like created - {\"reaction\":\"death\"}",
            "required": true
          }
        ],
        "operationId": "postReactionTerm",
        "produces": [
          "application/json"
        ],
        "responses": {
          "200": {
            "description": "OK - definition has been successfully created (will return the reaction definitions found for the reaction term)",
            "schema": {
              "required": [
                "meta",
                "data"
              ],
              "title": " ",
              "properties": {
                "meta": {
                  "description": "Object container for request metadata",
                  "required": [
                    "execution_time"
                  ],
                  "title": "Meta",
                  "properties": {
                    "execution_time": {
                      "description": "Amount of time to make the request",
                      "type": "String"
                    }
                  }
                },
                "data": {
                  "description": "Object container for response data",
                  "$ref": "#/definitions/Reaction"
                }
              }
            }
          },
          "400": {
            "description": "Duplicate - definition already exists"
          },
          "[all errors]": {
            "description": "All errors",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        },
        "tags": [
          "reactions"
        ]
      }
    },
    "/reactions/{reaction}": {
      "get": {
        "description": "Get definition of specfied reaction term",
        "parameters": [
          {
            "name": "reaction",
            "in": "path",
            "description": "The reaction term",
            "required": true,
            "type": "string"
          }
        ],
        "operationId": "getReactionTerm",
        "produces": [
          "application/json"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "required": [
                "meta",
                "data"
              ],
              "title": " ",
              "properties": {
                "meta": {
                  "description": "Object container for request metadata",
                  "required": [
                    "execution_time"
                  ],
                  "title": "Meta",
                  "properties": {
                    "execution_time": {
                      "description": "Amount of time to make the request",
                      "type": "String"
                    }
                  }
                },
                "data": {
                  "$ref": "#/definitions/Reaction",
                  "description": "Object container for response data"
                }
              }
            }
          },
          "400": {
            "description": "Invalid header (requires application/json)"
          },
          "404": {
            "description": "Reaction term definitions not found"
          },
          "[all errors]": {
            "description": "All errors",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        },
        "tags": [
          "reactions"
        ]
      },
      "delete": {
        "description": "Delete specific reaction term from dictionary including all definitons and votes",
        "parameters": [
          {
            "name": "reaction",
            "in": "path",
            "description": "The reaction term",
            "required": true,
            "type": "string"
          }
        ],
        "operationId": "deleteReaction",
        "produces": [
          "application/json"
        ],
        "responses": {
          "204": {
            "description": "Delete was successful (no additional content will be provided in response body)"
          },
          "400": {
            "description": "Invalid header (requires application/json)"
          },
          "[all errors]": {
            "description": "All errors",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        },
        "tags": [
          "reactions"
        ]
      }
    },
    "/reactions/{reaction}/definitions": {
      "post": {
        "description": "Post definition to a pre-existing reaction",
        "parameters": [
          {
            "name": "reaction",
            "in": "path",
            "description": "The reaction term",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "description": "The definition - {\"definition\":\"lorem ipsum\"}",
            "required": true
          }
        ],
        "operationId": "createReactionDefinition",
        "produces": [
          "application/json"
        ],
        "responses": {
          "200": {
            "description": "OK (will return the updated reaction with all definitions)",
            "schema": {
              "required": [
                "meta",
                "data"
              ],
              "title": " ",
              "properties": {
                "meta": {
                  "description": "Object container for request metadata",
                  "required": [
                    "execution_time"
                  ],
                  "title": "Meta",
                  "properties": {
                    "execution_time": {
                      "description": "Amount of time to make the request",
                      "type": "String"
                    }
                  }
                },
                "data": {
                  "$ref": "#/definitions/Reaction",
                  "description": "Object container for response data"
                }
              }
            }
          },
          "400": {
            "description": "bad request (missing attributes, bad content-type)"
          },
          "422": {
            "description": "duplicate definition provide (no definition will be added)"
          },
          "[all errors]": {
            "description": "All errors",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        },
        "tags": [
          "reactions"
        ]
      }
    },
    "/reactions/{reaction}/definitions/{index}": {
      "put": {
        "description": "Increase the up / down vote count for a specific definition {index} of a specific {reaction}",
        "parameters": [
          {
            "name": "reaction",
            "in": "path",
            "description": "The reaction term",
            "required": true,
            "type": "string"
          },
          {
            "name": "index",
            "in": "path",
            "description": "The definition index (based upon the order shown in the GET /reaction response - starts with 0)",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "description": "The vote to be increased - {\"vote\":\"up\"} or {\"vote\":\"down\"}",
            "required": true
          }
        ],
        "operationId": "updateReactionDefinitionVote",
        "produces": [
          "application/json"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "required": [
                "meta",
                "data"
              ],
              "title": " ",
              "properties": {
                "meta": {
                  "description": "Object container for request metadata",
                  "required": [
                    "execution_time"
                  ],
                  "title": "Meta",
                  "properties": {
                    "execution_time": {
                      "description": "Amount of time to make the request",
                      "type": "String"
                    }
                  }
                },
                "data": {
                  "$ref": "#/definitions/Reaction",
                  "description": "Object container for response data"
                }
              }
            }
          },
          "400": {
            "description": "Bad request (missing attributes, bad content-type)"
          },
          "404": {
            "description": "Reaction could not be found"
          },
          "[all errors]": {
            "description": "All errors",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        },
        "tags": [
          "reactions"
        ]
      }
    },
    "/searches": {
      "get": {
        "description": "Get list of search terms that have been submitted and the total count (ordered from descending order)",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "The total number of reactions that will be returned (default = 25, limit = 200)",
            "required": false,
            "type": "integer"
          },
          {
            "name": "offset",
            "in": "query",
            "description": "The offset to pagination thru the results",
            "required": false,
            "type": "integer"
          }
        ],
        "operationId": "getDRESearchMetrics",
        "produces": [
          "application/json"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "required": [
                "meta",
                "data"
              ],
              "title": " ",
              "properties": {
                "meta": {
                  "description": "Object container for request metadata",
                  "required": [
                    "total_count",
                    "execution_time"
                  ],
                  "title": "Meta",
                  "properties": {
                    "limit": {
                      "description": "The limit used when making the request based upon what was passed in or defaults",
                      "type": "String"
                    },
                    "offset": {
                      "description": "The offset used when making the request based upon what was passed in or defaults",
                      "type": "String"
                    },
                    "total_count": {
                      "description": "The total count of unique search terms that have been captured",
                      "type": "integer"
                    },
                    "execution_time": {
                      "description": "Amount of time to make the request",
                      "type": "String"
                    }
                  }
                },
                "data": {
                  "description": "Object container for response data",
                  "type": "array",
                  "items": {
                    "$ref": "#/definitions/Search"
                  }
                }
              }
            }
          },
          "404": {
            "description": "No results found (can occur when there is a bad offset)"
          },
          "[all errors]": {
            "description": "All errors",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        },
        "tags": [
          "searches"
        ]
      },
      "post": {
        "description": "Post search term to increase counter",
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "description": "The search term- {\"search\":\"ibuprofen\"}",
            "required": true
          }
        ],
        "operationId": "postDRESearchMetrics",
        "produces": [
          "application/json"
        ],
        "responses": {
          "200": {
            "description": "OK - search term count was incremented",
            "schema": {
              "required": [
                "meta",
                "data"
              ],
              "title": " ",
              "properties": {
                "meta": {
                  "description": "Object container for request metadata",
                  "required": [
                    "execution_time"
                  ],
                  "title": "Meta",
                  "properties": {
                    "execution_time": {
                      "description": "Amount of time to make the request",
                      "type": "String"
                    }
                  }
                },
                "data": {
                  "description": "Object container for response data",
                  "$ref": "#/definitions/Search"
                }
              }
            }
          },
          "400": {
            "description": "bad request (missing attributes, bad content-type)"
          },
          "[all errors]": {
            "description": "All errors",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        },
        "tags": [
          "searches"
        ]
      }
    }
  },
  "definitions": {
    "Search": {
      "required": [
        "search",
        "count"
      ],
      "properties": {
        "search": {
          "description": "The unique search term",
          "type": "string"
        },
        "count": {
          "description": "The total number of times that search term has been searched",
          "type": "integer"
        }
      }
    },
    "Definition": {
      "required": [
        "definition",
        "source",
        "created_at",
        "votes"
      ],
      "properties": {
        "definition": {
          "type": "string",
          "description": "The definition text"
        },
        "source": {
          "type": "string",
          "description": "The source of the definition - at this time the list of values include wordnik.com, dictionaryapi.com or dre_app (when a user enters a definition via the DRE app)"
        },
        "created_at": {
          "type": "integer",
          "description": "Timestamp of when the definition was added to the reaction"
        },
        "votes": {
          "$ref": "#/definitions/Votes"
        }
      }
    },
    "Votes": {
      "required": [
        "ups",
        "downs"
      ],
      "properties": {
        "ups": {
          "type": "integer",
          "description": "Count of up votes"
        },
        "downs": {
          "type": "integer",
          "description": "Count of down votes"
        }
      }
    },
    "Reaction": {
      "required": [
        "reaction",
        "definitions",
        "last_updated"
      ],
      "properties": {
        "reaction": {
          "type": "string",
          "description": "The reaction term"
        },
        "definitions": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/Definition"
          }
        },
        "last_updated": {
          "type": "integer",
          "description": "Timestamp of when the reaction record was last updated"
        }
      }
    },
    "Error": {
      "required": [
        "error",
        "message"
      ],
      "properties": {
        "error": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      }
    }
  }
}