/api/auth/login:
  post:
    tags: [Authentication]
    summary: User login
    description: Authenticate user and receive JWT token via HTTP-only cookie
    requestBody:
      required: true
      content:
        application/json:
          schema:
            $ref: '../components/schemas/authentication.yaml#/LoginRequest'
        application/x-www-form-urlencoded:
          schema:
            $ref: '../components/schemas/authentication.yaml#/LoginRequest'
    responses:
      '200':
        description: Login successful
        headers:
          Set-Cookie:
            description: JWT token in HTTP-only cookie
            schema:
              type: string
        content:
          application/json:
            schema:
              $ref: '../components/schemas/authentication.yaml#/LoginResponse'
      '400':
        description: Missing username
        content:
          application/json:
            schema:
              $ref: '../components/schemas/common.yaml#/ErrorResponse'
      '401':
        description: Invalid credentials
        content:
          application/json:
            schema:
              $ref: '../components/schemas/common.yaml#/ErrorResponse'

/api/auth/logout:
  post:
    tags: [Authentication]
    summary: User logout
    description: Clear JWT token cookie
    security:
      - bearerAuth: []
    responses:
      '200':
        description: Logout successful
        content:
          application/json:
            schema:
              $ref: '../components/schemas/common.yaml#/SuccessResponse'

/api/auth/check:
  get:
    tags: [Authentication]
    summary: Check authentication status
    security:
      - bearerAuth: []
      - cookieAuth: []
    responses:
      '200':
        description: Authenticated
        content:
          application/json:
            schema:
              type: object
              properties:
                authenticated:
                  type: boolean
                user:
                  type: object
      '401':
        description: Not authenticated

/api/auth/register:
  post:
    tags: [Authentication]
    summary: Register new user
    requestBody:
      required: true
      content:
        application/json:
          schema:
            $ref: '../components/schemas/authentication.yaml#/RegisterRequest'
    responses:
      '201':
        description: User created
        content:
          application/json:
            schema:
              $ref: '../components/schemas/common.yaml#/SuccessResponse'

/api/auth/change_pass:
  post:
    tags: [Authentication]
    summary: Change password
    security:
      - bearerAuth: []
    requestBody:
      required: true
      content:
        application/json:
          schema:
            type: object
            required:
              - current_password
              - new_password
            properties:
              current_password:
                type: string
                format: password
              new_password:
                type: string
                format: password
    responses:
      '200':
        description: Password changed successfully

/v2/auth/login:
  post:
    tags: [Authentication]
    summary: V2 User login
    requestBody:
      required: true
      content:
        application/json:
          schema:
            $ref: '../components/schemas/authentication.yaml#/LoginRequest'
    responses:
      '200':
        description: Login successful
        content:
          application/json:
            schema:
              $ref: '../components/schemas/authentication.yaml#/LoginResponse'

/v2/auth/logout:
  post:
    tags: [Authentication]
    summary: V2 User logout
    responses:
      '200':
        description: Logout successful

/v2/auth/check:
  get:
    tags: [Authentication]
    summary: V2 Check authentication
    responses:
      '200':
        description: Auth check result

/v2/auth/register:
  post:
    tags: [Authentication]
    summary: V2 Register new user
    requestBody:
      required: true
      content:
        application/json:
          schema:
            $ref: '../components/schemas/authentication.yaml#/RegisterRequest'
    responses:
      '201':
        description: User created
