diff --git a/config/conf/__init__.py b/config/conf/__init__.py index 6da5eb1..a0b05f0 100644 --- a/config/conf/__init__.py +++ b/config/conf/__init__.py @@ -1,3 +1,4 @@ from .rest_framework import * from .corsheaders import * -from .simple_jwt import * \ No newline at end of file +from .simple_jwt import * +from .drf_yasg import * \ No newline at end of file diff --git a/config/conf/drf_yasg.py b/config/conf/drf_yasg.py new file mode 100644 index 0000000..53142fc --- /dev/null +++ b/config/conf/drf_yasg.py @@ -0,0 +1,3 @@ +SWAGGER_SETTINGS = { + 'DEFAULT_MODEL_RENDERING': 'example' +} \ No newline at end of file diff --git a/core/apps/authentication/views/login.py b/core/apps/authentication/views/login.py index 1a5d308..0db3a31 100644 --- a/core/apps/authentication/views/login.py +++ b/core/apps/authentication/views/login.py @@ -22,32 +22,30 @@ class LoginApiView(generics.GenericAPIView, ResponseMixin): serializer_class = LoginSerializer queryset = User.objects.all() - # @swagger_auto_schema( - # operation_summary="Login", - # responses={ - # 200: openapi.Response( - # description="Success", - # schema=openapi.Schema( - # type=openapi.TYPE_OBJECT - # ), - # examples={ - # "application/json": { - # "status_code": 200, - # "status": "success", - # "message": "User topildi", - # "data": { - # "id": 1, - # "first_name": "Behruz", - # "last_name": "Xoliqberdiyev", - # "region": "nbve", - # "is_active": True, - # "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." - # } - # } - # } - # ) - # } - # ) + @swagger_auto_schema( + operation_summary="Login", + responses={ + 200: openapi.Response( + description="Success", + schema=None, + examples={ + "application/json": { + "status_code": 200, + "status": "success", + "message": "User topildi", + "data": { + "id": 1, + "first_name": "Behruz", + "last_name": "Xoliqberdiyev", + "region": "nbve", + "is_active": True, + "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." + } + } + } + ) + } + ) def post(self, request): try: serializer = self.serializer_class(data=request.data)