openapi: 3.0.3 info: title: AutoStore API description: API for the AutoStore system - a system to store items with expiration dates that automatically orders new items when they expire. version: 1.0.0 servers: - url: http://localhost:3000/api/v1 description: Development server paths: /login: post: summary: User login description: Authenticates a user and returns a JWT token requestBody: required: true content: application/json: schema: type: object required: - username - password properties: username: type: string description: User's username or email password: type: string description: User's password responses: '200': description: Login successful content: application/json: schema: allOf: - $ref: '#/components/schemas/JsendSuccess' - type: object properties: data: type: object properties: user: $ref: '#/components/schemas/User' token: type: string description: JWT token for authentication '401': description: Invalid credentials content: application/json: schema: $ref: '#/components/schemas/JsendError' /items: get: summary: Get list of items description: Returns a list of all items for the authenticated user security: - bearerAuth: [] responses: '200': description: List of items content: application/json: schema: allOf: - $ref: '#/components/schemas/JsendSuccess' - type: object properties: data: type: array items: $ref: '#/components/schemas/Item' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/JsendError' post: summary: Create a new item description: Creates a new item for the authenticated user security: - bearerAuth: [] requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ItemInput' responses: '201': description: Item created successfully content: application/json: schema: allOf: - $ref: '#/components/schemas/JsendSuccess' - type: object properties: data: $ref: '#/components/schemas/Item' '400': description: Invalid input content: application/json: schema: $ref: '#/components/schemas/JsendError' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/JsendError' /items/{id}: get: summary: Get item by ID description: Returns a specific item by its ID security: - bearerAuth: [] parameters: - name: id in: path required: true description: Item ID schema: type: string responses: '200': description: Item details content: application/json: schema: allOf: - $ref: '#/components/schemas/JsendSuccess' - type: object properties: data: $ref: '#/components/schemas/Item' '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/JsendError' '404': description: Item not found content: application/json: schema: $ref: '#/components/schemas/JsendError' delete: summary: Delete an item description: Deletes an existing item security: - bearerAuth: [] parameters: - name: id in: path required: true description: Item ID schema: type: string responses: '204': description: Item deleted successfully '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/JsendError' '404': description: Item not found content: application/json: schema: $ref: '#/components/schemas/JsendError' components: securitySchemes: bearerAuth: type: http scheme: bearer bearerFormat: JWT schemas: JsendSuccess: type: object properties: status: type: string example: success data: type: object description: Response data JsendError: type: object properties: status: type: string example: error message: type: string description: Error message code: type: integer description: Error code data: type: object description: Additional error data User: type: object properties: id: type: string description: User ID username: type: string description: User's username or email Item: type: object properties: id: type: string description: Item ID name: type: string description: Item name expirationDate: type: string format: date-time description: Item expiration date orderUrl: type: string format: uri description: URL to send order request when item expires userId: type: string description: ID of the user who owns this item ItemInput: type: object required: - name - expirationDate - orderUrl properties: name: type: string description: Item name expirationDate: type: string format: date-time description: Item expiration date orderUrl: type: string format: uri description: URL to send order request when item expires