Skip to content

Commit

Permalink
Merge pull request #53 from Brints/swagger_doc
Browse files Browse the repository at this point in the history
doc: Documentation for verify phone number endpoint.
  • Loading branch information
aniebietafia authored Nov 4, 2024
2 parents b5bc4b4 + 421579f commit b9749d3
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 2 deletions.
2 changes: 1 addition & 1 deletion brints-estate-api/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class AuthController {
@ApiResponse(InternalServerErrorResponse)
@Post('register')
@Auth(AuthType.None)
@UseInterceptors(FileInterceptor('file'))
@UseInterceptors(FileInterceptor('image_url'))
@UseInterceptors(ClassSerializerInterceptor)
@UseFilters(HttpExceptionFilter)
async registerUser(
Expand Down
110 changes: 110 additions & 0 deletions brints-estate-api/src/users/swagger_docs/verify-phone-response.doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,113 @@ export const VerifyPhoneResponse = {
},
},
};

export const NotFoundPhoneNumberResponse = {
description: 'Phone number does not exist',
status: HttpStatus.NOT_FOUND,
schema: {
type: 'object',
properties: {
success: {
type: 'boolean',
example: false,
},
status_code: {
type: 'number',
example: HttpStatus.NOT_FOUND,
},
message: {
type: 'string',
example: 'Phone number does not exist.',
},
},
},
};

export const IncorrectPhoneNumberResponse = {
description: 'Incorrect phone number',
status: HttpStatus.BAD_REQUEST,
schema: {
type: 'object',
properties: {
success: {
type: 'boolean',
example: false,
},
status_code: {
type: 'number',
example: HttpStatus.BAD_REQUEST,
},
message: {
type: 'string',
example: 'Incorrect phone number.',
},
},
},
};

export const ForbiddenAccountVerifiedResponse = {
description: 'This account is already verified',
status: HttpStatus.FORBIDDEN,
schema: {
type: 'object',
properties: {
success: {
type: 'boolean',
example: false,
},
status_code: {
type: 'number',
example: HttpStatus.FORBIDDEN,
},
message: {
type: 'string',
example: 'This account is already verified.',
},
},
},
};

export const InvalidOTPResponse = {
description: 'Invalid OTP. Try again.',
status: HttpStatus.BAD_REQUEST,
schema: {
type: 'object',
properties: {
success: {
type: 'boolean',
example: false,
},
status_code: {
type: 'number',
example: HttpStatus.BAD_REQUEST,
},
message: {
type: 'string',
example: 'Invalid OTP. Try again.',
},
},
},
};

export const OTPExpiredResponse = {
description: 'OTP has expired. Please, generate a new one.',
status: HttpStatus.BAD_REQUEST,
schema: {
type: 'object',
properties: {
success: {
type: 'boolean',
example: false,
},
status_code: {
type: 'number',
example: HttpStatus.BAD_REQUEST,
},
message: {
type: 'string',
example: 'OTP has expired. Please, generate a new one.',
},
},
},
};
17 changes: 16 additions & 1 deletion brints-estate-api/src/users/users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ import {
Put,
} from '@nestjs/common';
import {
ApiBadRequestResponse,
ApiBearerAuth,
ApiForbiddenResponse,
ApiInternalServerErrorResponse,
ApiNotFoundResponse,
ApiOkResponse,
ApiOperation,
ApiResponse,
Expand Down Expand Up @@ -45,7 +48,14 @@ import {
InternalServerErrorResponse,
UnauthorizedUserVerifiedResponse,
} from './swagger_docs/common-reponses.doc';
import { VerifyPhoneResponse } from './swagger_docs/verify-phone-response.doc';
import {
ForbiddenAccountVerifiedResponse,
IncorrectPhoneNumberResponse,
InvalidOTPResponse,
NotFoundPhoneNumberResponse,
OTPExpiredResponse,
VerifyPhoneResponse,
} from './swagger_docs/verify-phone-response.doc';

@Controller('user')
@ApiTags('User Management')
Expand Down Expand Up @@ -78,6 +88,11 @@ export class UsersController {
summary: 'Verify registered user phone number.',
})
@ApiOkResponse(VerifyPhoneResponse)
@ApiNotFoundResponse(NotFoundPhoneNumberResponse)
@ApiBadRequestResponse(IncorrectPhoneNumberResponse)
@ApiForbiddenResponse(ForbiddenAccountVerifiedResponse)
@ApiBadRequestResponse(InvalidOTPResponse)
@ApiBadRequestResponse(OTPExpiredResponse)
@ApiInternalServerErrorResponse(InternalServerErrorResponse)
@Post('verify-phone')
@Auth(AuthType.None)
Expand Down

0 comments on commit b9749d3

Please sign in to comment.