brew uninstall openssl curl
brew install openssl curl
export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig"
This file contains 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
@extend_schema( | |
request=PolymorphicProxySerializer( | |
component_name='Pet', | |
serializers=[ | |
CatSerializer, DogSerializer, | |
], | |
resource_type_field_name='pet_type', | |
) | |
) | |
def create(self, request, *args, **kwargs): |
This file contains 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
schemas: | |
Pet: | |
type: object | |
required: | |
- pet_type | |
properties: | |
pet_type: | |
type: string | |
discriminator: # JSON Object에서는 Object간 상속관계를 알수 없기때문에 이를 알기위한 구분자 필드가 필요하다. | |
propertyName: pet_type # 이 attr에 명시된 내용을 가지고 해당 JSON Object가 Dog Object인지 Cat Object인지를 구분할수있다. |
This file contains 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
class Pet: | |
... | |
class Cat(Pet): | |
... | |
class Dog(Pet): | |
... |
This file contains 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 drf_spectacular.utils import extend_schema_serializer | |
class UserSerializer(serializers.Serializer): | |
field_custom = serializers.SerializerMethodField(method_name="get_field_custom") | |
@extend_schema_field(OpenApiTypes.DATETIME) | |
def get_field_custom(self, object): | |
return '2021-03-06 20:54:00' |
This file contains 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", |
This file contains 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 study_example_app.schemas import USER_CREATE_EXAMPLES, USER_CREATE_QUERY_PARAM_EXAMPLES | |
... | |
@extend_schema( | |
tags=["사용자"], | |
summary="method레벨 데코레이터도 가능", | |
parameters=[ | |
OpenApiParameter(name="a_param", description="QueryParam1 입니다.", required=False, type=str), |
This file contains 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
@extend_schema( | |
tags=["사용자"], | |
summary="method레벨 데코레이터도 가능", | |
parameters=[ | |
OpenApiParameter(name="a_param", description="QueryParam1 입니다.", required=False, type=str), | |
OpenApiParameter( | |
name="date_param", | |
type=OpenApiTypes.DATE, | |
location=OpenApiParameter.QUERY, | |
description="Filter by release date", |
This file contains 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
@extend_schema( | |
tags=["사용자"], | |
summary="method레벨 데코레이터도 가능", | |
examples=[ | |
OpenApiExample( | |
name="success_example", | |
value={ | |
"username": "root", | |
"password": "django_1234", | |
"first_name": "성렬", |
This file contains 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 django.http import HttpResponse | |
from drf_spectacular.types import OpenApiTypes | |
from drf_spectacular.utils import OpenApiExample, OpenApiParameter, extend_schema_view | |
from drf_spectacular.utils import extend_schema | |
from rest_framework.decorators import action | |
from rest_framework.request import Request | |
from rest_framework.response import Response | |
from rest_framework.viewsets import ModelViewSet | |
from rest_framework import serializers, status |
NewerOlder