class CustomSchemaGeneratorOpenAPISchemaGenerator def get_endpointsself request # Get all endpoints from the parent class endpoints = superget_endpointsrequest # Remove th
There is no syntax error in the code. However, to improve readability and maintainability, we can add comments and use more descriptive variable names:
class CustomSchemaGenerator(OpenAPISchemaGenerator):
def get_endpoints(self, request):
# Get all endpoints from the parent class
all_endpoints = super().get_endpoints(request)
# Remove the '/admin/' endpoint
filtered_endpoints = [endpoint for endpoint in all_endpoints if "/admin/" not in endpoint[0]]
return filtered_endpoints
This code overrides the get_endpoints method of the OpenAPISchemaGenerator class to filter out any endpoints that contain the string "/admin/". The method returns a list of tuples where each tuple contains the endpoint URL and its corresponding view function.
原文地址: https://www.cveoy.top/t/topic/buql 著作权归作者所有。请勿转载和采集!