Enhance API documentation and schema management by implementing explicit tag configurations for Swagger and ReDoc. Introduce postprocessing hooks to filter auto-generated tags, ensuring only defined tags are used. Update viewsets across various modules to utilize the new tagging system, improving clarity and organization in API documentation.

This commit is contained in:
IGNY8 VPS (Salman)
2025-11-16 04:48:14 +00:00
parent dee2a36ff0
commit 3694e40c04
11 changed files with 363 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ from rest_framework import viewsets, status
from rest_framework.decorators import action
from rest_framework.response import Response
from django.db import transaction
from drf_spectacular.utils import extend_schema, extend_schema_view
from igny8_core.api.base import AccountModelViewSet
from igny8_core.api.response import success_response, error_response
from igny8_core.api.throttles import DebugScopedRateThrottle
@@ -16,6 +17,14 @@ from django.conf import settings
logger = logging.getLogger(__name__)
@extend_schema_view(
list=extend_schema(tags=['System']),
retrieve=extend_schema(tags=['System']),
update=extend_schema(tags=['System']),
test_connection=extend_schema(tags=['System']),
task_progress=extend_schema(tags=['System']),
get_image_generation_settings=extend_schema(tags=['System']),
)
class IntegrationSettingsViewSet(viewsets.ViewSet):
"""
ViewSet for managing integration settings (OpenAI, Runware, GSC)

View File

@@ -6,6 +6,7 @@ from rest_framework import viewsets, status, permissions
from rest_framework.decorators import action
from rest_framework.response import Response
from django.db import transaction
from drf_spectacular.utils import extend_schema, extend_schema_view
from igny8_core.api.base import AccountModelViewSet
from igny8_core.api.response import success_response, error_response
from igny8_core.api.authentication import JWTAuthentication, CSRFExemptSessionAuthentication
@@ -18,6 +19,14 @@ from .settings_serializers import (
)
@extend_schema_view(
list=extend_schema(tags=['System']),
create=extend_schema(tags=['System']),
retrieve=extend_schema(tags=['System']),
update=extend_schema(tags=['System']),
partial_update=extend_schema(tags=['System']),
destroy=extend_schema(tags=['System']),
)
class SystemSettingsViewSet(AccountModelViewSet):
"""
ViewSet for managing system-wide settings (admin only for write operations)
@@ -61,6 +70,14 @@ class SystemSettingsViewSet(AccountModelViewSet):
return success_response(data=serializer.data, request=request)
@extend_schema_view(
list=extend_schema(tags=['System']),
create=extend_schema(tags=['System']),
retrieve=extend_schema(tags=['System']),
update=extend_schema(tags=['System']),
partial_update=extend_schema(tags=['System']),
destroy=extend_schema(tags=['System']),
)
class AccountSettingsViewSet(AccountModelViewSet):
"""
ViewSet for managing account-level settings
@@ -113,6 +130,14 @@ class AccountSettingsViewSet(AccountModelViewSet):
serializer.save(account=account)
@extend_schema_view(
list=extend_schema(tags=['System']),
create=extend_schema(tags=['System']),
retrieve=extend_schema(tags=['System']),
update=extend_schema(tags=['System']),
partial_update=extend_schema(tags=['System']),
destroy=extend_schema(tags=['System']),
)
class UserSettingsViewSet(AccountModelViewSet):
"""
ViewSet for managing user-level settings
@@ -171,6 +196,14 @@ class UserSettingsViewSet(AccountModelViewSet):
serializer.save(user=user, account=account)
@extend_schema_view(
list=extend_schema(tags=['System']),
create=extend_schema(tags=['System']),
retrieve=extend_schema(tags=['System']),
update=extend_schema(tags=['System']),
partial_update=extend_schema(tags=['System']),
destroy=extend_schema(tags=['System']),
)
class ModuleSettingsViewSet(AccountModelViewSet):
"""
ViewSet for managing module-specific settings
@@ -242,6 +275,14 @@ class ModuleSettingsViewSet(AccountModelViewSet):
serializer.save(account=account)
@extend_schema_view(
list=extend_schema(tags=['System']),
create=extend_schema(tags=['System']),
retrieve=extend_schema(tags=['System']),
update=extend_schema(tags=['System']),
partial_update=extend_schema(tags=['System']),
destroy=extend_schema(tags=['System']),
)
class AISettingsViewSet(AccountModelViewSet):
"""
ViewSet for managing AI-specific settings

View File

@@ -12,6 +12,7 @@ from django.db import transaction, connection
from django.core.cache import cache
from django.utils import timezone
from django_filters.rest_framework import DjangoFilterBackend
from drf_spectacular.utils import extend_schema, extend_schema_view
from igny8_core.api.base import AccountModelViewSet
from igny8_core.api.response import success_response, error_response
from igny8_core.api.permissions import IsEditorOrAbove, IsAuthenticatedAndActive, IsViewerOrAbove
@@ -23,6 +24,14 @@ from .serializers import AIPromptSerializer, AuthorProfileSerializer, StrategySe
logger = logging.getLogger(__name__)
@extend_schema_view(
list=extend_schema(tags=['System']),
create=extend_schema(tags=['System']),
retrieve=extend_schema(tags=['System']),
update=extend_schema(tags=['System']),
partial_update=extend_schema(tags=['System']),
destroy=extend_schema(tags=['System']),
)
class AIPromptViewSet(AccountModelViewSet):
"""
ViewSet for managing AI prompts
@@ -192,6 +201,14 @@ class AIPromptViewSet(AccountModelViewSet):
)
@extend_schema_view(
list=extend_schema(tags=['System']),
create=extend_schema(tags=['System']),
retrieve=extend_schema(tags=['System']),
update=extend_schema(tags=['System']),
partial_update=extend_schema(tags=['System']),
destroy=extend_schema(tags=['System']),
)
class AuthorProfileViewSet(AccountModelViewSet):
"""
ViewSet for managing Author Profiles
@@ -210,6 +227,14 @@ class AuthorProfileViewSet(AccountModelViewSet):
filterset_fields = ['is_active', 'language']
@extend_schema_view(
list=extend_schema(tags=['System']),
create=extend_schema(tags=['System']),
retrieve=extend_schema(tags=['System']),
update=extend_schema(tags=['System']),
partial_update=extend_schema(tags=['System']),
destroy=extend_schema(tags=['System']),
)
class StrategyViewSet(AccountModelViewSet):
"""
ViewSet for managing Strategies