Skip to content

Commit

Permalink
docs: tweaks to settings for authenticated routes
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleymichael committed Sep 2, 2023
1 parent 9edf343 commit 240ba5e
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 103 deletions.
25 changes: 1 addition & 24 deletions src/cards/cards.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,12 @@ import { CardResponse } from './dto/cardResponse';

@ApiTags('Cards')
@UseGuards(AuthGuard)
@ApiBearerAuth('Authorization')
@Controller('cards')
export class CardsController {
constructor(private readonly cardsService: CardsService) {}

@Post()
@ApiHeader({
name: 'Authorization',
description: 'Bearer token for authentication',
required: true,
})
@ApiBearerAuth()
@ApiBody({ type: CardsDTO })
@ApiOperation({ summary: 'Create card' })
@ApiUnauthorizedResponse({ description: 'Token not sent or invalid' })
Expand All @@ -54,12 +49,6 @@ export class CardsController {
}

@Get()
@ApiHeader({
name: 'Authorization',
description: 'Bearer token for authentication',
required: true,
})
@ApiBearerAuth()
@ApiOperation({ summary: 'Find all cards' })
@ApiUnauthorizedResponse({ description: 'Token not sent or invalid' })
@ApiOkResponse({
Expand All @@ -71,12 +60,6 @@ export class CardsController {
}

@Get('/:id')
@ApiHeader({
name: 'Authorization',
description: 'Bearer token for authentication',
required: true,
})
@ApiBearerAuth()
@ApiOperation({ summary: 'Find card by cardId' })
@ApiParam({ name: 'id', description: 'Card id', example: 1 })
@ApiUnauthorizedResponse({ description: 'Token not sent or invalid' })
Expand All @@ -95,12 +78,6 @@ export class CardsController {
}

@Delete('/:id')
@ApiHeader({
name: 'Authorization',
description: 'Bearer token for authentication',
required: true,
})
@ApiBearerAuth()
@ApiOperation({ summary: 'Delete card by cardId' })
@ApiParam({ name: 'id', description: 'Card id', example: 1 })
@ApiBadRequestResponse({ description: 'Id not valid' })
Expand Down
27 changes: 2 additions & 25 deletions src/credentials/credentials.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,14 @@ import {
} from '@nestjs/swagger';
import { CredentialResponse } from './dto/credentialResponse';

@ApiTags('Credentials - Login information for a website or service')
@UseGuards(AuthGuard)
@ApiBearerAuth('Authorization')
@ApiTags('Credentials - Login information for a website or service')
@Controller('credentials')
export class CredentialsController {
constructor(private readonly credentialsService: CredentialsService) {}

@Post()
@ApiHeader({
name: 'Authorization',
description: 'Bearer token for authentication',
required: true,
})
@ApiBearerAuth()
@ApiBody({ type: CredentialDTO })
@ApiOperation({ summary: 'Create credential' })
@ApiUnauthorizedResponse({ description: 'Token not sent or invalid' })
Expand All @@ -60,12 +55,6 @@ export class CredentialsController {
}

@Get()
@ApiHeader({
name: 'Authorization',
description: 'Bearer token for authentication',
required: true,
})
@ApiBearerAuth()
@ApiOperation({ summary: 'Find all credentials' })
@ApiUnauthorizedResponse({ description: 'Token not sent or invalid' })
@ApiOkResponse({
Expand All @@ -77,12 +66,6 @@ export class CredentialsController {
}

@Get('/:id')
@ApiHeader({
name: 'Authorization',
description: 'Bearer token for authentication',
required: true,
})
@ApiBearerAuth()
@ApiOperation({ summary: 'Find credential by credentialId' })
@ApiParam({ name: 'id', description: 'Credential id', example: 1 })
@ApiUnauthorizedResponse({ description: 'Token not sent or invalid' })
Expand All @@ -103,12 +86,6 @@ export class CredentialsController {
}

@Delete('/:id')
@ApiHeader({
name: 'Authorization',
description: 'Bearer token for authentication',
required: true,
})
@ApiBearerAuth()
@ApiOperation({ summary: 'Delete credential by credentialId' })
@ApiParam({ name: 'id', description: 'Credential id', example: 1 })
@ApiBadRequestResponse({ description: 'Id not valid' })
Expand Down
7 changes: 1 addition & 6 deletions src/erase/erase.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,13 @@ import {
} from '@nestjs/swagger';

@ApiTags('Erase')
@ApiBearerAuth('Authorization')
@UseGuards(AuthGuard)
@Controller('erase')
export class EraseController {
constructor(private readonly eraseService: EraseService) {}

@Delete()
@ApiHeader({
name: 'Authorization',
description: 'Bearer token for authentication',
required: true,
})
@ApiBearerAuth()
@ApiBody({
schema: {
type: 'object',
Expand Down
4 changes: 4 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ async function bootstrap() {
.setDescription('DrivenPass API description')
.setVersion('1.0')
.addTag('drivenpass')
.addBearerAuth(
{ type: 'http', scheme: 'bearer', bearerFormat: 'JWT', name: 'JWT', description: 'Enter JWT token', },
'Authorization'
)
.build();

const document = SwaggerModule.createDocument(app, config);
Expand Down
25 changes: 1 addition & 24 deletions src/notes/notes.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,12 @@ import { NoteResponse } from './dto/noteResponse';

@ApiTags('Notes')
@UseGuards(AuthGuard)
@ApiBearerAuth('Authorization')
@Controller('notes')
export class NotesController {
constructor(private readonly notesService: NotesService) {}

@Post()
@ApiHeader({
name: 'Authorization',
description: 'Bearer token for authentication',
required: true,
})
@ApiBearerAuth()
@ApiBody({ type: NotesDTO })
@ApiOperation({ summary: 'Create note' })
@ApiUnauthorizedResponse({ description: 'Token not sent or invalid' })
Expand All @@ -54,12 +49,6 @@ export class NotesController {
}

@Get()
@ApiHeader({
name: 'Authorization',
description: 'Bearer token for authentication',
required: true,
})
@ApiBearerAuth()
@ApiOperation({ summary: 'Find all notes' })
@ApiUnauthorizedResponse({ description: 'Token not sent or invalid' })
@ApiOkResponse({
Expand All @@ -71,12 +60,6 @@ export class NotesController {
}

@Get('/:id')
@ApiHeader({
name: 'Authorization',
description: 'Bearer token for authentication',
required: true,
})
@ApiBearerAuth()
@ApiOperation({ summary: 'Find note by noteId' })
@ApiParam({ name: 'id', description: 'Note id', example: 1 })
@ApiUnauthorizedResponse({ description: 'Token not sent or invalid' })
Expand All @@ -95,12 +78,6 @@ export class NotesController {
}

@Delete('/:id')
@ApiHeader({
name: 'Authorization',
description: 'Bearer token for authentication',
required: true,
})
@ApiBearerAuth()
@ApiOperation({ summary: 'Delete note by noteId' })
@ApiParam({ name: 'id', description: 'Note id', example: 1 })
@ApiBadRequestResponse({ description: 'Id not valid' })
Expand Down
25 changes: 1 addition & 24 deletions src/wifi/wifi.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,12 @@ import { WifiResponse } from './dto/wifiResponse';

@ApiTags('Wifi')
@UseGuards(AuthGuard)
@ApiBearerAuth('Authorization')
@Controller('wifi')
export class WifiController {
constructor(private readonly wifiService: WifiService) {}

@Post()
@ApiHeader({
name: 'Authorization',
description: 'Bearer token for authentication',
required: true,
})
@ApiBearerAuth()
@ApiBody({ type: WifiDTO })
@ApiOperation({ summary: 'Create wifi' })
@ApiUnauthorizedResponse({ description: 'Token not sent or invalid' })
Expand All @@ -52,12 +47,6 @@ export class WifiController {
}

@Get()
@ApiHeader({
name: 'Authorization',
description: 'Bearer token for authentication',
required: true,
})
@ApiBearerAuth()
@ApiOperation({ summary: 'Find all wifi data' })
@ApiUnauthorizedResponse({ description: 'Token not sent or invalid' })
@ApiOkResponse({
Expand All @@ -69,12 +58,6 @@ export class WifiController {
}

@Get('/:id')
@ApiHeader({
name: 'Authorization',
description: 'Bearer token for authentication',
required: true,
})
@ApiBearerAuth()
@ApiOperation({ summary: 'Find wifi by wifiId' })
@ApiParam({ name: 'id', description: 'Wifi id', example: 1 })
@ApiUnauthorizedResponse({ description: 'Token not sent or invalid' })
Expand All @@ -93,12 +76,6 @@ export class WifiController {
}

@Delete('/:id')
@ApiHeader({
name: 'Authorization',
description: 'Bearer token for authentication',
required: true,
})
@ApiBearerAuth()
@ApiOperation({ summary: 'Delete wifi by wifiId' })
@ApiParam({ name: 'id', description: 'Wifi id', example: 1 })
@ApiBadRequestResponse({ description: 'Id not valid' })
Expand Down

0 comments on commit 240ba5e

Please sign in to comment.