diff --git a/backend/config/__pycache__/settings.cpython-313.pyc b/backend/config/__pycache__/settings.cpython-313.pyc index 707d1a5..11ed20b 100644 Binary files a/backend/config/__pycache__/settings.cpython-313.pyc and b/backend/config/__pycache__/settings.cpython-313.pyc differ diff --git a/backend/config/settings.py b/backend/config/settings.py index 571e92e..6229f8b 100644 --- a/backend/config/settings.py +++ b/backend/config/settings.py @@ -42,6 +42,7 @@ INSTALLED_APPS = [ 'rest_framework', 'corsheaders', 'drf_spectacular', # Swagger文档生成 + 'drf_spectacular_sidecar', 'shop', ] @@ -150,12 +151,9 @@ SPECTACULAR_SETTINGS = { 'SERVE_INCLUDE_SCHEMA': True, 'SERVE_PERMISSIONS': ['rest_framework.permissions.AllowAny'], 'COMPONENT_SPLIT_REQUEST': True, - 'SCHEMA_PATH_PREFIX': r'/api/v[0-9]', - 'SWAGGER_UI_SETTINGS': { - 'deepLinking': True, - 'persistAuthorization': True, - 'displayOperationId': True, - }, + 'SWAGGER_UI_DIST': 'SIDECAR', + 'SWAGGER_UI_FAVICON_HREF': 'SIDECAR', + 'REDOC_DIST': 'SIDECAR', } # django-unfold配置 diff --git a/backend/shop/__pycache__/views.cpython-313.pyc b/backend/shop/__pycache__/views.cpython-313.pyc index 54f0fe2..757f1fc 100644 Binary files a/backend/shop/__pycache__/views.cpython-313.pyc and b/backend/shop/__pycache__/views.cpython-313.pyc differ diff --git a/backend/shop/views.py b/backend/shop/views.py index 38b8606..26e9016 100644 --- a/backend/shop/views.py +++ b/backend/shop/views.py @@ -2,9 +2,14 @@ from rest_framework import viewsets, status from rest_framework.decorators import action from rest_framework.response import Response from django.shortcuts import render +from drf_spectacular.utils import extend_schema, extend_schema_view, OpenApiParameter, OpenApiExample from .models import ESP32Config, Order, WeChatPayConfig, Service, ARService, ServiceOrder from .serializers import ESP32ConfigSerializer, OrderSerializer, ServiceSerializer, ARServiceSerializer, ServiceOrderSerializer +@extend_schema_view( + list=extend_schema(summary="获取AR服务列表", description="获取所有可用的AR服务"), + retrieve=extend_schema(summary="获取AR服务详情", description="获取指定AR服务的详细信息") +) class ARServiceViewSet(viewsets.ReadOnlyModelViewSet): """ AR服务列表和详情 @@ -21,6 +26,10 @@ def order_check_view(request): """ return render(request, 'shop/order_check.html') +@extend_schema_view( + list=extend_schema(summary="获取AI服务列表", description="获取所有可用的AI服务"), + retrieve=extend_schema(summary="获取AI服务详情", description="获取指定AI服务的详细信息") +) class ServiceViewSet(viewsets.ReadOnlyModelViewSet): """ AI服务列表和详情 @@ -35,6 +44,10 @@ class ServiceOrderViewSet(viewsets.ModelViewSet): queryset = ServiceOrder.objects.all() serializer_class = ServiceOrderSerializer +@extend_schema_view( + list=extend_schema(summary="获取ESP32配置列表", description="获取所有可用的ESP32硬件配置选项"), + retrieve=extend_schema(summary="获取ESP32配置详情", description="获取指定ESP32配置的详细信息") +) class ESP32ConfigViewSet(viewsets.ReadOnlyModelViewSet): """ 提供ESP32配置选项的列表和详情