docs: improved auto-generated openapi docs

With these additional annotations the openapi docs under `/apidoc` and `/private/apidoc` will be improved by adding errors that the requests can return

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2022-01-17 11:35:57 +01:00
parent 2bc8c0d6da
commit 796b8294cf
10 changed files with 183 additions and 34 deletions

View file

@ -16,12 +16,15 @@ import {
} from '@nestjs/common';
import { FileInterceptor } from '@nestjs/platform-express';
import {
ApiBadRequestResponse,
ApiBody,
ApiConsumes,
ApiCreatedResponse,
ApiForbiddenResponse,
ApiHeader,
ApiInternalServerErrorResponse,
ApiNoContentResponse,
ApiNotFoundResponse,
ApiSecurity,
ApiTags,
ApiUnauthorizedResponse,
@ -37,7 +40,10 @@ import { Note } from '../../../notes/note.entity';
import { NotesService } from '../../../notes/notes.service';
import { User } from '../../../users/user.entity';
import {
badRequestDescription,
forbiddenDescription,
internalServerErrorDescription,
notFoundDescription,
successfullyDeletedDescription,
unauthorizedDescription,
} from '../../utils/descriptions';
@ -78,8 +84,13 @@ export class MediaController {
description: 'The file was uploaded successfully',
type: MediaUploadUrlDto,
})
@ApiBadRequestResponse({ description: badRequestDescription })
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
@ApiForbiddenResponse({ description: forbiddenDescription })
@ApiNotFoundResponse({ description: notFoundDescription })
@ApiInternalServerErrorResponse({
description: internalServerErrorDescription,
})
@UseInterceptors(FileInterceptor('file'))
@HttpCode(201)
async uploadMedia(
@ -100,6 +111,9 @@ export class MediaController {
@Delete(':filename')
@HttpCode(204)
@ApiNoContentResponse({ description: successfullyDeletedDescription })
@ApiInternalServerErrorResponse({
description: internalServerErrorDescription,
})
@FullApi
async deleteMedia(
@RequestUser() user: User,