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 .rest_framework import *
from .corsheaders import * from .corsheaders import *
from .simple_jwt 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 serializer_class = LoginSerializer
queryset = User.objects.all() queryset = User.objects.all()
# @swagger_auto_schema( @swagger_auto_schema(
# operation_summary="Login", operation_summary="Login",
# responses={ responses={
# 200: openapi.Response( 200: openapi.Response(
# description="Success", description="Success",
# schema=openapi.Schema( schema=None,
# type=openapi.TYPE_OBJECT examples={
# ), "application/json": {
# examples={ "status_code": 200,
# "application/json": { "status": "success",
# "status_code": 200, "message": "User topildi",
# "status": "success", "data": {
# "message": "User topildi", "id": 1,
# "data": { "first_name": "Behruz",
# "id": 1, "last_name": "Xoliqberdiyev",
# "first_name": "Behruz", "region": "nbve",
# "last_name": "Xoliqberdiyev", "is_active": True,
# "region": "nbve", "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
# "is_active": True, }
# "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." }
# } }
# } )
# } }
# ) )
# }
# )
def post(self, request): def post(self, request):
try: try:
serializer = self.serializer_class(data=request.data) serializer = self.serializer_class(data=request.data)