Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCS]: Enhance Swagger Docs with Auth & Examples for Waitlist & Newsletter Endpoints #1333

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from
14 changes: 7 additions & 7 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ JWT_SECRET=someSecrets
JWT_EXPIRY_TIMEFRAME=3600
REDIS_HOST=localhost
REDIS_PORT=6379
DB_TYPE=
DB_USERNAME=
DB_PASSWORD=
DB_HOST=
DB_NAME=hng
DB_TYPE=postgres
DB_USERNAME=nacho
DB_PASSWORD=nacho
DB_HOST=localhost
DB_NAME=hng_nestjs
DB_ENTITIES=dist/src/modules/**/entities/**/*.entity{.ts,.js}
DB_MIGRATIONS=dist/db/migrations/*{.ts,.js}
POSGRES_USER=$DB_USERNAME
Expand All @@ -24,8 +24,8 @@ DB_SSL=false
JWT_REFRESH_SECRET=bbp
JWT_REFRESH_EXPIRY_TIMEFRAME=15
GOOGLE_REDIRECT_URI=
GOOGLE_CLIENT_SECRET=
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=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
GOOGLE_CLIENT_ID=219247925548-r0mj3lopu0t9e5r4o2qct89hr4c3v9da.apps.googleusercontent.com
OAUTH_LOGIN_REDIRECT=
SMTP_HOST=
SMTP_PORT=587
Expand Down
18 changes: 2 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -407,25 +407,10 @@ todo.txt
# Docker compose
docker-compose.yml
data/
<<<<<<< HEAD
data/
docker-compose.yml
package-lock.json
.dev.env


package-lock.json
docker-compose.yml
data/
.dev.env


=======

# Docker compose
docker-compose.yml
data/
>>>>>>> d080450 (chore: created a docker-compose.yml file and updated the gitignore)

data/
docker-compose.yml
Expand All @@ -436,4 +421,5 @@ package-lock.json
package-lock.json
docker-compose.yml
data/
.dev.env
.dev.env
.env.*
26 changes: 26 additions & 0 deletions src/modules/waitlist/docs/waitlist-swagger.docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { WaitlistResponseDto } from '../dto/create-waitlist-response.dto';

export function createWaitlistDocs() {
return applyDecorators(
ApiBearerAuth(),
ApiOperation({ summary: 'Create a new waitlist entry' }),
ApiResponse({
status: HttpStatus.CREATED,
Expand All @@ -16,6 +17,21 @@ export function createWaitlistDocs() {
status: HttpStatus.BAD_REQUEST,
description: 'Invalid input data.',
type: ErrorResponseDto,
}),
ApiResponse({
status: HttpStatus.UNAUTHORIZED,
description: 'Unauthorized access.',
type: ErrorResponseDto,
}),
ApiResponse({
status: HttpStatus.FORBIDDEN,
description: 'Forbidden access.',
type: ErrorResponseDto,
}),
ApiResponse({
status: HttpStatus.INTERNAL_SERVER_ERROR,
description: 'Internal server error.',
type: ErrorResponseDto,
})
);
}
Expand All @@ -29,6 +45,16 @@ export function getAllWaitlistDocs() {
description: 'Successfully retrieved all waitlist entries.',
type: GetWaitlistResponseDto,
}),
ApiResponse({
status: HttpStatus.UNAUTHORIZED,
description: 'Unauthorized access.',
type: ErrorResponseDto,
}),
ApiResponse({
status: HttpStatus.FORBIDDEN,
description: 'Forbidden access.',
type: ErrorResponseDto,
}),
ApiResponse({
status: HttpStatus.INTERNAL_SERVER_ERROR,
description: 'Internal server error.',
Expand Down
30 changes: 30 additions & 0 deletions src/modules/waitlist/dto/waitlist-error-response.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,34 @@ export class ErrorResponseDto {
example: 'Bad Request',
})
error: string;

@ApiProperty({
description: 'Example of an unauthorized error response.',
example: {
status_code: HttpStatus.UNAUTHORIZED,
message: 'Unauthorized access',
error: 'Unauthorized',
},
})
unauthorized_example: object;

@ApiProperty({
description: 'Example of a forbidden error response.',
example: {
status_code: HttpStatus.FORBIDDEN,
message: 'Forbidden access',
error: 'Forbidden',
},
})
forbidden_example: object;

@ApiProperty({
description: 'Example of an internal server error response.',
example: {
status_code: HttpStatus.INTERNAL_SERVER_ERROR,
message: 'Internal server error',
error: 'Internal Server Error',
},
})
internal_server_error_example: object;
}