Skip to content

Commit

Permalink
Improve the Swagger Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Wellington-gc committed Nov 3, 2022
1 parent 6dba9e5 commit 17e171d
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 8 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "calendar-api",
"version": "0.0.1",
"description": "",
"author": "",
"version": "1.0.0",
"description": "Our calendar API should be used as a tool to test integration capabilities with an API.",
"author": "https://github.com/Wellington-gc",
"private": true,
"license": "UNLICENSED",
"license": "MIT",
"scripts": {
"config": "cp .env.example .env",
"docker:start:dev": "docker-compose up -d && docker exec --user node -it calendar-api-app bash",
Expand Down Expand Up @@ -86,4 +86,4 @@
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
}
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ async function bootstrap() {

const swaggerConfig = new DocumentBuilder()
.setTitle('Calendar API Swagger Documentation - Codelitt')
.setDescription(
'This is an API built to be used when creating calendars reminders by [Codelitt](https://www.codelitt.com/).',
)
.setContact('Codelitt', 'https://www.codelitt.com/', '[email protected]')
.setExternalDoc('API documentation', 'https://github.com/codelittinc/calendar-api#readme')
.setDescription('This is an API built to create calendars reminders.')
.setVersion('v1')
.build();

Expand Down
60 changes: 60 additions & 0 deletions src/reminders/reminders.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ export class RemindersController {
@ApiResponse({
status: 201,
description: 'The reminder has been successfully created',
schema: {
example: {
title: 'Title Example',
description: 'Description example',
date: '2022-11-03T15:14:21.005Z',
color: '#FFFFFF',
token: {
id: '21681ba4-7556-4358-9500-e4afe1ce6141',
name: 'John Doe',
createdAt: '2022-11-02T15:12:13.242Z',
updatedAt: '2022-11-02T15:12:13.242Z',
},
id: '0493ad93-1290-41ea-818e-c7a371c828df',
createdAt: '2022-11-03T15:14:36.265Z',
updatedAt: '2022-11-03T15:14:36.265Z',
},
},
})
@ApiResponse({
status: 400,
Expand All @@ -29,6 +46,16 @@ export class RemindersController {
@ApiResponse({
status: 200,
description: 'Returns an array with the days that have created reminders',
schema: {
example: [
{
date: '2022-11-02T00:00:00.000Z',
},
{
date: '2022-11-03T00:00:00.000Z',
},
],
},
})
@ApiResponse({
status: 400,
Expand All @@ -47,6 +74,28 @@ export class RemindersController {
@ApiResponse({
status: 200,
description: 'Returns a list of reminders for the selected date',
schema: {
example: [
{
id: '0493ad93-1290-41ea-818e-c7a371c828df',
title: 'Title Example',
description: 'Description example',
date: '2022-11-03T15:14:21.005Z',
color: '#FFFFFF',
createdAt: '2022-11-03T15:14:36.265Z',
updatedAt: '2022-11-03T15:14:36.265Z',
},
{
id: 'f2c1f472-0743-450c-a928-71810066d7ba',
title: 'Title Example',
description: 'Description example',
date: '2022-11-03T15:17:13.222Z',
color: '#FFFFFF',
createdAt: '2022-11-03T15:17:38.778Z',
updatedAt: '2022-11-03T15:17:38.778Z',
},
],
},
})
@ApiResponse({
status: 400,
Expand All @@ -62,6 +111,17 @@ export class RemindersController {
@ApiResponse({
status: 200,
description: 'Returns a single reminder',
schema: {
example: {
id: '417b9cb6-6953-4cb5-b42e-6b6c8b209fe5',
title: 'Title Example',
description: 'Description example',
date: '2022-11-02T20:11:45.639Z',
color: '#FFFFFF',
createdAt: '2022-11-02T19:29:25.186Z',
updatedAt: '2022-11-02T20:12:26.845Z',
},
},
})
@ApiResponse({
status: 400,
Expand Down
16 changes: 16 additions & 0 deletions src/tokens/tokens.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ export class TokensController {
@ApiResponse({
status: 201,
description: 'The token has been created successfully',
schema: {
example: {
id: '21681ba4-7556-4358-9500-e4afe1ce6141',
name: 'John Doe',
createdAt: '2022-11-02T15:12:13.242Z',
updatedAt: '2022-11-02T15:12:13.242Z',
},
},
})
@ApiResponse({
status: 400,
Expand All @@ -27,6 +35,14 @@ export class TokensController {
@ApiResponse({
status: 200,
description: 'Returns a single token',
schema: {
example: {
id: '21681ba4-7556-4358-9500-e4afe1ce6141',
name: 'John Doe',
createdAt: '2022-11-02T15:12:13.242Z',
updatedAt: '2022-11-02T15:12:13.242Z',
},
},
})
@ApiResponse({
status: 400,
Expand Down

0 comments on commit 17e171d

Please sign in to comment.