openapi: 3.0.3
info:
  title: WBi Quality Platform API
  description: Local Quality Config Manager and Quality API contracts used to configure environments, execute quality gates, inspect test cases, and serve dashboard artifacts.
  version: 0.1.0
  contact:
    name: Western Badminton Inc
    email: admin@westernbadminton.com
servers:
  - url: http://localhost:8090
    description: Local Quality Config Manager
  - url: http://localhost:8080
    description: Local Quality API app
tags:
  - name: Config Manager Auth
    description: Local or WBi-admin authentication for the Quality Config Manager
  - name: Configuration
    description: Environment variable management for LOCAL, DEV, UAT, and PROD
  - name: Executions
    description: Quality gate execution from the UI
  - name: Test Cases
    description: Test case catalog and editable execution records
  - name: Dashboard
    description: Quality Dashboard artifacts
  - name: Quality API
    description: Runtime health endpoint for the TypeScript API app
paths:
  /api/auth/status:
    get:
      tags: [Config Manager Auth]
      summary: Get Config Manager authentication status
      responses:
        '200':
          description: Authentication status returned
  /api/auth/login:
    post:
      tags: [Config Manager Auth]
      summary: Login to Config Manager in local auth mode
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [username, password]
              properties:
                username:
                  type: string
                password:
                  type: string
                  format: password
      responses:
        '200':
          description: Login successful
        '401':
          description: Invalid username or password
        '409':
          description: WBi admin mode requires direct BFF admin login
  /api/auth/exchange:
    post:
      tags: [Config Manager Auth]
      summary: Exchange WBi admin session token for a Config Manager session
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [sessionToken]
              properties:
                sessionToken:
                  type: string
      responses:
        '200':
          description: Session exchanged
        '400':
          description: Exchange is not enabled in current auth mode
        '401':
          description: Invalid WBi admin session
  /api/auth/logout:
    post:
      tags: [Config Manager Auth]
      summary: Logout from Config Manager
      responses:
        '200':
          description: Logged out
  /api/config:
    get:
      tags: [Configuration]
      summary: Load environment configuration
      security:
        - configManagerCookie: []
      parameters:
        - name: environment
          in: query
          required: false
          schema:
            type: string
            enum: [LOCAL, DEV, UAT, PROD]
      responses:
        '200':
          description: Configuration fields, options, gates, and values returned
        '401':
          description: Config Manager authentication required
    put:
      tags: [Configuration]
      summary: Save environment configuration
      security:
        - configManagerCookie: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [values]
              properties:
                values:
                  type: object
                  additionalProperties:
                    type: string
      responses:
        '200':
          description: Environment configuration saved
        '401':
          description: Config Manager authentication required
  /api/executions/gates:
    get:
      tags: [Executions]
      summary: List executable quality gates
      security:
        - configManagerCookie: []
      responses:
        '200':
          description: Quality gates returned
  /api/executions:
    get:
      tags: [Executions]
      summary: List quality gate executions
      security:
        - configManagerCookie: []
      responses:
        '200':
          description: Executions returned
    post:
      tags: [Executions]
      summary: Start quality gate execution
      security:
        - configManagerCookie: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [gateId, environment]
              properties:
                gateId:
                  type: string
                  example: accessibility
                environment:
                  type: string
                  enum: [LOCAL, DEV, UAT, PROD]
      responses:
        '202':
          description: Execution started
        '400':
          description: Unknown execution gate
  /api/executions/{id}:
    get:
      tags: [Executions]
      summary: Get quality gate execution
      security:
        - configManagerCookie: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Execution returned
        '404':
          description: Execution not found
  /api/test-cases:
    get:
      tags: [Test Cases]
      summary: Get test case execution store
      security:
        - configManagerCookie: []
      responses:
        '200':
          description: Runs and test cases returned
    put:
      tags: [Test Cases]
      summary: Save editable test cases
      security:
        - configManagerCookie: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [testCases]
              properties:
                testCases:
                  type: array
                  items:
                    type: object
      responses:
        '200':
          description: Test case store saved
        '400':
          description: Invalid test case payload
  /api/health:
    get:
      tags: [Quality API]
      summary: Config Manager API health
      responses:
        '200':
          description: Config Manager API is healthy
  /health:
    get:
      tags: [Quality API]
      summary: TypeScript Quality API health
      servers:
        - url: http://localhost:8080
      responses:
        '200':
          description: Quality API is healthy
  /dashboard:
    get:
      tags: [Dashboard]
      summary: Open Quality Dashboard HTML
      responses:
        '200':
          description: Dashboard HTML returned
        '404':
          description: Dashboard has not been generated
  /dashboard.json:
    get:
      tags: [Dashboard]
      summary: Export Quality Dashboard JSON
      responses:
        '200':
          description: Dashboard JSON returned
        '404':
          description: Dashboard has not been generated
  /dashboard.pdf:
    get:
      tags: [Dashboard]
      summary: Export Quality Dashboard PDF
      responses:
        '200':
          description: Dashboard PDF returned
        '404':
          description: Dashboard has not been generated
components:
  securitySchemes:
    configManagerCookie:
      type: apiKey
      in: cookie
      name: wbi_quality_config_session
