How to mark a method as deprecated with swagger_auto_schema?

Viewed 474

I'm using swagger-auto-schema to document my endpoints API using django-rest-framework, swagger, and drf-yasg. Is there a way to mark the API endpoints in the documentation as deprecated?

1 Answers

You should set deprecated=True parameter on the swagger_auto_schema decorator.

Example:

class MyViewSet(viewsets.ModelViewSet):
    ...

    @swagger_auto_schema(deprecated=True)
    def list(self, request, *args, **kwargs):
        return super().list(request, *args, **kwargs)
Related