mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-16 16:14:43 -04:00
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:
parent
2bc8c0d6da
commit
796b8294cf
10 changed files with 183 additions and 34 deletions
|
@ -12,7 +12,12 @@ import {
|
|||
Post,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import {
|
||||
ApiInternalServerErrorResponse,
|
||||
ApiNotFoundResponse,
|
||||
ApiTags,
|
||||
ApiUnauthorizedResponse,
|
||||
} from '@nestjs/swagger';
|
||||
|
||||
import { SessionGuard } from '../../../identity/session.guard';
|
||||
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
||||
|
@ -21,6 +26,11 @@ import { MediaService } from '../../../media/media.service';
|
|||
import { UserInfoDto } from '../../../users/user-info.dto';
|
||||
import { User } from '../../../users/user.entity';
|
||||
import { UsersService } from '../../../users/users.service';
|
||||
import {
|
||||
internalServerErrorDescription,
|
||||
notFoundDescription,
|
||||
unauthorizedDescription,
|
||||
} from '../../utils/descriptions';
|
||||
import { RequestUser } from '../../utils/request-user.decorator';
|
||||
|
||||
@UseGuards(SessionGuard)
|
||||
|
@ -35,11 +45,13 @@ export class MeController {
|
|||
this.logger.setContext(MeController.name);
|
||||
}
|
||||
@Get()
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
getMe(@RequestUser() user: User): UserInfoDto {
|
||||
return this.userService.toUserDto(user);
|
||||
}
|
||||
|
||||
@Get('media')
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
async getMyMedia(@RequestUser() user: User): Promise<MediaUploadDto[]> {
|
||||
const media = await this.mediaService.listUploadsByUser(user);
|
||||
return await Promise.all(
|
||||
|
@ -49,6 +61,11 @@ export class MeController {
|
|||
|
||||
@Delete()
|
||||
@HttpCode(204)
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
@ApiNotFoundResponse({ description: notFoundDescription })
|
||||
@ApiInternalServerErrorResponse({
|
||||
description: internalServerErrorDescription,
|
||||
})
|
||||
async deleteUser(@RequestUser() user: User): Promise<void> {
|
||||
const mediaUploads = await this.mediaService.listUploadsByUser(user);
|
||||
for (const mediaUpload of mediaUploads) {
|
||||
|
@ -61,6 +78,7 @@ export class MeController {
|
|||
|
||||
@Post('profile')
|
||||
@HttpCode(200)
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
async updateDisplayName(
|
||||
@RequestUser() user: User,
|
||||
@Body('name') newDisplayName: string,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue