1
+ import { ApiOperator } from "@src/types/type" ;
2
+ import { AuthSocialController } from "./auth-social.controller" ;
3
+ import { OperationObject } from "@nestjs/swagger/dist/interfaces/open-api-spec.interface" ;
4
+ import { HttpStatus , applyDecorators } from "@nestjs/common" ;
5
+ import { ApiCreatedResponse , ApiOperation } from "@nestjs/swagger" ;
6
+ import { DetailResponseDto } from "@src/interceptors/success-interceptor/dto/detail-response.dto" ;
7
+ import { UserDto } from "@src/apis/users/dto/user.dto" ;
8
+ import { ValidationError } from "class-validator" ;
9
+ import { HttpException } from "@src/http-exceptions/exceptions/http.exception" ;
10
+ import { COMMON_ERROR_CODE } from "@src/constants/error/common/common-error-code.constant" ;
11
+ import { USER_ERROR_CODE } from "@src/constants/error/users/user-error-code.constant" ;
12
+ import { AUTH_ERROR_CODE } from "@src/constants/error/auth/auth-error-code.constant" ;
13
+
14
+ export const ApiAuthSocial : ApiOperator < keyof AuthSocialController > = {
15
+ CheckRegistration : (
16
+ apiOperationOptions : Required < Pick < Partial < OperationObject > , 'summary' > > &
17
+ Partial < OperationObject > ,
18
+ ) : PropertyDecorator => {
19
+ return applyDecorators (
20
+ ApiOperation ( {
21
+ operationId : 'CheckRegistration' ,
22
+ ...apiOperationOptions ,
23
+ } ) ,
24
+ ApiCreatedResponse ( {
25
+ type : Boolean
26
+ } ) ,
27
+ )
28
+ } ,
29
+ SignUp : (
30
+ apiOperationOptions : Required < Pick < Partial < OperationObject > , 'summary' > > &
31
+ Partial < OperationObject > ,
32
+ ) : PropertyDecorator => {
33
+ return applyDecorators (
34
+ ApiOperation ( {
35
+ operationId : 'Signup' ,
36
+ ...apiOperationOptions ,
37
+ } ) ,
38
+ DetailResponseDto . swaggerBuilder ( HttpStatus . CREATED , 'user' , UserDto ) ,
39
+ HttpException . swaggerBuilder (
40
+ HttpStatus . BAD_REQUEST ,
41
+ [ COMMON_ERROR_CODE . INVALID_REQUEST_PARAMETER ] ,
42
+ {
43
+ description :
44
+ '해당 필드는 request parameter 가 잘못된 경우에만 리턴됩니다.' ,
45
+ type : ValidationError ,
46
+ } ,
47
+ ) ,
48
+ HttpException . swaggerBuilder ( HttpStatus . CONFLICT , [
49
+ USER_ERROR_CODE . ALREADY_EXIST_USER_EMAIL ,
50
+ USER_ERROR_CODE . ALREADY_EXIST_USER_PHONE_NUMBER ,
51
+ ] ) ,
52
+ HttpException . swaggerBuilder ( HttpStatus . INTERNAL_SERVER_ERROR , [
53
+ COMMON_ERROR_CODE . SERVER_ERROR ,
54
+ ] ) ,
55
+ ) ;
56
+ } ,
57
+ SignIn : (
58
+ apiOperationOptions : Required < Pick < Partial < OperationObject > , 'summary' > > &
59
+ Partial < OperationObject > ,
60
+ ) : PropertyDecorator => {
61
+ return applyDecorators (
62
+ ApiOperation ( {
63
+ operationId : 'AuthSignIn' ,
64
+ ...apiOperationOptions ,
65
+ } ) ,
66
+ ApiCreatedResponse ( {
67
+ schema : {
68
+ properties : {
69
+ accessToken : {
70
+ description : 'access token' ,
71
+ type : 'string' ,
72
+ } ,
73
+ } ,
74
+ } ,
75
+ } ) ,
76
+ HttpException . swaggerBuilder (
77
+ HttpStatus . BAD_REQUEST ,
78
+ [
79
+ COMMON_ERROR_CODE . INVALID_REQUEST_PARAMETER ,
80
+ AUTH_ERROR_CODE . ACCOUNT_NOT_FOUND ,
81
+ AUTH_ERROR_CODE . DIFFERENT_ACCOUNT_INFORMATION ,
82
+ ] ,
83
+ {
84
+ description :
85
+ '해당 필드는 request parameter 가 잘못된 경우에만 리턴됩니다.' ,
86
+ type : ValidationError ,
87
+ } ,
88
+ ) ,
89
+ HttpException . swaggerBuilder ( HttpStatus . INTERNAL_SERVER_ERROR , [
90
+ COMMON_ERROR_CODE . SERVER_ERROR ,
91
+ ] ) ,
92
+ ) ;
93
+ } ,
94
+ }
0 commit comments