/api/user:
  get:
    tags: [User]
    summary: List users with pagination and search
    security:
      - bearerAuth: []
    parameters:
      - name: page
        in: query
        schema:
          type: integer
          default: 1
        description: Page number
      - name: per_page
        in: query
        schema:
          type: integer
          default: 20
        description: Items per page
      - name: search
        in: query
        schema:
          type: string
        description: Search term for username, email, or name
    responses:
      '200':
        description: List of users with pagination
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                  example: success
                message:
                  type: string
                  example: Users retrieved successfully
                data:
                  type: object
                  properties:
                    users:
                      type: array
                      items:
                        $ref: '../components/schemas/user.yaml#/User'
                    pagination:
                      type: object
                      properties:
                        current_page:
                          type: integer
                        per_page:
                          type: integer
                        total:
                          type: integer
                        total_pages:
                          type: integer
      '500':
        description: Server error

  post:
    tags: [User]
    summary: Create new user
    security:
      - bearerAuth: []
    requestBody:
      required: true
      content:
        application/json:
          schema:
            $ref: '../components/schemas/user.yaml#/UserCreate'
    responses:
      '201':
        description: User created successfully
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                  example: success
                message:
                  type: string
                  example: User created successfully
                data:
                  type: object
                  properties:
                    UserID:
                      type: integer
                    Username:
                      type: string
                    Email:
                      type: string
      '400':
        description: Validation failed
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                  example: failed
                message:
                  type: string
                  example: Validation failed
                data:
                  type: object
      '500':
        description: Server error


/api/user/{id}:
  get:
    tags: [User]
    summary: Get user by ID
    security:
      - bearerAuth: []
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
        description: User ID
    responses:
      '200':
        description: User details
        content:
          application/json:
            schema:
              $ref: '../components/schemas/user.yaml#/User'
      '404':
        description: User not found
      '500':
        description: Server error

  patch:
    tags: [User]
    summary: Update existing user
    security:
      - bearerAuth: []
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
        description: User ID
    requestBody:
      required: true
      content:
        application/json:
          schema:
            $ref: '../components/schemas/user.yaml#/UserUpdate'
    responses:
      '200':
        description: User updated successfully
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                  example: success
                message:
                  type: string
                  example: User updated successfully
                data:
                  type: object
                  properties:
                    UserID:
                      type: integer
                    updated_fields:
                      type: array
                      items:
                        type: string
      '400':
        description: UserID is required
      '404':
        description: User not found
      '500':
        description: Server error

  delete:
    tags: [User]
    summary: Delete user (soft delete)
    security:
      - bearerAuth: []
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
        description: User ID
    responses:
      '200':
        description: User deleted successfully
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                  example: success
                message:
                  type: string
                  example: User deleted successfully
                data:
                  type: object
                  properties:
                    UserID:
                      type: integer
      '404':
        description: User not found
      '500':
        description: Server error
