andela/magma-backend

View on GitHub
src/config/swagger.json

Summary

Maintainability
Test Coverage
{
  "swagger": "2.0",
  "info": {
    "title": "Barefoot Normad API Documentation",
    "version": "1.0.0",
    "description": "Documentation to test the endpoints for the Barefoot Normad API"
  },
  "host": "localhost:5000",
  "basePath": "/api/v1",
  "tags": [
    {
      "name": "auth",
      "description": "Create account and login"
    },
    {
      "name": "request",
      "description": "Make travel requests"
    }
  ],
  "schemes": ["https", "http"],
  "securityDefinitions": {
    "Bearer": {
      "type": "apiKey",
      "name": "Authorization",
      "in": "header"
    }
  },
  "paths": {
    "/users/signup": {
      "post": {
        "tags": ["auth"],
        "summary": "Creates a new user",
        "description": "This endpoint registers a new user",
        "operationId": "createUser",
        "consumes": ["application/json"],
        "produces": ["application/json"],
        "security": [],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "description": "Information needed to create a user",
            "required": true,
            "schema": {
              "$ref": "#/definitions/Signup"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "user account created successfully",
            "schema": {
              "$ref": "#/definitions/AuthResponse"
            }
          },
          "409": {
            "description": "email already in use"
          },
          "400": {
            "description": "email is required, and should follow this format: myemail@domain.com"
          }
        }
      }
    },
    "/users/verifyEmail/:token": {
      "get": {
        "tags": ["auth"],
        "summary": "Verify email",
        "description": "This endpoint verify a new user's email address",
        "operationId": "verifyUser",
        "consumes": ["string"],
        "produces": "Update database",
        "security": [],
        "parameters": [
          {
            "in": "email",
            "name": "token",
            "description": "Contains email and id",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "Your account has been verified"
          }
        }
      }
    },
    "/users/signin": {
      "post": {
        "tags": ["auth"],
        "summary": "Signs in a verified user",
        "description": "This endpoint signs in a verified user",
        "operationId": "loginUser",
        "consumes": ["application/json"],
        "produces": ["application/json"],
        "security": [],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "description": "Information needed for login",
            "required": true,
            "schema": {
              "$ref": "#/definitions/Signin"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Login successful.",
            "schema": {
              "$ref": "#/definitions/AuthResponse"
            }
          },
          "404": {
            "description": "Your email cannot be found in our database."
          },
          "401": {
            "description": "Your password is incorrect."
          }
        }
      }
    },
    "/requests": {
      "post": {
        "tags": ["request"],
        "summary": "Book a travel request",
        "description": "This endpoint books a one-way trip request",
        "operationId": "bookTrip",
        "consumes": ["application/json"],
        "produces": ["application/json"],
        "security": [
          {
            "Bearer": []
          }
        ],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "description": "data needed to book a trip",
            "required": true,
            "schema": {
              "$ref": "#/definitions/BookTrip"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "message created successfully",
            "schema": {
              "$ref": "#/definitions/RequestResponse"
            }
          },
          "400": {
            "description": "departureDate is required"
          },
          "409": {
            "description": "you already have a trip booked around this period, you may choose to cancel and make a multi-city request"
          }
        }
      }
    }
  },
  "definitions": {
    "Signup": {
      "type": "object",
      "properties": {
        "firstName": {
          "type": "string"
        },
        "lastName": {
          "type": "string"
        },
        "email": {
          "type": "string"
        },
        "password": {
          "type": "string",
          "format": "password"
        }
      }
    },
    "Signin": {
      "type": "object",
      "properties": {
        "email": {
          "type": "string"
        },
        "password": {
          "type": "string",
          "format": "password"
        }
      }
    },
    "BookTrip": {
      "type": "object",
      "properties": {
        "origin": {
          "type": "string"
        },
        "destination": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": ["one-way", "return"]
        },
        "departureDate": {
          "type": "string",
          "format": "date"
        },
        "returnDate": {
          "type": "string",
          "format": "date"
        },
        "reason": {
          "type": "string"
        },
        "accommodation": {
          "type": "string"
        }
      }
    },
    "AuthResponse": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string"
        },
        "data": {
          "type": "object",
          "items": {
            "properties": {
              "token": {
                "type": "string"
              },
              "id": {
                "type": "integer",
                "format": "int64"
              },
              "email": {
                "type": "string"
              },
              "firstName": {
                "type": "string"
              },
              "lastName": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "RequestResponse": {
      "type": "object",
      "properties": {
        "status": {
          "type": "string"
        },
        "data": {
          "type": "object",
          "items": {
            "properties": {
              "origin": {
                "type": "string"
              },
              "destination": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": ["one-way", "return"]
              },
              "departureDate": {
                "type": "string",
                "format": "date"
              },
              "returnDate": {
                "type": "string",
                "format": "date"
              },
              "reason": {
                "type": "string"
              },
              "accommodation": {
                "type": "string"
              },
              "status": {
                "type": "string",
                "enum": ["open", "closed"]
              }
            }
          }
        }
      }
    }
  }
}