Skip to content

Commit

Permalink
#39 feat : make swagger for user's api (#40)
Browse files Browse the repository at this point in the history
* #39 feat : make swagger for user's api

* #39 feat : add freelancer swagger
  • Loading branch information
0321minji authored May 4, 2024
1 parent baa7a8c commit e64fae1
Showing 1 changed file with 151 additions and 101 deletions.
252 changes: 151 additions & 101 deletions users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,111 +10,14 @@
from users.models import User
from users.services import UserService

from drf_yasg import openapi
from drf_yasg.utils import swagger_auto_schema

# Create your views here.

class ReformerSignUpApi(APIView):
permission_classes = (AllowAny,)

# class ReformerSignupInputSerializer(serializers.Serializer):
# #TODO전화번호 인증 구현 필요, 테스트 후 required=False 삭제 필요
# email = serializers.EmailField()
# password = serializers.CharField()
# nickname = serializers.CharField()
# phone = serializers.CharField()
# profile_image = serializers.ImageField(required = False)
# thumbnail_image = serializers.ImageField(required = False)
# agreement_terms = serializers.BooleanField(required = False)
# market_name = serializers.CharField(required = False)
# market_intro = serializers.CharField(required = False)
# links = serializers.CharField(required = False)
# area = serializers.CharField(required = False)
# work_style = serializers.ListField(required = False)
# school_ability = serializers.CharField(required = False)
# school_certification = serializers.FileField(required = False)
# career_ability = serializers.CharField(required = False)
# career_certification = serializers.FileField(required = False)
# license_ability =serializers.CharField(required = False)
# license_certification = serializers.FileField(required = False)
# freelancer_ability =serializers.CharField(required = False)
# freelancer_certification = serializers.FileField(required = False)
# contest_ability =serializers.CharField(required = False)
# contest_certification = serializers.FileField(required = False)
# etc_ability =serializers.CharField(required = False)
# etc_certification = serializers.FileField(required = False)
# special_material = serializers.ListField(required = False)

# def post(self, request):
# serializer = self.ReformerSignupInputSerializer(data = request.data)
# serializer.is_valid(raise_exception=True)
# data = serializer.validated_data

# UserService.reformer_sign_up(
# email = data.get('email'),
# password = data.get('password'),
# nickname = data.get('nickname'),
# phone = data.get('phone', None),
# profile_image = data.get('profile_image'),
# thumbnail_image = data.get('thumbnail_image'),
# agreement_terms= data.get('agreement_terms', False),
# market_name = data.get('market_name', None),
# market_intro = data.get('market_intro', None),
# links = data.get('links', None),
# area = data.get('area', None),
# work_style = data.get('work_style', []),
# school_ability = data.get('school_ability', None),
# school_certification = data.get('school_certification', None),
# career_ability = data.get('career_ability', None),
# career_certification = data.get('career_certification', None),
# license_ability =data.get('license_ability', None),
# license_certification = data.get('license_certification', None),
# freelancer_ability =data.get('license_ability', None),
# freelancer_certification = data.get('license_certification', None),
# contest_ability =data.get('license_ability', None),
# contest_certification = data.get('license_certification', None),
# etc_ability =data.get('license_ability', None),
# etc_certification = data.get('license_certification', None),
# special_material = data.get('special_material', []),
# )

# return Response({
# 'stauts': 'success',
# },status = status.HTTP_201_CREATED)


# class ConsumerSignUpApi(APIView):
# permission_classes = (AllowAny, )

# class ConsumerSignUpInputSerializer(serializers.Serializer):
# #TODO전화번호인증필요
# email = serializers.EmailField()
# password = serializers.CharField()
# nickname = serializers.CharField()
# phone = serializers.CharField(required = False)
# profile_image = serializers.ImageField(required = False)
# agreement_terms = serializers.BooleanField(required = False)
# area = serializers.CharField(required = False)
# prefer_style = serializers.ListField(required = False)

# def post(self, request):
# serializers = self.ConsumerSignUpInputSerializer(data = request.data)
# serializers.is_valid(raise_exception=True)
# data = serializers.validated_data

# UserService.consumer_sign_up(
# email = data.get('email'),
# password = data.get('password'),
# nickname = data.get('nickname',),
# phone = data.get('phone', None),
# profile_image = data.get('profile_image'),
# agreement_terms= data.get('agreement_terms', False),
# area = data.get('area', None),
# prefer_style = data.get('prefer_style',[]),
# )

# return Response({
# 'stauts': 'success',
# },status = status.HTTP_201_CREATED)

class UserSignUpApi(APIView):
permission_classes = (AllowAny,)

Expand All @@ -128,6 +31,26 @@ class UserSignUpInputSerializer(serializers.Serializer):
#얘도 드롭다운 방식이라서 나중에 필드 형식 변환 필요
area=serializers.CharField(required=False)

@swagger_auto_schema(
request_body=UserSignUpInputSerializer,
security=[],
operation_id='유저 회원가입 API',
operation_description="유저 기본 회원가입 API 입니다.",
responses={
"200":openapi.Response(
description="OK",
examples={
"application/json":{
"status":"success",
}
}
),
"400":openapi.Response(
description="Bad Request",
),
}
)

def post(self, request):
serializers = self.UserSignUpInputSerializer(data=request.data)
serializers.is_valid(raise_exception=True)
Expand Down Expand Up @@ -158,6 +81,33 @@ class UserLoginOutputSerializer(serializers.Serializer):
is_reformer = serializers.BooleanField()
is_consumer = serializers.BooleanField()

@swagger_auto_schema(
request_body=UserLoginInputSerializer,
security=[],
operation_description='유저가 로그인하는 API 입니다.',
operation_id='유저 로그인 API',
responses={
"200": openapi.Response(
description="OK",
examples={
"application/json": {
"status": "success",
"email":"[email protected]",
"refresh":"refresh토큰",
"access":"access토큰",
"nickname":"sdptech",
"is_reformer":"true",
"is_consumer":"true",
}
}
),
"400": openapi.Response(
description="Bad Request",
),
},
)

def post(self, request):
input_serializer = self.UserLoginInputSerializer(data=request.data)
input_serializer.is_valid(raise_exception=True)
Expand Down Expand Up @@ -191,6 +141,26 @@ class ReformerProfileInputSerializer(serializers.Serializer):
work_style=serializers.CharField()
special_material=serializers.CharField()

@swagger_auto_schema(
request_body=ReformerProfileInputSerializer,
security=[],
operation_id='리포머 프로필 등록 API',
operation_description="리포머의 추가 정보를 등록하는 API 입니다.",
responses={
"200":openapi.Response(
description="OK",
examples={
"application/json":{
"status":"success"
}
}
),
"400":openapi.Response(
description="Bad Request",
),
}
)

def post(self,request):
serializer = self.ReformerProfileInputSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
Expand Down Expand Up @@ -221,7 +191,27 @@ class CertificationCreateInputSerializer(serializers.Serializer):
issuing_authority = serializers.CharField()
issue_date = serializers.DateField()
proof_document = serializers.FileField()


@swagger_auto_schema(
request_body=CertificationCreateInputSerializer,
security=[],
operation_id='자격증 등록 API',
operation_description="리포머 프로필의 경력 작성 중 하나인 자격증 등록 API 입니다.",
responses={
"200":openapi.Response(
description="OK",
examples={
"application/json":{
"status":"success"
}
}
),
"400":openapi.Response(
description="Bad Request",
),
}
)

def post(self,request):
input_serializer = self.CertificationCreateInputSerializer(data=request.data)
input_serializer.is_valid(raise_exception=True)
Expand Down Expand Up @@ -249,6 +239,26 @@ class CompetitionCreateInputSerializer(serializers.Serializer):
organizer = serializers.CharField()
award_date = serializers.DateField()
proof_document = serializers.FileField()

@swagger_auto_schema(
request_body=CompetitionCreateInputSerializer,
security=[],
operation_id='공모전 등록 API',
operation_description="리포머 프로필의 경력 작성 중 하나인 공모전 등록 API 입니다.",
responses={
"200":openapi.Response(
description="OK",
examples={
"application/json":{
"status":"success"
}
}
),
"400":openapi.Response(
description="Bad Request",
),
}
)

def post(self,request):
input_serializer = self.CompetitionCreateInputSerializer(data=request.data)
Expand Down Expand Up @@ -279,6 +289,26 @@ class IntershipCreateInputSerializer(serializers.Serializer):
start_date = serializers.DateField()
end_date = serializers.DateField()
proof_document = serializers.FileField()

@swagger_auto_schema(
request_body=IntershipCreateInputSerializer,
security=[],
operation_id='인턴 등록 API',
operation_description="리포머 프로필 경력 등록 중 하나인 인턴 경력 등록 API 입니다.",
responses={
"200":openapi.Response(
description="OK",
examples={
"application/json":{
"status":"success"
}
}
),
"400":openapi.Response(
description="Bad Request",
),
}
)

def post(self,request):
input_serializer = self.IntershipCreateInputSerializer(data=request.data)
Expand Down Expand Up @@ -312,6 +342,26 @@ class FreelancerCreateInputSerializer(serializers.Serializer):
start_date = serializers.DateField()
end_date = serializers.DateField()
proof_document = serializers.FileField()

@swagger_auto_schema(
request_body=FreelancerCreateInputSerializer,
security=[],
operation_id='프리랜서 등록 API',
operation_description="리포머 프로필 경력 등록 중 하나인 프리랜서/외주 경력 등록 API 입니다.",
responses={
"200":openapi.Response(
description="OK",
examples={
"application/json":{
"status":"success"
}
}
),
"400":openapi.Response(
description="Bad Request",
),
}
)

def post(self,request):
input_serializer = self.FreelancerCreateInputSerializer(data=request.data)
Expand Down

0 comments on commit e64fae1

Please sign in to comment.