Integrate OpenAPI/Swagger documentation using drf-spectacular, enhancing API documentation with comprehensive guides and schema generation. Add multiple documentation files covering authentication, error codes, rate limiting, and migration strategies. Update settings and URLs to support new documentation endpoints and schema configurations.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
"""
|
||||
IGNY8 API Module
|
||||
IGNY8 API Package
|
||||
Unified API Standard v1.0
|
||||
"""
|
||||
|
||||
# Import schema extensions to register them with drf-spectacular
|
||||
from igny8_core.api import schema_extensions # noqa
|
||||
|
||||
39
backend/igny8_core/api/schema_extensions.py
Normal file
39
backend/igny8_core/api/schema_extensions.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""
|
||||
OpenAPI Schema Extensions for drf-spectacular
|
||||
Custom extensions for JWT authentication and unified response format
|
||||
"""
|
||||
from drf_spectacular.extensions import OpenApiAuthenticationExtension
|
||||
from drf_spectacular.plumbing import build_bearer_security_scheme_object
|
||||
from drf_spectacular.utils import extend_schema, OpenApiResponse
|
||||
from rest_framework import status
|
||||
|
||||
|
||||
class JWTAuthenticationExtension(OpenApiAuthenticationExtension):
|
||||
"""
|
||||
OpenAPI extension for JWT Bearer Token authentication
|
||||
"""
|
||||
target_class = 'igny8_core.api.authentication.JWTAuthentication'
|
||||
name = 'JWTAuthentication'
|
||||
|
||||
def get_security_definition(self, auto_schema):
|
||||
return build_bearer_security_scheme_object(
|
||||
header_name='Authorization',
|
||||
token_prefix='Bearer',
|
||||
bearer_format='JWT'
|
||||
)
|
||||
|
||||
|
||||
class CSRFExemptSessionAuthenticationExtension(OpenApiAuthenticationExtension):
|
||||
"""
|
||||
OpenAPI extension for CSRF-exempt session authentication
|
||||
"""
|
||||
target_class = 'igny8_core.api.authentication.CSRFExemptSessionAuthentication'
|
||||
name = 'SessionAuthentication'
|
||||
|
||||
def get_security_definition(self, auto_schema):
|
||||
return {
|
||||
'type': 'apiKey',
|
||||
'in': 'cookie',
|
||||
'name': 'sessionid'
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user