Add API doc for private media API

Signed-off-by: Yannick Bungers <git@innay.de>
This commit is contained in:
Yannick Bungers 2021-10-18 20:20:14 +02:00 committed by David Mehren
parent d13a3e87cb
commit 24d79a9493
No known key found for this signature in database
GPG key ID: 185982BA4C42B7C3

View file

@ -19,7 +19,15 @@ import {
UseInterceptors, UseInterceptors,
} from '@nestjs/common'; } from '@nestjs/common';
import { FileInterceptor } from '@nestjs/platform-express'; import { FileInterceptor } from '@nestjs/platform-express';
import { ApiNoContentResponse } from '@nestjs/swagger'; import {
ApiBody,
ApiConsumes,
ApiCreatedResponse,
ApiForbiddenResponse,
ApiHeader,
ApiNoContentResponse,
ApiUnauthorizedResponse,
} from '@nestjs/swagger';
import { import {
ClientError, ClientError,
@ -35,7 +43,12 @@ import { MulterFile } from '../../../media/multer-file.interface';
import { Note } from '../../../notes/note.entity'; import { Note } from '../../../notes/note.entity';
import { NotesService } from '../../../notes/notes.service'; import { NotesService } from '../../../notes/notes.service';
import { User } from '../../../users/user.entity'; import { User } from '../../../users/user.entity';
import { successfullyDeletedDescription } from '../../utils/descriptions'; import {
forbiddenDescription,
successfullyDeletedDescription,
unauthorizedDescription,
} from '../../utils/descriptions';
import { FullApi } from '../../utils/fullapi-decorator';
import { RequestUser } from '../../utils/request-user.decorator'; import { RequestUser } from '../../utils/request-user.decorator';
@UseGuards(SessionGuard) @UseGuards(SessionGuard)
@ -50,6 +63,28 @@ export class MediaController {
} }
@Post() @Post()
@ApiConsumes('multipart/form-data')
@ApiBody({
schema: {
type: 'object',
properties: {
file: {
type: 'string',
format: 'binary',
},
},
},
})
@ApiHeader({
name: 'HedgeDoc-Note',
description: 'ID or alias of the parent note',
})
@ApiCreatedResponse({
description: 'The file was uploaded successfully',
type: MediaUploadUrlDto,
})
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
@ApiForbiddenResponse({ description: forbiddenDescription })
@UseInterceptors(FileInterceptor('file')) @UseInterceptors(FileInterceptor('file'))
@HttpCode(201) @HttpCode(201)
async uploadMedia( async uploadMedia(
@ -82,6 +117,7 @@ export class MediaController {
@Delete(':filename') @Delete(':filename')
@HttpCode(204) @HttpCode(204)
@ApiNoContentResponse({ description: successfullyDeletedDescription }) @ApiNoContentResponse({ description: successfullyDeletedDescription })
@FullApi
async deleteMedia( async deleteMedia(
@RequestUser() user: User, @RequestUser() user: User,
@Param('filename') filename: string, @Param('filename') filename: string,