Notification texts go here Contact Us Buy Now!

How to hide Some API in django rest swagger?

How to Hide Some APIs in Django REST Swagger

Hiding APIs in Django REST Swagger can be achieved using two methods:

  1. Using `swagger_schema = None`
  2. This method is used to exclude a specific view from schema generation. To use this method, add the following code above the view in your `views.py` file:

        from drf_yasg.utils import swagger_auto_schema
    
        @swagger_auto_schema(auto_schema=None)
        def get(self, request):
            pass
      
  3. Using the `@swagger_auto_schema` decorator
  4. This method is used to hide a specific view from schema generation. To use this method, add the following code above the view in your `views.py` file:

        from drf_yasg.utils import swagger_auto_schema
    
        @swagger_auto_schema(auto_schema=False)
        def get(self, request):
            pass
      

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.