openapi: 3.0.0 info: title: API Documentation version: 1.0.0 servers: - url: http://localhost:3002 - url: https://team-one.binar-project.online paths: /users/register: post: summary: Mendaftarkan pengguna baru requestBody: required: true content: application/json: schema: type: object properties: name: type: string password: type: string email: type: string is_admin: type: boolean address: type: string required: - name - password - email responses: '201': description: Pengguna berhasil didaftarkan '400': description: Validasi input gagal atau email telah digunakan '500': description: Terjadi kesalahan saat mendaftarkan pengguna /users/: get: summary: Mendapatkan daftar semua pengguna security: - bearerAuth: [] responses: '200': description: Daftar pengguna berhasil diambil '500': description: Terjadi kesalahan saat mengambil data pengguna /users/login: post: summary: Masuk ke dalam sistem requestBody: required: true content: application/json: schema: type: object properties: email: type: string password: type: string required: - email - password responses: '200': description: Login berhasil '400': description: Email atau password tidak diisi '401': description: Email tidak ditemukan atau kombinasi email dan password salah '500': description: Terjadi kesalahan saat login /users/user-update: put: summary: Memperbarui informasi pengguna security: - bearerAuth: [] requestBody: required: true content: application/json: schema: type: object properties: name: type: string address: type: string email: type: string oldPassword: type: string newPassword: type: string responses: '200': description: Informasi pengguna berhasil diperbarui '400': description: Tidak ada perubahan atau email telah digunakan '401': description: Old Password salah '404': description: Pengguna tidak ditemukan '500': description: Terjadi kesalahan saat memperbarui pengguna /users/user-delete: delete: summary: Menghapus pengguna security: - bearerAuth: [] responses: '200': description: Pengguna berhasil dihapus '400': description: Password tidak diisi '401': description: Password yang dimasukkan salah '404': description: Pengguna tidak ditemukan '500': description: Terjadi kesalahan saat menghapus pengguna /users/whoami: get: summary: Mendapatkan informasi pengguna saat ini security: - bearerAuth: [] responses: '200': description: Informasi pengguna saat ini berhasil diambil /items: get: summary: Get all items description: Show all available items tags: - Items security: - bearerAuth: [] responses: '200': description: successfully retrieved all items content: application/json: schema: type: object properties: success: type: boolean example: true data: type: array items: $ref: '#/components/schemas/Item' "500": description: failed to retrieve all items content: application/json: schema: type: object properties: success: type: boolean example: false message: example: Internal Server Error post: summary: Add a new item description: Add a new item tags: - Items security: - bearerAuth: [] responses: '200': description: successfully created a new item content: application/json: schema: type: object properties: success: type: boolean example: true data: type: array items: $ref: '#/components/schemas/Item' "500": description: failed to create a new item content: application/json: schema: type: object properties: message: example: Internal Server Error /items/{id}: get: summary: Get a specific item description: Get an item with the specified ID tags: - Items security: - bearerAuth: [] parameters: - name: id in: path description: ID of item to return required: true schema: type: integer format: int64 responses: '200': description: successfully retrieved the specified item content: application/json: schema: type: object properties: success: type: boolean example: true data: type: array items: $ref: '#/components/schemas/Item' "400": description: invalid id supplied content: application/json: schema: type: object properties: success: type: boolean example: false message: example: Item not found "500": description: failed to retrieve the specified item content: application/json: schema: type: object properties: success: type: boolean example: false message: example: Internal Server Error /items: post: summary: Create a new item description: Create a new item in the inventory. tags: - Items security: - bearerAuth: [] requestBody: required: true content: multipart/form-data: schema: type: object properties: name: type: string description: Name of the item example: "Example Item" description: type: string description: Description of the item example: "This is an example item." stock: type: integer description: Stock quantity of the item example: 100 price: type: number format: float description: Price of the item example: 29.99 image: type: string format: binary description: Image of the item responses: 200: description: Item created successfully content: application/json: schema: type: object properties: success: type: boolean data: $ref: '#/components/schemas/Item' 500: description: Server error content: application/json: schema: type: object properties: message: type: string /items/{id}: put: summary: Update an existing item description: Update the details of an existing item. tags: - Items security: - bearerAuth: [] parameters: - in: path name: id required: true schema: type: string description: ID of the item to update requestBody: required: true content: multipart/form-data: schema: type: object properties: name: type: string description: Name of the item description: type: string description: Description of the item stock: type: integer description: Stock quantity of the item price: type: number format: float description: Price of the item image: type: string format: binary description: Image of the item responses: 200: description: Item updated successfully content: application/json: schema: type: object properties: success: type: boolean message: type: string data: $ref: '#/components/schemas/Item' 400: description: Invalid item ID 500: description: Server error content: application/json: schema: type: object properties: message: type: string delete: summary: Delete an item description: Delete an existing item by ID. tags: - Items parameters: - in: path name: id required: true schema: type: string description: ID of the item to delete responses: 200: description: Item deleted successfully content: application/json: schema: type: object properties: message: type: string 400: description: Invalid item ID 500: description: Server error content: application/json: schema: type: object properties: message: type: string /orders: get: summary: Get user orders description: Retrieve all orders for the authenticated user. tags: - Orders security: - bearerAuth: [] responses: '200': description: Successfully retrieved orders content: application/json: schema: type: object properties: success: type: boolean example: true data: type: array items: $ref: '#/components/schemas/Order' '500': description: Internal server error post: summary: Create a new order description: Create a new order with specified items. tags: - Orders security: - bearerAuth: [] requestBody: description: Order creation object required: true content: application/json: schema: $ref: '#/components/schemas/CreateOrderRequest' responses: '201': description: Successfully created order content: application/json: schema: type: object properties: success: type: boolean example: true data: type: array items: $ref: '#/components/schemas/OrderItem' '400': description: Bad request content: text/plain: schema: type: string example: 'Please fill items with id and quantity. Example: { "items": [ {"id": 1, "quantity": 10}, {"id": 2, "quantity": 15} ] }' '404': description: Item not found content: application/json: schema: type: object properties: error: type: string example: 'cannot find item(s) requested' '500': description: Internal server error /orders/{id}/update-status: patch: summary: Update order status description: Update the status of an order by ID. tags: - Orders security: - bearerAuth: [] parameters: - in: path name: id schema: type: integer required: true description: ID of the order to update requestBody: description: Order status update object required: true content: application/json: schema: $ref: '#/components/schemas/UpdateStatusRequest' responses: '200': description: Successfully updated order status '422': description: Status not matched content: application/json: schema: type: object properties: status: type: boolean example: false error: type: string example: Status not matched '404': description: Order not found '500': description: Internal server error components: securitySchemes: bearerAuth: type: http scheme: bearer bearerFormat: JWT schemas: User: type: object properties: name: type: string address: type: string email: type: string is_admin: type: boolean is_verified: type: boolean Order: type: object properties: id: type: integer example: 1 user_id: type: integer example: 1 total_price: type: number format: float example: 100.0 total_quantity: type: number format: float example: 2 status: type: string enum: [pending, success] example: pending createdAt: type: string format: date-time example: 2023-01-01T00:00:00.000Z items: type: array items: $ref: '#/components/schemas/OrderItem' OrderItem: type: object properties: order_id: type: integer example: 1 item_id: type: integer example: 1 quantity: type: number format: float example: 1 Item: type: object $ref: '#/components/schemas/Item' Item: type: object properties: id: type: integer example: 1 name: type: string example: Item name description: type: string example: Item description image: type: string example: item.jpg stock: type: integer example: 10 price: type: number format: float example: 50.0 UpdateStatusRequest: type: object properties: status: type: string enum: [pending, success] example: success CreateOrderRequest: type: object properties: items: type: array items: type: object properties: id: type: integer example: 1 quantity: type: number format: float example: 10