openapi: 3.0.0
info:
  title: VoiceCommit Widget Integration API
  description: API for helping AI assistants integrate VoiceCommit voice feedback widgets into websites
  version: 1.0.0
  contact:
    email: support@voicecommit.com
  license:
    name: MIT
servers:
  - url: https://app.voicecommit.com
    description: Production server

paths:
  /api/ai/widget-integration:
    get:
      summary: Get widget integration documentation
      description: Returns integration documentation in JSON or Markdown format for AI assistants
      parameters:
        - in: query
          name: format
          schema:
            type: string
            enum: [json, markdown]
            default: json
          description: Format of the response (json for structured data, markdown for human-readable)
      responses:
        '200':
          description: Integration documentation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/IntegrationSpec'
            text/markdown:
              schema:
                type: string
                description: Markdown-formatted integration documentation
        '400':
          description: Invalid format parameter
        '500':
          description: Server error

components:
  schemas:
    IntegrationSpec:
      type: object
      description: Complete widget integration specification
      properties:
        name:
          type: string
          example: "VoiceCommit Widget Integration"
        version:
          type: string
          example: "1.0.0"
        description:
          type: string
          example: "AI-optimized specification for integrating VoiceCommit voice feedback widgets"
        requirements:
          type: object
          properties:
            https:
              type: boolean
              description: HTTPS required for voice recording
            microphone:
              type: boolean
              description: Microphone permission required
            browsers:
              type: array
              items:
                type: string
              example: ["Chrome 60+", "Firefox 55+", "Safari 11+", "Edge 79+"]
        integration:
          type: object
          properties:
            basic:
              type: object
              description: Simple automatic initialization
              properties:
                description:
                  type: string
                  example: "Automatic initialization - simplest integration"
                code:
                  type: object
                  properties:
                    css:
                      type: string
                      example: "https://app.voicecommit.com/api/widget/{WIDGET_ID}/widget.css"
                    javascript:
                      type: string
                      example: "https://app.voicecommit.com/api/widget/{WIDGET_ID}/widget.js"
                example:
                  type: string
                  example: "<link rel=\"stylesheet\" href=\"https://app.voicecommit.com/api/widget/{WIDGET_ID}/widget.css\">\n<script src=\"https://app.voicecommit.com/api/widget/{WIDGET_ID}/widget.js\" data-widget-id=\"{WIDGET_ID}\"></script>"
        frameworks:
          type: object
          description: Framework-specific integration examples
          properties:
            react:
              type: object
              properties:
                type:
                  type: string
                  example: "useEffect"
                cleanup:
                  type: boolean
                  example: true
                example:
                  type: string
                  description: Complete React component code example
            vue:
              type: object
              properties:
                type:
                  type: string
                  example: "mounted"
                lifecycle:
                  type: string
                  example: "mounted"
                example:
                  type: string
                  description: Vue.js integration code example
            angular:
              type: object
              properties:
                type:
                  type: string
                  example: "ngOnInit"
                lifecycle:
                  type: string
                  example: "OnInit"
                example:
                  type: string
                  description: Angular component integration code example
        security:
          type: object
          description: Security requirements and CSP configuration
          properties:
            csp:
              type: object
              properties:
                script-src:
                  type: string
                  example: "https://app.voicecommit.com"
                style-src:
                  type: string
                  example: "https://app.voicecommit.com"
                connect-src:
                  type: string
                  example: "https://app.voicecommit.com"
                media-src:
                  type: string
                  example: "blob:"
        troubleshooting:
          type: object
          description: Common issues and solutions
          properties:
            common_issues:
              type: array
              items:
                type: object
                properties:
                  issue:
                    type: string
                    example: "Widget not appearing"
                  solutions:
                    type: array
                    items:
                      type: string
                    example: ["Verify widget ID is correct", "Check domain is authorized"]
        setup_steps:
          type: array
          description: Step-by-step setup instructions
          items:
            type: object
            properties:
              step:
                type: integer
              action:
                type: string
          example:
            - step: 1
              action: "Create widget at https://app.voicecommit.com/widgets/new"
            - step: 2
              action: "Copy widget ID from settings page"
        ai_assistant_instructions:
          type: object
          description: Instructions for AI assistants helping with integration
          properties:
            when_helping_with_integration:
              type: array
              items:
                type: string
              example: ["Always ask for widget ID first", "Remind about HTTPS requirement"]
            common_ai_tasks:
              type: array
              items:
                type: string
              example: ["Generate integration code for specific frameworks", "Debug CSP issues"]