remove a endpoind using class CustomSchemaGeneratorOpenAPISchemaGenerator
To remove an endpoint using the CustomSchemaGenerator class, you will need to override the get_endpoints() method and remove the endpoint from the list of endpoints returned.
Here's an example of how to remove an endpoint with the path /example/:
from drf_yasg.generators import OpenAPISchemaGenerator
class CustomSchemaGenerator(OpenAPISchemaGenerator):
def get_endpoints(self, request):
endpoints = super().get_endpoints(request)
# Remove the endpoint with the path '/example/'
endpoints = [e for e in endpoints if e.path != '/example/']
return endpoints
In this example, we are calling the get_endpoints() method of the parent class using super(), and then filtering out the endpoint with the path /example/ using a list comprehension.
You can customize this example to remove any other endpoint by changing the condition used to filter out the endpoint.
原文地址: https://www.cveoy.top/t/topic/buQJ 著作权归作者所有。请勿转载和采集!