Skip to content

v1.3.5: Critical Swagger UI Loading Fix

Choose a tag to compare

@CodeMath CodeMath released this 31 Aug 14:46
· 16 commits to main since this release

πŸ”§ Critical Swagger UI Loading Fix - Enhanced Error Handling

Critical fix: Improved error handling for Swagger UI initialization timing issues.

πŸ› οΈ Bug Fixes

  • πŸ”„ Enhanced Retry Logic - Fixed TypeError when window.ui is undefined during Swagger UI loading
  • πŸ“Š Better Error Handling - Added try-catch around Swagger UI access with detailed logging
  • ⏱️ Improved Timing - Increased retry attempts (20x) for slower Swagger UI initialization
  • πŸ” Enhanced Debugging - More detailed console logs for troubleshooting UI loading issues

πŸ”§ Technical Improvements

  • Error-Safe UI Checking:
    try {
        if (window.ui && typeof window.ui.preauthorizeApiKey === 'function') {
            // Safe access with type checking
        }
    } catch (error) {
        console.log('πŸ” UI check error (will retry):', error.message);
    }
  • Robust Retry Mechanism: 20 attempts over 10 seconds for UI readiness
  • Graceful Degradation: Clear error messages when Swagger UI fails to load

🎯 What This Fixes

  • TypeError Prevention: No more "Cannot read properties of undefined" errors
  • Better Reliability: AUTO_AUTHORIZE works consistently across different loading speeds
  • Enhanced Debugging: Clear console logs to diagnose Swagger UI loading issues

πŸ”„ Backward Compatibility

  • 100% Compatible: All existing functionality preserved
  • Zero Breaking Changes: Pure bug fix release

πŸ“¦ Installation

pip install --upgrade drf-spectacular-auth==1.3.5

This specifically addresses the console error you encountered:

TypeError: Cannot read properties of undefined (reading 'preauthorizeApiKey')

πŸ”— Links