mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-21 02:35:23 -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
|
@ -14,7 +14,11 @@ import {
|
|||
UnauthorizedException,
|
||||
UseGuards,
|
||||
} from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import {
|
||||
ApiNotFoundResponse,
|
||||
ApiTags,
|
||||
ApiUnauthorizedResponse,
|
||||
} from '@nestjs/swagger';
|
||||
|
||||
import { AuthTokenWithSecretDto } from '../../../auth/auth-token-with-secret.dto';
|
||||
import { AuthTokenDto } from '../../../auth/auth-token.dto';
|
||||
|
@ -23,6 +27,10 @@ import { SessionGuard } from '../../../identity/session.guard';
|
|||
import { ConsoleLoggerService } from '../../../logger/console-logger.service';
|
||||
import { User } from '../../../users/user.entity';
|
||||
import { TimestampMillis } from '../../../utils/timestamp';
|
||||
import {
|
||||
notFoundDescription,
|
||||
unauthorizedDescription,
|
||||
} from '../../utils/descriptions';
|
||||
import { RequestUser } from '../../utils/request-user.decorator';
|
||||
|
||||
@UseGuards(SessionGuard)
|
||||
|
@ -37,6 +45,7 @@ export class TokensController {
|
|||
}
|
||||
|
||||
@Get()
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
async getUserTokens(@RequestUser() user: User): Promise<AuthTokenDto[]> {
|
||||
return (await this.authService.getTokensByUser(user)).map((token) =>
|
||||
this.authService.toAuthTokenDto(token),
|
||||
|
@ -44,6 +53,7 @@ export class TokensController {
|
|||
}
|
||||
|
||||
@Post()
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
async postTokenRequest(
|
||||
@Body('label') label: string,
|
||||
@Body('validUntil') validUntil: TimestampMillis,
|
||||
|
@ -54,6 +64,8 @@ export class TokensController {
|
|||
|
||||
@Delete('/:keyId')
|
||||
@HttpCode(204)
|
||||
@ApiUnauthorizedResponse({ description: unauthorizedDescription })
|
||||
@ApiNotFoundResponse({ description: notFoundDescription })
|
||||
async deleteToken(
|
||||
@RequestUser() user: User,
|
||||
@Param('keyId') keyId: string,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue