remove specific api endpint from drf_yasg swagger
To remove a specific API endpoint from drf_yasg Swagger, you can use the exclude parameter of the get_schema_view method. Here's an example:
from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
# Define your API endpoints here
...
# Create a schema view
schema_view = get_schema_view(
openapi.Info(
title="My API",
default_version='v1',
description="My API description",
terms_of_service="https://www.example.com/terms/",
contact=openapi.Contact(email="contact@example.com"),
license=openapi.License(name="BSD License"),
),
# Exclude the endpoint you want to remove
public=True,
permission_classes=(permissions.AllowAny,),
# Add exclude parameter here
exclude=["api/v1/my-endpoint/"],
)
# Add your API endpoints to the router
...
In this example, the exclude parameter is set to ["api/v1/my-endpoint/"], which will remove the my-endpoint endpoint from the Swagger UI. You can add multiple endpoints to the exclude list to remove them from the Swagger UI.
原文地址: https://www.cveoy.top/t/topic/bs26 著作权归作者所有。请勿转载和采集!