I follow this link(and many other link): https://drf-spectacular.readthedocs.io/en/latest/faq.html#how-to-correctly-annotate-function-based-views-that-use-api-view but docs always show “No operations defined in spec!”
# url.py
urlpatterns = [
path("schema/", SpectacularAPIView.as_view(), name="schema"),
path("docs/", SpectacularSwaggerView.as_view(url_name="schema"), name="swagger-ui"),
path('pi/', FeedView.as_view()),
]
# views.py
class FeedView(APIView):
@extend_schema(responses=OpenApiTypes.FLOAT)
@api_view(['GET'])
def get(request, format=None):
pass # pragma: no cover
How can I resolve it? Thanks, attach sourcecode link https://firebasestorage.googleapis.com/v0/b/test-project-33489.appspot.com/o/Test%2Fmysite.zip?alt=media&token=b272288f-c743-4d44-8ad3-0a8b6977d265
refer this link: https://drf-spectacular.readthedocs.io/en/latest/faq.html#i-get-an-empty-schema-or-endpoints-are-missing If you use
drf-spectacular will not contain unversioned endpoints, every endpoints must be versioned. But single function base view cannot be assigned to one namespace. So you should use include like:
BTW,@api_view should below @extend_schema,pay attention to the order