Created
April 18, 2021 05:01
-
-
Save KimSoungRyoul/a14073248c0780f7022545c074060b9f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth.models import User | |
from drf_spectacular.utils import OpenApiExample, extend_schema_serializer | |
from rest_framework.serializers import ModelSerializer | |
@extend_schema_serializer( | |
exclude_fields=("password",), | |
examples=[ | |
OpenApiExample( | |
"Valid example 1", | |
summary="short summary", | |
description="longer description", | |
value={ | |
"is_superuser": True, | |
"username": "string", | |
"first_name": "string", | |
"last_name": "string", | |
"email": "[email protected]", | |
"is_staff": False, | |
"is_active": True, | |
"date_joined": "2021-04-18 04:14:30", | |
"user_type": "customer", | |
}, | |
request_only=True, # view Layer에서 사용한 Example Object와 동일한 동작을 한다. | |
response_only=False, | |
), | |
], | |
) | |
class UserReadOnlySerializer(ModelSerializer): | |
class Meta: | |
model = User | |
depth = 1 | |
fields = "__all__" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment