mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-25 12:34:45 -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
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
@ -14,7 +14,14 @@ import {
|
|||
UseGuards,
|
||||
UseInterceptors,
|
||||
} from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import {
|
||||
ApiBadRequestResponse,
|
||||
ApiConflictResponse,
|
||||
ApiInternalServerErrorResponse,
|
||||
ApiNotFoundResponse,
|
||||
ApiTags,
|
||||
ApiUnauthorizedResponse,
|
||||
} from '@nestjs/swagger';
|
||||
|
||||
import { HistoryService } from '../../../history/history.service';
|
||||
import { SessionGuard } from '../../../identity/session.guard';
|
||||
|
@ -32,6 +39,13 @@ import { RevisionDto } from '../../../revisions/revision.dto';
|
|||
import { RevisionsService } from '../../../revisions/revisions.service';
|
||||
import { User } from '../../../users/user.entity';
|
||||
import { UsersService } from '../../../users/users.service';
|
||||
import {
|
||||
badRequestDescription,
|
||||
conflictDescription,
|
||||
internalServerErrorDescription,
|
||||
notFoundDescription,
|
||||
unauthorizedDescription,
|
||||
} from '../../utils/descriptions';
|
||||
import { GetNoteInterceptor } from '../../utils/get-note.interceptor';
|
||||
import { MarkdownBody } from '../../utils/markdownbody-decorator';
|
||||
import { PermissionsGuard } from '../../utils/permissions.guard';
|
||||
|
@ -54,6 +68,7 @@ export class NotesController {
|
|||
}
|
||||
|
||||
@Get(':noteIdOrAlias')
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
@Permissions(Permission.READ)
|
||||
@UseInterceptors(GetNoteInterceptor)
|
||||
@UseGuards(PermissionsGuard)
|
||||
|
@ -66,6 +81,7 @@ export class NotesController {
|
|||
}
|
||||
|
||||
@Get(':noteIdOrAlias/media')
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
@Permissions(Permission.READ)
|
||||
@UseInterceptors(GetNoteInterceptor)
|
||||
@UseGuards(PermissionsGuard)
|
||||
|
@ -78,6 +94,7 @@ export class NotesController {
|
|||
|
||||
@Post()
|
||||
@HttpCode(201)
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
@Permissions(Permission.CREATE)
|
||||
@UseGuards(PermissionsGuard)
|
||||
async createNote(
|
||||
|
@ -92,6 +109,10 @@ export class NotesController {
|
|||
|
||||
@Post(':noteAlias')
|
||||
@HttpCode(201)
|
||||
@ApiBadRequestResponse({ description: badRequestDescription })
|
||||
@ApiConflictResponse({ description: conflictDescription })
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
@ApiNotFoundResponse({ description: notFoundDescription })
|
||||
@Permissions(Permission.CREATE)
|
||||
@UseGuards(PermissionsGuard)
|
||||
async createNamedNote(
|
||||
|
@ -107,6 +128,11 @@ export class NotesController {
|
|||
|
||||
@Delete(':noteIdOrAlias')
|
||||
@HttpCode(204)
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
@ApiNotFoundResponse({ description: notFoundDescription })
|
||||
@ApiInternalServerErrorResponse({
|
||||
description: internalServerErrorDescription,
|
||||
})
|
||||
@Permissions(Permission.OWNER)
|
||||
@UseInterceptors(GetNoteInterceptor)
|
||||
@UseGuards(PermissionsGuard)
|
||||
|
@ -130,6 +156,8 @@ export class NotesController {
|
|||
}
|
||||
|
||||
@Get(':noteIdOrAlias/revisions')
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
@ApiNotFoundResponse({ description: notFoundDescription })
|
||||
@Permissions(Permission.READ)
|
||||
@UseInterceptors(GetNoteInterceptor)
|
||||
@UseGuards(PermissionsGuard)
|
||||
|
@ -147,6 +175,8 @@ export class NotesController {
|
|||
|
||||
@Delete(':noteIdOrAlias/revisions')
|
||||
@HttpCode(204)
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
@ApiNotFoundResponse({ description: notFoundDescription })
|
||||
@Permissions(Permission.READ)
|
||||
@UseInterceptors(GetNoteInterceptor)
|
||||
@UseGuards(PermissionsGuard)
|
||||
|
@ -167,6 +197,8 @@ export class NotesController {
|
|||
}
|
||||
|
||||
@Get(':noteIdOrAlias/revisions/:revisionId')
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
@ApiNotFoundResponse({ description: notFoundDescription })
|
||||
@Permissions(Permission.READ)
|
||||
@UseInterceptors(GetNoteInterceptor)
|
||||
@UseGuards(PermissionsGuard)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue