{
  "swagger": "2.0",
  "info": {
    "version": "1.0.0",
    "title": "Deno oak starter API",
    "contact": {
      "email": "asad.dk.bd@gmail.com"
    }
  },
  "host": "localhost:8000",
  "tags": [
    {
      "name": "Auth",
      "description": "JWT authentication"
    },
    {
      "name": "Users",
      "description": "User enity CRUD operation"
    }
  ],
  "schemes": [
    "http"
  ],
  "securityDefinitions": {
    "BearerAuth": {
      "type": "apiKey",
      "in": "header",
      "name": "Authorization"
    }
  },
  "paths": {
    "/login": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "User login",
        "operationId": "login",
        "consumes": [
          "application/json"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/LoginCredential"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "successful operation",
            "schema": {
              "$ref": "#/definitions/AuthToken"
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "401": {
            "description": "Unauthorized"
          }
        }
      }
    },
    "/register": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "Register end user",
        "operationId": "register",
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/UserRegistration"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "successful operation",
            "schema": {
              "$ref": "#/definitions/UserModel"
            }
          },
          "400": {
            "description": "Invalid request"
          }
        }
      }
    },
    "/users": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "List user list",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Get list of users, called by admin user",
        "operationId": "getUserList",
        "produces": [
          "application/json"
        ],
        "responses": {
          "200": {
            "description": "successful operation",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/UserModel"
              }
            }
          },
          "401": {
            "description": "Unauthorized user"
          }
        }
      }
    },
    "/users/{userId}": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "Find user by userId",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Get users, called by admin user",
        "operationId": "getUserById",
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "description": "ID of user to return",
            "required": true,
            "type": "integer",
            "format": "int64"
          }
        ],
        "responses": {
          "200": {
            "description": "successful operation",
            "schema": {
              "$ref": "#/definitions/UserModel"
            }
          },
          "401": {
            "description": "Unauthorized user"
          },
          "404": {
            "description": "User not found"
          }
        }
      },
      "put": {
        "tags": [
          "Users"
        ],
        "summary": "Update user by userId",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Get users, called by admin user",
        "operationId": "updateUser",
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "description": "ID of user to return",
            "required": true,
            "type": "integer",
            "format": "int64"
          },
          {
            "in": "body",
            "name": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/UserUpdateData"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "successful operation",
            "schema": {
              "$ref": "#/definitions/UserModel"
            }
          },
          "401": {
            "description": "Unauthorized user"
          },
          "404": {
            "description": "User not found"
          }
        }
      },
      "delete": {
        "tags": [
          "Users"
        ],
        "summary": "Delete user by userId",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "description": "Delete users, called by admin user",
        "operationId": "deleteUser",
        "produces": [
          "application/json"
        ],
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "description": "ID of user to return",
            "required": true,
            "type": "integer",
            "format": "int64"
          }
        ],
        "responses": {
          "204": {
            "description": "successful operation"
          }
        }
      }
    }
  },
  "definitions": {
    "LoginCredential": {
      "type": "object",
      "properties": {
        "email": {
          "type": "string",
          "format": "string"
        },
        "password": {
          "type": "string",
          "format": "string"
        }
      }
    },
    "AuthToken": {
      "type": "object",
      "properties": {
        "access_token": {
          "type": "string",
          "format": "string"
        },
        "refresh_token": {
          "type": "string",
          "format": "string"
        }
      }
    },
    "UserRegistration": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "format": "string"
        },
        "email": {
          "type": "string",
          "format": "string"
        },
        "password": {
          "type": "string",
          "format": "string"
        }
      }
    },
    "UserUpdateData": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "format": "string"
        },
        "email": {
          "type": "string",
          "format": "string"
        }
      }
    },
    "UserModel": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer",
          "format": "int32"
        },
        "name": {
          "type": "string",
          "format": "string"
        },
        "email": {
          "type": "string",
          "format": "string"
        },
        "roles": {
          "type": "string",
          "format": "string"
        },
        "is_active": {
          "type": "boolean"
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        },
        "updated_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    }
  },
  "externalDocs": {
    "description": "Find out more about Swagger",
    "url": "http://swagger.io"
  }
}