Files
chunyu_project/utils/swagger_generator.py
T
2026-08-05 23:59:15 +08:00

17 lines
643 B
Python

"""
Custom Swagger schema generator that handles conflicting views gracefully.
"""
from drf_yasg.generators import OpenAPISchemaGenerator
from drf_yasg.errors import SwaggerGenerationError
class GracefulOpenAPISchemaGenerator(OpenAPISchemaGenerator):
"""Custom generator that skips views that cause SwaggerGenerationError."""
def get_operation(self, view, path, prefix, method, components, request):
try:
return super().get_operation(view, path, prefix, method, components, request)
except SwaggerGenerationError:
# Skip views that have conflicting schema definitions
return None