swagger response togirlandi

This commit is contained in:
behruz-dev
2025-11-26 14:38:28 +05:00
parent ee9b626666
commit 830ab74b80
3 changed files with 29 additions and 27 deletions

View File

@@ -1,3 +1,4 @@
from .rest_framework import *
from .corsheaders import *
from .simple_jwt import *
from .drf_yasg import *

3
config/conf/drf_yasg.py Normal file
View File

@@ -0,0 +1,3 @@
SWAGGER_SETTINGS = {
'DEFAULT_MODEL_RENDERING': 'example'
}

View File

@@ -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)