HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/calendar/calendar-venv/lib/python3.12/site-packages/drf_spectacular/checks.py
from django.core.checks import Error, Warning, register


@register(deploy=True)
def schema_check(app_configs, **kwargs):
    """ Perform dummy generation and emit warnings/errors as part of Django's check framework """
    from drf_spectacular.drainage import GENERATOR_STATS
    from drf_spectacular.settings import spectacular_settings

    if not spectacular_settings.ENABLE_DJANGO_DEPLOY_CHECK:
        return []

    errors = []
    try:
        with GENERATOR_STATS.silence():
            spectacular_settings.DEFAULT_GENERATOR_CLASS().get_schema(request=None, public=True)
    except Exception as exc:
        errors.append(
            Error(f'Schema generation threw exception "{exc}"', id='drf_spectacular.E001')
        )
    if GENERATOR_STATS:
        for w in GENERATOR_STATS._warn_cache:
            errors.append(Warning(w, id='drf_spectacular.W001'))
        for e in GENERATOR_STATS._error_cache:
            errors.append(Warning(e, id='drf_spectacular.W002'))
    return errors