I am not able to find any support for making a schema for the file upload API. The Swagger UI must have a button allowing a tester to upload a file for testing purposes. I am using firebase as a database so serializers and models don't come into the picture. I am using only Django's rest framework.
I have looked at drf-yasg's documentation that suggests using Operation for file upload. But It is a very abstract and obscure documentation.
Make sure you specify the parser_classes
in your view. By Default it's JSON parser which doesn't handle file uploads. Use either MultiPartParser
or FileUploadParser
class MyUploadView(CreateAPIView):
parser_classes = (MultiPartParser,)
...
@swagger_auto_schema(operation_description='Upload file...',)
@action(detail=False, methods=['post'])
def post(self, request, **kwargs):
# Code to handle file
Check out this issue. You can find how to use @swagger_auto_schema to create something like this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With