{ "openapi": "3.0.0", "info": { "title": "AIRBNB API", "version": "1.0.0", "description": "documentation for airbnb API", "contact": { "name": "Team 1 Alterra", "email": "ezabintangramadhan@gmail.com" }, "license": { "name": "APACHE 2.0" } }, "servers": [ { "description": "server for airnb project", "url": "https://auf.my.id" } ], "paths": { "/login": { "post": { "tags": [ "Auth" ], "summary": "login user", "description": "", "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "email": { "type": "string", "description": "email user", "example": "tukimin@mail.com" }, "password": { "type": "string", "description": "passwword user", "example": "tukimin123" } }, "required": [ "email", "passwword" ] } } } }, "responses": { "200": { "description": "Login successful", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Login" }, "examples": { "success": { "description": "Login successful", "value":{ "id": 1, "name":"user123", "token":"agaTwefhwoefh12314" } } } } } }, "400":{ "description": "Login failed", "content": { "application/json":{ "schema": { "type": "object", "properties": { "status": { "type": "string" }, "description":{ "type": "string" } } }, "examples": { "failed": { "description": "Login failed", "value":{ "status":"login failed", "description":"wrong username/password" } } } } } }, "404":{ "description": "user not found. please input correctly.", "content": { "application/json":{ "schema":{ "type": "object", "properties": { "message":{ "type": "string" } }, "example":{ "message":"user not found. please input correctly." } } } } }, "500":{ "$ref": "#/components/responses/500" } } } }, "/users": { "post":{ "tags": ["users"], "summary": "create new user", "description": "", "requestBody":{ "required": true, "content": { "application/json":{ "schema":{ "$ref": "#/components/schemas/InsertUser" }, "example": { "name":"tukimin", "email":"tukimin@mail.com", "password":"tukimin123", "phone_number":"08220321" } } } }, "responses": { "201":{ "description": "successful register", "content":{ "application/json":{ "schema":{ "$ref": "#/components/responses/201" }, "examples":{ "successful_update":{ "value":{ "message":"register successful" } } } } } }, "400":{ "$ref": "#/components/responses/400" }, "404":{ "$ref": "#/components/responses/404" }, "500":{ "$ref": "#/components/responses/500" } } }, "get": { "security": [ { "JWTAuth":[] } ], "tags": [ "users" ], "summary": "see profile user", "description": "see profile user by token id", "responses": { "200": { "description": "Success get profile user", "content": { "application/json":{ "schema": { "type": "object", "properties": { "id": { "type": "integer", "example": 1 }, "name":{ "type": "string", "example": "tukimin" }, "email":{ "type": "string", "example":"tukimin@mail.com" } } } } } }, "404": { "$ref": "#/components/responses/404" }, "500":{ "$ref": "#/components/responses/500" } } }, "put": { "security": [ { "JWTAuth":[] } ], "tags": [ "users" ], "summary": "Update existing user", "description": "update existing user by id", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UpdateUser" }, "examples": { "update_user":{ "value":{ "name":"Eza", "email":"eza@mail.com", "password":"eza123", "phone_number":"0822232" } } } } } }, "responses": { "200": { "description": "successful update", "content":{ "application/json":{ "schema":{ "$ref": "#/components/responses/200" }, "examples":{ "successful_update":{ "value":{ "message":"success update user" } } } } } }, "400":{ "description": "wrong input", "content": { "application/json":{ "schema":{ "$ref": "#/components/responses/400" }, "examples":{ "failed_update":{ "value":{ "message":"failed update. input your changes correctly" } } } } } }, "500":{ "$ref": "#/components/responses/500" } } }, "delete":{ "security": [ { "JWTAuth":[] } ], "tags": [ "users" ], "summary": "delete existing user", "description": "delete existing user by id", "responses": { "200":{ "description": "successful delete user", "content":{ "application/json":{ "schema":{ "$ref": "#/components/responses/200" }, "examples":{ "successful_delete":{ "value":{ "message":"success delete user" } } } } } }, "404":{ "description": "user not found", "content": { "application/json":{ "schema":{ "$ref": "#/components/responses/404" }, "examples":{ "failed_delete":{ "value":{ "message":"failed delete. user not found" } } } } } }, "500":{ "$ref": "#/components/responses/500" } } } }, "/users/upgrade":{ "post":{ "security": [ { "JWTAuth":[] } ], "tags": ["users"], "summary": "make a host", "description": "make a host with create homestays for rent", "requestBody":{ "required": true, "content": { "application/json":{ "schema":{ "$ref": "#/components/schemas/CreateHomestay" }, "example":{ "homestayName":"puncak dieng", "address":"Bandung", "description":"1 queen size bed, 1 toilet, TV, wifi, etc", "price_per_night":145000, "images1":"url images1", "images2":"url images2", "images3":"url images3" } } } }, "responses": { "201":{ "description": "success make a host and add homestay", "content": { "application/json":{ "schema":{ "allOf":[ { "$ref": "#/components/responses/201" }, { "type": "object", "properties": { "message":{ "type": "string", "example":"success add homestay. Congratulations! you're host now" } } } ] } } } }, "400":{ "$ref": "#/components/responses/400" }, "500":{ "$ref": "#/components/responses/500" } } } }, "/users/changeprofilepicture":{ "post":{ "security": [ { "JWTAuth":[] } ], "tags": ["users"], "summary": "Upload profile picture", "description": "Endpoint for upload user's profile picture", "requestBody": { "required": true, "content": { "multipart/form-data": { "schema": { "type": "object", "properties": { "profile_picture": { "type": "string", "format": "binary", "description": "The profile picture file to be uploaded" } }, "required": ["profile_picture"] } } } }, "responses": { "200": { "description": "success upload profile picture", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "example": "Profile picture uploaded successfully" }, "photoURL": { "type": "string", "example": "https://res.cloudinary.com/dikdesfng/image/upload/v1245564784/go-cloudinary/alfdbsaufpad.png" } } } } } }, "400": { "$ref": "#/components/responses/400" }, "500": { "$ref": "#/components/responses/500" } } } }, "/homestays":{ "get":{ "tags": [ "homestays" ], "summary": "get all homestay in user mode", "description": "get all homestay when user in user mode", "responses": { "200":{ "description": "Success get all homestay", "content": { "application/json":{ "schema":{ "allOf":[ { "$ref": "#/components/schemas/ResponsesWithData" }, { "type": "object", "properties": { "message":{ "type": "string", "example":"success get all homestay" }, "data":{ "type": "object", "properties": { "homestay_id" :{ "type": "integer", "example": 1 }, "homestayName":{ "type": "string", "example":"puncak cottage" }, "address":{ "type": "string", "example":"Bandung" }, "price_per_night":{ "type": "integer", "example":120000 } } } } } ] } } } }, "404":{ "$ref": "#/components/responses/404" }, "500":{ "$ref": "#/components/responses/500" } } } }, "/homestays/{id}":{ "get":{ "tags": ["homestays"], "summary": "get homestay by id", "description": "get homestay using id at path parameter. only return 1 data", "parameters": [ { "$ref": "#/components/parameters/idHomestay" } ], "responses": { "200":{ "description": "Success get homestay", "content": { "application/json":{ "schema":{ "allOf":[ { "$ref": "#/components/schemas/ResponsesWithData" }, { "type": "object", "properties": { "message":{ "type": "string", "example":"success get homestay" }, "data":{ "type": "object", "properties": { "homestay_id" :{ "type": "integer", "example": 1 }, "homestayName":{ "type": "string", "example":"puncak cottage" }, "address":{ "type": "string", "example":"Bandung" }, "price_per_night":{ "type": "integer", "example":120000 }, "description":{ "type": "string", "example":"1 queen size bed, 1 toilet, TV, wifi, etc" } } } } } ] } } } }, "404":{ "$ref": "#/components/responses/404" }, "500":{ "$ref": "#/components/responses/500" } } } }, "/homestays/host":{ "get":{ "security": [ { "JWTAuth":[] } ], "tags": ["homestays"], "summary": "get all homestay in host mode", "description": "get all homestay when user in host mode", "responses": { "200":{ "description": "Success get all homestay", "content": { "application/json":{ "schema":{ "allOf":[ { "$ref": "#/components/schemas/ResponsesWithData" }, { "type": "object", "properties": { "message":{ "type": "string", "example":"success get all homestay" }, "data":{ "type": "object", "properties": { "homestay_id" :{ "type": "integer", "example": 1 }, "homestayName":{ "type": "string", "example":"puncak cottage" }, "address":{ "type": "string", "example":"Bandung" }, "price_per_night":{ "type": "integer", "example":120000 } } } } } ] } } } }, "404":{ "$ref": "#/components/responses/404" }, "500":{ "$ref": "#/components/responses/500" } } }, "post":{ "security": [ { "JWTAuth":[] } ], "tags": ["homestays"], "summary": "create new homestay", "description": "create homestays for rent", "requestBody":{ "required": true, "content": { "application/json":{ "schema":{ "$ref": "#/components/schemas/CreateHomestay" }, "example":{ "homestayName":"puncak dieng", "address":"Bandung", "description":"1 queen size bed, 1 toilet, TV, wifi, etc", "price_per_night":145000 } }, "multipart/form-data": { "schema": { "type": "object", "properties": { "photos": { "type": "array", "items":{ "type": "string", "format": "binary" }, "description": "The photos file to be uploaded (max.3 photos)" } }, "required": ["homestayPhotos"] } } } }, "responses": { "201":{ "description": "success add homestay", "content": { "application/json":{ "schema":{ "allOf":[ { "$ref": "#/components/responses/201" }, { "type": "object", "properties": { "message":{ "type": "string", "example":"success add homestay" } } } ] } } } }, "400":{ "$ref": "#/components/responses/400" }, "500":{ "$ref": "#/components/responses/500" } } } }, "/homestays/host/myHomestay":{ "get":{ "security": [ { "JWTAuth":[] } ], "tags": ["homestays"], "description": "get all user's homestay", "responses": { "200":{ "description": "Success get all homestay", "content": { "application/json":{ "schema":{ "allOf":[ { "$ref": "#/components/schemas/ResponsesWithData" }, { "type": "object", "properties": { "message":{ "type": "string", "example":"success get all homestay" }, "data":{ "type": "object", "properties": { "homestay_id" :{ "type": "integer", "example": 1 }, "homestayName":{ "type": "string", "example":"puncak cottage" }, "address":{ "type": "string", "example":"Bandung" }, "price_per_night":{ "type": "integer", "example":120000 } } } } } ] } } } }, "404":{ "$ref": "#/components/responses/404" }, "500":{ "$ref": "#/components/responses/500" } } } }, "/homestays/host/{id}":{ "put":{ "security": [ { "JWTAuth":[] } ], "tags": ["homestays"], "summary": "update homestay data by id", "parameters": [ { "$ref": "#/components/parameters/idHomestay" } ], "requestBody":{ "required": true, "content": { "application/json":{ "schema":{ "$ref": "#/components/schemas/CreateHomestay" }, "example":{ "homestayName":"bromo cottage", "address":"lumajang", "description":"1 king size bed, 2 toilet, TV, wifi, etc", "price_per_night":375000 } }, "multipart/form-data": { "schema": { "type": "object", "properties": { "photos": { "type": "array", "items":{ "type": "string", "format": "binary" }, "description": "The photos file to be uploaded (max.3 photos)" } }, "required": ["homestayPhotos"] } } } }, "responses": { "201":{ "description": "success update homestay", "content": { "application/json":{ "schema":{ "allOf":[ { "$ref": "#/components/responses/201" }, { "type": "object", "properties": { "message":{ "type": "string", "example":"success update homestay" } } } ] } } } }, "400":{ "$ref": "#/components/responses/400" }, "500":{ "$ref": "#/components/responses/500" } } }, "delete":{ "security": [ { "JWTAuth":[] } ], "tags": ["homestays"], "summary": "delete homestay by id", "parameters": [ { "$ref": "#/components/parameters/idHomestay" } ], "responses": { "200":{ "description": "successful delete homestay", "content":{ "application/json":{ "schema":{ "$ref": "#/components/responses/200" }, "examples":{ "successfulUpdate":{ "value":{ "message":"success delete homestay" } } } } } }, "404":{ "description": "user not found", "content": { "application/json":{ "schema":{ "$ref": "#/components/responses/404" }, "examples":{ "failedDelete":{ "value":{ "message":"failed delete. homestay not found" } } } } } }, "500":{ "$ref": "#/components/responses/500" } } } }, "/reservations/availability":{ "post":{ "security": [ { "JWTAuth":[] } ], "tags": ["reservations"], "summary": "check reservation availability", "requestBody":{ "required": true, "content": { "application/json":{ "schema":{ "$ref": "#/components/schemas/reservationFeature" }, "examples": { "availableRequest":{ "value":{ "homestay_id":1, "start_date":"2006-01-02", "end_date":"2006-01-05" } } } } } }, "responses": { "200":{ "description":"success check availability", "content":{ "application/json":{ "schema":{ "oneOf":[ { "$ref": "#/components/schemas/availableResponse" }, { "$ref": "#/components/schemas/NotAvailableResponse" } ] } } } }, "400":{ "$ref": "#/components/responses/400" }, "500":{ "$ref": "#/components/responses/500" } } } }, "/reservations":{ "post":{ "security": [ { "JWTAuth":[] } ], "tags": ["reservations"], "summary": "create reservation", "requestBody":{ "required": true, "content": { "application/json":{ "schema":{ "$ref": "#/components/schemas/reservationFeature" }, "examples": { "availableRequest":{ "value":{ "homestay_id":1, "start_date":"2006-01-02", "end_date":"2006-01-05" } } } } } }, "responses": { "200":{ "description":"success create reservation", "content":{ "application/json":{ "schema":{ "$ref": "#/components/responses/200" }, "examples": { "statusCheck":{ "value":{ "message":"success create reservation" } } } } } }, "400":{ "$ref": "#/components/responses/400" }, "500":{ "$ref": "#/components/responses/500" } } } }, "/reservations/history":{ "get":{ "security": [ { "JWTAuth":[] } ], "tags": ["reservations"], "summary": "reservation history", "responses": { "200":{ "description": "Success get all history", "content": { "application/json":{ "schema":{ "allOf":[ { "$ref": "#/components/schemas/ResponsesWithData" }, { "type": "object", "properties": { "message":{ "type": "string", "example":"success get all reservation" }, "data":{ "type": "object", "properties": { "id": { "type": "integer", "example": 1 }, "user_id": { "type": "integer", "example": 1 }, "homestay_id" :{ "type": "integer", "example": 1 }, "start_date":{ "type": "string", "example":"2006-01-02" }, "end_date":{ "type": "string", "example":"2006-01-05" }, "total_price":{ "type": "integer", "example":120000 }, "status":{ "type": "string", "example":"success" } } } } } ] } } } }, "404":{ "$ref": "#/components/responses/404" }, "500":{ "$ref": "#/components/responses/500" } } } }, "/feedback":{ "post":{ "security": [ { "JWTAuth":[] } ], "tags": ["feedbacks"], "summary": "create feedback", "requestBody":{ "required": true, "content": { "application/json":{ "schema":{ "$ref": "#/components/schemas/createFeedback" } } } }, "responses": { "200":{ "description":"success create feedback", "content":{ "application/json":{ "schema":{ "$ref": "#/components/responses/200" }, "examples": { "statusCheck":{ "value":{ "message":"success create feedback" } } } } } }, "400":{ "$ref": "#/components/responses/400" }, "500":{ "$ref": "#/components/responses/500" } } } }, "/feedback/{id}":{ "get":{ "security": [ { "JWTAuth":[] } ], "tags": ["feedbacks"], "summary": "get feedback by homestay id", "parameters": [ { "$ref": "#/components/parameters/idHomestay" } ], "responses": { "200":{ "description": "Success get all feedback", "content": { "application/json":{ "schema":{ "allOf":[ { "$ref": "#/components/schemas/ResponsesWithData" }, { "type": "object", "properties": { "message":{ "type": "string", "example":"success get feedback by homestay id" }, "data":{ "type": "object", "properties": { "id" :{ "type": "integer", "example": 1 }, "user_id" :{ "type": "integer", "example": 1 }, "homestay_id" :{ "type": "integer", "example": 1 }, "rating" :{ "type": "integer", "example": 5 }, "feedback":{ "type": "string", "example":"tempatnya nyaman" }, "created_at":{ "type": "string", "example":"2006-01-02" } } } } } ] } } } }, "404":{ "$ref": "#/components/responses/404" }, "500":{ "$ref": "#/components/responses/500" } } } } }, "components": { "securitySchemes": { "JWTAuth": { "description": "token for admin", "type": "http", "scheme": "bearer", "bearerFormat": "JWT" } }, "parameters": { "idHomestay": { "name": "id", "in": "path", "required": true, "description": "id homestay to get data", "schema": { "type": "integer", "example":1 } } }, "schemas": { "Login": { "type": "object", "properties": { "id": { "type": "string" }, "name": { "type": "string" }, "token": { "type": "string" } } }, "InsertUser":{ "type": "object", "properties": { "name":{ "type": "string" }, "email":{ "type": "string" }, "password":{ "type": "string" }, "phone_number":{ "type": "string" } } }, "ResponsesWithData": { "type": "object", "properties": { "message":{ "type": "string" }, "data":{ "type": "object" } } }, "UpdateUser": { "type": "object", "properties": { "name": { "type": "string" }, "email": { "type": "string" }, "password": { "type": "string" }, "phone_number":{ "type": "string" } } }, "CreateHomestay":{ "type": "object", "properties": { "homestayName":{ "type": "string" }, "address":{ "type": "string" }, "description":{ "type": "string" }, "price_per_night":{ "type": "integer" } } }, "reservationFeature":{ "type": "object", "properties": { "homestay_id":{ "type": "integer" }, "startDate":{ "type": "string" }, "endDate":{ "type": "string" } } }, "createFeedback":{ "type":"object", "properties": { "homestay_id" :{ "type": "integer", "example": 1 }, "rating":{ "type": "integer", "example":5 }, "feedback":{ "type": "string", "example":"tempatnya nyaman" } } }, "availableResponse":{ "type": "object", "properties": { "status": { "type": "string", "example": "available" } } }, "NotAvailableResponse": { "type": "object", "properties": { "status": { "type": "string", "example": "not available" } } } }, "responses": { "200":{ "description": "success Process data", "content": { "application/json":{ "schema":{ "type": "object", "properties": { "message":{ "type": "string" } } } } } }, "201":{ "description": "success create data", "content": { "application/json":{ "schema":{ "type": "object", "properties": { "message":{ "type": "string" } } } } } }, "400":{ "description": "bad request from user", "content": { "application/json":{ "schema":{ "type": "object", "properties": { "message":{ "type": "string" } }, "example":{ "message":"Process failed. Please check your input" } } } } }, "404":{ "description": "page not found or wrong url", "content": { "application/json":{ "schema":{ "type": "object", "properties": { "message":{ "type": "string" } }, "example":{ "message":"procces failed. page not found or wrong url" } } } } }, "500":{ "description": "error procces on server", "content": { "application/json":{ "schema":{ "type": "object", "properties": { "message":{ "type": "string" } }, "example":{ "message": "procces failed. error internal server" } } } } } } } }