Как дать разное описание разным конечным точкам url в drf-spectacular

У меня следующие взгляды:

@extend_schema(tags=["admin"])
class CompanyForAdminView(APIView):
    permission_classes = [IsAuthenticated, IsAdmin]
    filter_backends = [SearchFilter]
    search_fields = ["email", "company_profile__name"]

    def get(self, request, id=None):
        if id:
            company = get_object_or_404(Company, id=id)
            serializer = CompanyRetrieveSerializer(company)
            return Response(serializer.data)
        else:
            companies = Company.objects.all()
            for backend in list(self.filter_backends):
                companies = backend().filter_queryset(request, companies, self)
            paginator = LimitOffsetPagination()
            result = paginator.paginate_queryset(companies, request)
            serializer = CompanyListSerializer(result, many=True)
            return paginator.get_paginated_response(serializer.data)


@extend_schema(tags=["admin"])
class EmployeeForAdminView(APIView):
    permission_classes = [IsAuthenticated, IsAdmin]
    filter_backends = [SearchFilter]
    search_fields = ["first_name", "middle_name", "last_name", "designation"]

    def get(self, request, company_id, id=None):
        if id:
            employee = get_object_or_404(Employee, id=id)
            serializer = EmployeeRetrieveSerializer(employee)
            return Response(serializer.data)
        else:
            company = get_object_or_404(Company, id=company_id)
            employees = company.employees.all()
            for backend in list(self.filter_backends):
                employees = backend().filter_queryset(request, employees, self)
            paginator = LimitOffsetPagination()
            result = paginator.paginate_queryset(employees, request)
            serializer = EmployeeListSerializer(result, many=True)
            return paginator.get_paginated_response(serializer.data)

У меня есть два разных маршрута для каждого вида в моем urls.py.

from django.urls import path, include
from rest_framework.routers import DefaultRouter
from drf_spectacular.utils import extend_schema_view, extend_schema
from account.views import (
    CompanyView,
    EmployeeView,
    AddEmployeesFromExcelView,
    PasswordChangeView,
    ForgotPasswordAPIView,
    ResetPasswordTokenCheckAPIView,
    CompanyForAdminView,
    EmployeeForAdminView,
)

app_name = "account"

...

urlpatterns = [
    ...,
    path("admin/company/", CompanyForAdminView.as_view(), name="admin_companies"),
    path(
        "admin/company/<int:id>/", CompanyForAdminView.as_view(), name="admin_companies"
    ),
    path(
        "admin/<int:company_id>/employee/",
        extend_schema_view(
            get=extend_schema(
                summary="List Employees",
                description="List of employees for a given company.",
                tags=["admin"],
            )
        )(EmployeeForAdminView.as_view()),
        name="admin_employees",
    ),
    path(
        "admin/<int:company_id>/employee/<int:id>/",
        extend_schema_view(
            get=extend_schema(
                summary="Retrieve Employee",
                description="Retrieve details of a specific employee.",
                tags=["admin"],
            )
        )(EmployeeForAdminView.as_view()),
        name="admin_employees",
    ),
]

Я пытаюсь добавить разные описания и документы для SwaggerUI для разных конечных точек. Но когда я делаю так, как показано выше, обе конечные точки в итоге имеют одно и то же описание, которое является описанием нижней конечной точки (admin/<int:company_id>/employee/<int:id>/). Как я могу написать описание конечных точек на уровне url с помощью drf-spectacular?

Вернуться на верх