openapi: 3.0.3
info:
  title: RMS API
  version: 1.0.0
  description: |
    Starter OpenAPI spec for Restaurant Management System.
    Covers auth, uploads, categories, menu items, and push notifications.
servers:
  - url: http://127.0.0.1:8000
    description: Local

security:
  - bearerAuth: []

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
  schemas:
    LoginRequest:
      type: object
      required: [email, password]
      properties:
        email:
          type: string
          format: email
        password:
          type: string
    UploadImageResponse:
      type: object
      properties:
        message:
          type: string
        data:
          type: object
          properties:
            image_url:
              type: string
              format: uri
            path:
              type: string
            disk:
              type: string
    CategoryRequest:
      type: object
      required: [name, status]
      properties:
        name:
          type: string
        description:
          type: string
        image_url:
          type: string
          format: uri
        sort_order:
          type: integer
        status:
          type: string
          enum: [active, inactive]
    MenuItemRequest:
      type: object
      required: [category_id, name, price, status]
      properties:
        category_id:
          type: integer
        name:
          type: string
        description:
          type: string
        price:
          type: number
          format: float
        image_url:
          type: string
          format: uri
        is_vegetarian:
          type: boolean
        is_vegan:
          type: boolean
        is_spicy:
          type: boolean
        preparation_time:
          type: integer
        status:
          type: string
          enum: [active, inactive]
    PushSubscribeRequest:
      type: object
      required: [endpoint, public_key, auth_token, device_type]
      properties:
        endpoint:
          type: string
        public_key:
          type: string
        auth_token:
          type: string
        device_name:
          type: string
        device_type:
          type: string
          enum: [web, ios, android]

paths:
  /api/auth/login:
    post:
      security: []
      tags: [Auth]
      summary: Login
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LoginRequest'
      responses:
        '200':
          description: Success

  /api/auth/me:
    get:
      tags: [Auth]
      summary: Current user
      responses:
        '200':
          description: Success

  /api/uploads/image:
    post:
      tags: [Uploads]
      summary: Upload image
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required: [image]
              properties:
                image:
                  type: string
                  format: binary
                folder:
                  type: string
      responses:
        '201':
          description: Uploaded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UploadImageResponse'

  /api/categories:
    get:
      tags: [Categories]
      summary: List categories
      responses:
        '200':
          description: Success
    post:
      tags: [Categories]
      summary: Create category (JSON)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CategoryRequest'
      responses:
        '201':
          description: Created

  /api/categories/{id}:
    get:
      tags: [Categories]
      summary: Get category
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Success
    put:
      tags: [Categories]
      summary: Update category
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CategoryRequest'
      responses:
        '200':
          description: Updated

  /api/menu-items:
    get:
      tags: [Menu Items]
      summary: List menu items
      responses:
        '200':
          description: Success
    post:
      tags: [Menu Items]
      summary: Create menu item (JSON)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MenuItemRequest'
      responses:
        '201':
          description: Created

  /api/menu-items/{id}:
    get:
      tags: [Menu Items]
      summary: Get menu item
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: Success

  /api/push-notifications/subscribe:
    post:
      security: []
      tags: [Push Notifications]
      summary: Subscribe for push
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PushSubscribeRequest'
      responses:
        '201':
          description: Subscribed

  /api/push-notifications/unsubscribe:
    post:
      security: []
      tags: [Push Notifications]
      summary: Unsubscribe from push
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                endpoint:
                  type: string
      responses:
        '200':
          description: Unsubscribed

  /api/push-notifications/subscriptions:
    get:
      tags: [Push Notifications]
      summary: Get subscriptions
      responses:
        '200':
          description: Success

  /api/push-notifications/test:
    post:
      tags: [Push Notifications]
      summary: Send test push notification
      responses:
        '200':
          description: Success
