Files
Django-Enhanced-API-Docs/conf.py

94 lines
3.7 KiB
Python
Raw Normal View History

2026-01-13 11:00:34 +01:00
def get_spectacular_settings(config):
"""
Generate SPECTACULAR_SETTINGS dict based on environment configuration.
Args:
config: Dictionary with environment configuration from dotenv
Returns:
Dictionary with drf-spectacular settings
"""
return {
'TITLE': 'Products API',
'DESCRIPTION': 'API for products, versions and permissions',
'VERSION': '1.0.0',
'SERVE_INCLUDE_SCHEMA': False,
'CONTACT': {
'email': 'holger.sielaff@kbs-gmbh.de',
},
'EXTERNAL_DOCS': {
'description': 'KBS GmbH',
'url': 'https://www.brainson.de',
},
'SERVERS': [
{'url': config.get('LOCAL_SWAGGER_HOST', 'http://localhost:8000'), 'description': 'The server'},
],
'SCHEMA_PATH_PREFIX': '/api/v1/',
'COMPONENT_SPLIT_REQUEST': True,
'COMPONENT_NO_READ_ONLY_REQUIRED': True,
'ENUM_NAME_OVERRIDES': {},
'PREPROCESSING_HOOKS': [],
'POSTPROCESSING_HOOKS': ['django_enhanced_apidocs.schema.postprocess_schema_enhancements'],
'SWAGGER_UI_SETTINGS': {
'deepLinking': True,
'persistAuthorization': True,
'displayOperationId': False,
'docExpansion': 'none',
'filter': True,
'showCommonExtensions': True,
'showExtensions': True,
'displayRequestDuration': True,
'syntaxHighlight.theme': 'monokai',
'tryItOutEnabled': True,
},
'REDOC_UI_SETTINGS': {
'hideDownloadButton': False,
'expandResponses': '200,201',
'pathInMiddlePanel': True,
'nativeScrollbars': True,
'theme': {
'spacing': {
'sectionVertical': 20,
},
'typography': {
'code': {
'wrap': True,
},
},
},
},
'SCHEMA_COERCE_METHOD_NAMES': {},
'APPEND_COMPONENTS': {
'securitySchemes': {
'basicAuth': {
'type': 'http',
'scheme': 'basic'
},
'cookieAuth': {
'type': 'apiKey',
'in': 'cookie',
'name': 'sessionid'
}
}
},
'SECURITY': [{'basicAuth': []}, {'cookieAuth': []}],
'TAGS': [
{'name': 'Products',
'description': 'Product management endpoints including versions, permissions, registrations, and file associations',
'viewsets': [
'ProductViewSet',
'ProductVersionViewSet',
'ProductPermissionViewSet',
'ProductRegistrationViewSet',
'ProductVersionFileViewSet', ]
},
{'name': 'Users', 'description': 'User management endpoints', 'viewsets': ['UserViewSet', ]},
{'name': 'Categories', 'description': 'Category management endpoints', 'viewsets': ['CategoryViewSet', ]},
{'name': 'Tags', 'description': 'Tag management endpoints', 'viewsets': ['TagViewSet', ]},
{'name': 'Files', 'description': 'File management endpoints', 'viewsets': ['FileViewSet', ]},
{'name': 'Support Tickets', 'description': 'Support ticket endpoints', 'viewsets': ['SupportTicketViewSet', 'TicketMessageViewSet']},
{'name': 'Customer Registration', 'description': 'Customer registration endpoints (no auth required)', },
{'name': 'Groups', 'description': 'Group/Project management endpoints including group/project types', 'viewsets': ['GroupViewSet', 'ProductGroupTypeViewSet']},
],
}