{
  "swagger": "2.0",
  "info": {
    "version": "1.0.0",
    "title": "Blog API",
    "description": "Blog API Management",
    "termsOfService": "http://www.clarusway.com/#",
    "contact": {
      "name": "Clarusway",
      "email": "qadir@clarusway.com"
    },
    "license": {
      "name": "ISC Licence"
    }
  },
  "host": "blog-api-js.fullstack.clarusway.com",
  "basePath": "/",
  "schemes": [
    "https"
  ],
  "securityDefinitions": {
    "Token": {
      "in": "header",
      "type": "apiKey",
      "name": "Authorization",
      "description": "Token Authentication * Example: <b>Token ...tokenKey...</b>"
    },
    "Bearer": {
      "in": "header",
      "type": "apiKey",
      "name": "Authorization",
      "description": "JWT Authentication * Example: <b>Bearer ...accessToken...</b>"
    }
  },
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "paths": {
    "/auth/login": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Login",
        "description": "Login with username (or email) and password for get Token and JWT.",
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "username": {
                  "type": "string",
                  "example": "test"
                },
                "password": {
                  "type": "string",
                  "example": "1234"
                }
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/auth/refresh": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "JWT: Refresh",
        "description": "Refresh access-token by refresh-token.",
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "bearer": {
                  "type": "object",
                  "properties": {
                    "refresh": {
                      "type": "string",
                      "example": "___refreshToken___"
                    }
                  }
                }
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/auth/logout": {
      "get": {
        "tags": [
          "Authentication"
        ],
        "summary": "Token: Logout",
        "description": "Delete token-key.",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/users/": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "List Users",
        "description": "  You can use <u>filter[] & search[] & sort[] & page & limit</u> queries with endpoint.  <ul> Examples:   <li>URL/?<b>filter[field1]=value1&filter[field2]=value2</b></li>   <li>URL/?<b>search[field1]=value1&search[field2]=value2</b></li>   <li>URL/?<b>sort[field1]=asc&sort[field2]=desc</b></li>   <li>URL/?<b>limit=10&page=1</b></li>  </ul>  ",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "post": {
        "tags": [
          "Users"
        ],
        "summary": "Create User",
        "description": "",
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "username": {
                  "type": "string",
                  "example": "test"
                },
                "password": {
                  "type": "string",
                  "example": "1234"
                },
                "email": {
                  "type": "string",
                  "example": "test@site.com"
                },
                "firstName": {
                  "type": "string",
                  "example": "test"
                },
                "lastName": {
                  "type": "string",
                  "example": "test"
                },
                "image": {
                  "type": "string",
                  "example": ""
                },
                "city": {
                  "type": "string",
                  "example": ""
                },
                "bio": {
                  "type": "string",
                  "example": ""
                }
              }
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Created"
          }
        }
      }
    },
    "/users/{id}": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "Get Single User",
        "description": "",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "put": {
        "tags": [
          "Users"
        ],
        "summary": "Update User",
        "description": "",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "username": {
                  "type": "string",
                  "example": "test"
                },
                "password": {
                  "type": "string",
                  "example": "1234"
                },
                "email": {
                  "type": "string",
                  "example": "test@site.com"
                },
                "firstName": {
                  "type": "string",
                  "example": "test"
                },
                "lastName": {
                  "type": "string",
                  "example": "test"
                },
                "image": {
                  "type": "string",
                  "example": ""
                },
                "city": {
                  "type": "string",
                  "example": ""
                },
                "bio": {
                  "type": "string",
                  "example": ""
                }
              }
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted"
          }
        }
      },
      "delete": {
        "tags": [
          "Users"
        ],
        "summary": "Delete User",
        "description": "",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          }
        }
      },
      "patch": {
        "tags": [
          "Users"
        ],
        "summary": "Update User",
        "description": "",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "username": {
                  "type": "string",
                  "example": "test"
                },
                "password": {
                  "type": "string",
                  "example": "1234"
                },
                "email": {
                  "type": "string",
                  "example": "test@site.com"
                },
                "firstName": {
                  "type": "string",
                  "example": "test"
                },
                "lastName": {
                  "type": "string",
                  "example": "test"
                },
                "image": {
                  "type": "string",
                  "example": ""
                },
                "city": {
                  "type": "string",
                  "example": ""
                },
                "bio": {
                  "type": "string",
                  "example": ""
                }
              }
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted"
          }
        }
      }
    },
    "/categories/": {
      "get": {
        "tags": [
          "Categories"
        ],
        "summary": "List Categories",
        "description": "  You can use <u>filter[] & search[] & sort[] & page & limit</u> queries with endpoint.  <ul> Examples:   <li>URL/?<b>filter[field1]=value1&filter[field2]=value2</b></li>   <li>URL/?<b>search[field1]=value1&search[field2]=value2</b></li>   <li>URL/?<b>sort[field1]=asc&sort[field2]=desc</b></li>   <li>URL/?<b>limit=10&page=1</b></li>  </ul>  ",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "post": {
        "tags": [
          "Categories"
        ],
        "summary": "Create Category",
        "description": "",
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "example": "Category 1"
                }
              }
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Created"
          }
        }
      }
    },
    "/categories/{id}": {
      "get": {
        "tags": [
          "Categories"
        ],
        "summary": "Get Single Category",
        "description": "",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "put": {
        "tags": [
          "Categories"
        ],
        "summary": "Update Category",
        "description": "",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "example": "Category 1"
                }
              }
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted"
          }
        }
      },
      "delete": {
        "tags": [
          "Categories"
        ],
        "summary": "Delete Category",
        "description": "",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          }
        }
      },
      "patch": {
        "tags": [
          "Categories"
        ],
        "summary": "Update Category",
        "description": "",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "example": "Category 1"
                }
              }
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted"
          }
        }
      }
    },
    "/blogs/": {
      "get": {
        "tags": [
          "Blogs"
        ],
        "summary": "List Blogs",
        "description": "  You can use <u>filter[] & search[] & sort[] & page & limit</u> queries with endpoint.  <ul> Examples:   <li>URL/?<b>filter[field1]=value1&filter[field2]=value2</b></li>   <li>URL/?<b>search[field1]=value1&search[field2]=value2</b></li>   <li>URL/?<b>sort[field1]=asc&sort[field2]=desc</b></li>   <li>URL/?<b>limit=10&page=1</b></li>  </ul>  You can use <i>author=userId</i> query for get all blogs of any user.  ",
        "parameters": [
          {
            "name": "author",
            "in": "query",
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "post": {
        "tags": [
          "Blogs"
        ],
        "summary": "Create Blog",
        "description": "",
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "categoryId": {
                  "type": "string",
                  "example": "65343222b67e9681f937f101"
                },
                "title": {
                  "type": "string",
                  "example": "Blog Title 1"
                },
                "content": {
                  "type": "string",
                  "example": "Blog Content 1"
                },
                "image": {
                  "type": "string",
                  "example": "http://imageURL"
                },
                "isPublish": {
                  "type": "boolean",
                  "example": true
                }
              }
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Created"
          }
        }
      }
    },
    "/blogs/{id}": {
      "get": {
        "tags": [
          "Blogs"
        ],
        "summary": "Get Single Blog",
        "description": "",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "put": {
        "tags": [
          "Blogs"
        ],
        "summary": "Update Blog",
        "description": "",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "categoryId": {
                  "type": "string",
                  "example": "65343222b67e9681f937f101"
                },
                "title": {
                  "type": "string",
                  "example": "Blog Title 1"
                },
                "content": {
                  "type": "string",
                  "example": "Blog Content 1"
                },
                "image": {
                  "type": "string",
                  "example": "http://imageURL"
                },
                "isPublish": {
                  "type": "boolean",
                  "example": true
                }
              }
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted"
          }
        }
      },
      "delete": {
        "tags": [
          "Blogs"
        ],
        "summary": "Delete Blog",
        "description": "",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          }
        }
      },
      "patch": {
        "tags": [
          "Blogs"
        ],
        "summary": "Update Blog",
        "description": "",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "categoryId": {
                  "type": "string",
                  "example": "65343222b67e9681f937f101"
                },
                "title": {
                  "type": "string",
                  "example": "Blog Title 1"
                },
                "content": {
                  "type": "string",
                  "example": "Blog Content 1"
                },
                "image": {
                  "type": "string",
                  "example": "http://imageURL"
                },
                "isPublish": {
                  "type": "boolean",
                  "example": true
                }
              }
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted"
          }
        }
      }
    },
    "/blogs/{id}/getLike": {
      "get": {
        "tags": [
          "Blogs"
        ],
        "summary": "Get Like Info",
        "description": "",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/blogs/{id}/postLike": {
      "post": {
        "tags": [
          "Blogs"
        ],
        "summary": "Add/Remove Like",
        "description": "",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {}
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted"
          }
        }
      }
    },
    "/comments/": {
      "get": {
        "tags": [
          "Comments"
        ],
        "summary": "List Comments",
        "description": "  You can use <u>filter[] & search[] & sort[] & page & limit</u> queries with endpoint.  <ul> Examples:   <li>URL/?<b>filter[field1]=value1&filter[field2]=value2</b></li>   <li>URL/?<b>search[field1]=value1&search[field2]=value2</b></li>   <li>URL/?<b>sort[field1]=asc&sort[field2]=desc</b></li>   <li>URL/?<b>limit=10&page=1</b></li>  </ul>  ",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "post": {
        "tags": [
          "Comments"
        ],
        "summary": "Create Comment",
        "description": "",
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "blogId": {
                  "type": "string",
                  "example": "65343222b67e9681f937f201"
                },
                "comment": {
                  "type": "string",
                  "example": "Comment 1"
                }
              }
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Created"
          }
        }
      }
    },
    "/comments/{id}": {
      "get": {
        "tags": [
          "Comments"
        ],
        "summary": "Get Single Comment",
        "description": "",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "put": {
        "tags": [
          "Comments"
        ],
        "summary": "Update Comment",
        "description": "",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "blogId": {
                  "type": "string",
                  "example": "65343222b67e9681f937f201"
                },
                "comment": {
                  "type": "string",
                  "example": "Comment 1"
                }
              }
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted"
          }
        }
      },
      "delete": {
        "tags": [
          "Comments"
        ],
        "summary": "Delete Comment",
        "description": "",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          }
        }
      },
      "patch": {
        "tags": [
          "Comments"
        ],
        "summary": "Update Comment",
        "description": "",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "blogId": {
                  "type": "string",
                  "example": "65343222b67e9681f937f201"
                },
                "comment": {
                  "type": "string",
                  "example": "Comment 1"
                }
              }
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted"
          }
        }
      }
    }
  },
  "definitions": {
    "User": {
      "type": "object",
      "properties": {
        "username": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "trim": {
              "type": "boolean",
              "example": true
            },
            "required": {
              "type": "boolean",
              "example": true
            },
            "unique": {
              "type": "boolean",
              "example": true
            },
            "index": {
              "type": "boolean",
              "example": true
            }
          }
        },
        "password": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "trim": {
              "type": "boolean",
              "example": true
            },
            "required": {
              "type": "boolean",
              "example": true
            }
          }
        },
        "email": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "trim": {
              "type": "boolean",
              "example": true
            },
            "required": {
              "type": "boolean",
              "example": true
            },
            "unique": {
              "type": "boolean",
              "example": true
            },
            "index": {
              "type": "boolean",
              "example": true
            }
          }
        },
        "firstName": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "trim": {
              "type": "boolean",
              "example": true
            },
            "required": {
              "type": "boolean",
              "example": true
            }
          }
        },
        "lastName": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "trim": {
              "type": "boolean",
              "example": true
            },
            "required": {
              "type": "boolean",
              "example": true
            }
          }
        },
        "image": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "trim": {
              "type": "boolean",
              "example": true
            }
          }
        },
        "city": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "trim": {
              "type": "boolean",
              "example": true
            }
          }
        },
        "bio": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "trim": {
              "type": "boolean",
              "example": true
            }
          }
        },
        "isActive": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "default": {
              "type": "boolean",
              "example": true
            }
          }
        },
        "isStaff": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "default": {
              "type": "boolean",
              "example": false
            }
          }
        },
        "isAdmin": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "default": {
              "type": "boolean",
              "example": false
            }
          }
        }
      }
    },
    "Category": {
      "type": "object",
      "properties": {
        "name": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "trim": {
              "type": "boolean",
              "example": true
            },
            "required": {
              "type": "boolean",
              "example": true
            },
            "unique": {
              "type": "boolean",
              "example": true
            }
          }
        }
      }
    },
    "Blog": {
      "type": "object",
      "properties": {
        "userId": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "ref": {
              "type": "string",
              "example": "User"
            },
            "required": {
              "type": "boolean",
              "example": true
            }
          }
        },
        "categoryId": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "ref": {
              "type": "string",
              "example": "Category"
            },
            "required": {
              "type": "boolean",
              "example": true
            }
          }
        },
        "title": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "trim": {
              "type": "boolean",
              "example": true
            },
            "required": {
              "type": "boolean",
              "example": true
            }
          }
        },
        "content": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "trim": {
              "type": "boolean",
              "example": true
            },
            "required": {
              "type": "boolean",
              "example": true
            }
          }
        },
        "image": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "trim": {
              "type": "boolean",
              "example": true
            },
            "required": {
              "type": "boolean",
              "example": true
            }
          }
        },
        "isPublish": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "default": {
              "type": "boolean",
              "example": true
            }
          }
        },
        "comments": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "type": {
                "type": "function"
              },
              "ref": {
                "type": "string",
                "example": "Comment"
              }
            }
          }
        },
        "likes": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "type": {
                "type": "function"
              },
              "ref": {
                "type": "string",
                "example": "User"
              }
            }
          }
        },
        "countOfVisitors": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "default": {
              "type": "number",
              "example": 0
            }
          }
        }
      }
    },
    "Comment": {
      "type": "object",
      "properties": {
        "blogId": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "ref": {
              "type": "string",
              "example": "Blog"
            },
            "required": {
              "type": "boolean",
              "example": true
            }
          }
        },
        "userId": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "ref": {
              "type": "string",
              "example": "User"
            },
            "required": {
              "type": "boolean",
              "example": true
            }
          }
        },
        "comment": {
          "type": "object",
          "properties": {
            "type": {
              "type": "function"
            },
            "trim": {
              "type": "boolean",
              "example": true
            },
            "required": {
              "type": "boolean",
              "example": true
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "Token": []
    },
    {
      "Bearer": []
    }
  ]
}