mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-04-25 12:41:51 +00:00
Docs: Add ApiProperty to all Dtos
This makes it possible for the autogenerated openapi file to contain all the dtos instead of nothing. Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
3f4f5936cb
commit
47ca8be78b
14 changed files with 95 additions and 7 deletions
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { IsBoolean, IsString } from 'class-validator';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class GroupInfoDto {
|
||||
/**
|
||||
|
@ -11,6 +12,7 @@ export class GroupInfoDto {
|
|||
* @example "superheroes"
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
name: string;
|
||||
|
||||
/**
|
||||
|
@ -18,6 +20,7 @@ export class GroupInfoDto {
|
|||
* @example "Superheroes"
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
displayName: string;
|
||||
|
||||
/**
|
||||
|
@ -26,5 +29,6 @@ export class GroupInfoDto {
|
|||
* @example false
|
||||
*/
|
||||
@IsBoolean()
|
||||
@ApiProperty()
|
||||
special: boolean;
|
||||
}
|
||||
|
|
|
@ -5,11 +5,13 @@
|
|||
*/
|
||||
|
||||
import { IsBoolean } from 'class-validator';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class HistoryEntryUpdateDto {
|
||||
/**
|
||||
* True if the note should be pinned
|
||||
*/
|
||||
@IsBoolean()
|
||||
@ApiProperty()
|
||||
pinStatus: boolean;
|
||||
}
|
||||
|
|
|
@ -5,12 +5,14 @@
|
|||
*/
|
||||
|
||||
import { IsArray, IsBoolean, IsDate, IsString } from 'class-validator';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class HistoryEntryDto {
|
||||
/**
|
||||
* ID or Alias of the note
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
identifier: string;
|
||||
|
||||
/**
|
||||
|
@ -19,6 +21,7 @@ export class HistoryEntryDto {
|
|||
* @example "Shopping List"
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
title: string;
|
||||
|
||||
/**
|
||||
|
@ -26,10 +29,12 @@ export class HistoryEntryDto {
|
|||
* @example "2020-12-01 12:23:34"
|
||||
*/
|
||||
@IsDate()
|
||||
@ApiProperty()
|
||||
lastVisited: Date;
|
||||
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
@ApiProperty()
|
||||
tags: string[];
|
||||
|
||||
/**
|
||||
|
@ -37,5 +42,6 @@ export class HistoryEntryDto {
|
|||
* @example false
|
||||
*/
|
||||
@IsBoolean()
|
||||
@ApiProperty()
|
||||
pinStatus: boolean;
|
||||
}
|
||||
|
|
|
@ -5,8 +5,10 @@
|
|||
*/
|
||||
|
||||
import { IsString } from 'class-validator';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class MediaUploadUrlDto {
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
link: string;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
import { IsDate, IsString } from 'class-validator';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class MediaUploadDto {
|
||||
/**
|
||||
|
@ -12,6 +13,7 @@ export class MediaUploadDto {
|
|||
* @example "https://example.com/uploads/testfile123.jpg"
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
url: string;
|
||||
|
||||
/**
|
||||
|
@ -19,6 +21,7 @@ export class MediaUploadDto {
|
|||
* @example "noteId" TODO how looks a note id?
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
noteId: string;
|
||||
|
||||
/**
|
||||
|
@ -26,6 +29,7 @@ export class MediaUploadDto {
|
|||
* @example "2020-12-01 12:23:34"
|
||||
*/
|
||||
@IsDate()
|
||||
@ApiProperty()
|
||||
createdAt: Date;
|
||||
|
||||
/**
|
||||
|
@ -33,5 +37,6 @@ export class MediaUploadDto {
|
|||
* @example "testuser5"
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
userName: string;
|
||||
}
|
||||
|
|
|
@ -38,10 +38,10 @@ async function getServerVersionFromPackageJson(): Promise<ServerVersion> {
|
|||
export class MonitoringService {
|
||||
async getServerStatus(): Promise<ServerStatusDto> {
|
||||
return {
|
||||
connectionSocketQueueLenght: 0,
|
||||
destictOnlineUsers: 0,
|
||||
connectionSocketQueueLength: 0,
|
||||
distinctOnlineUsers: 0,
|
||||
disconnectSocketQueueLength: 0,
|
||||
distictOnlineRegisteredUsers: 0,
|
||||
distinctOnlineRegisteredUsers: 0,
|
||||
isConnectionBusy: false,
|
||||
isDisconnectBusy: false,
|
||||
notesCount: 0,
|
||||
|
|
|
@ -4,25 +4,44 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export interface ServerVersion {
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class ServerVersion {
|
||||
@ApiProperty()
|
||||
major: number;
|
||||
@ApiProperty()
|
||||
minor: number;
|
||||
@ApiProperty()
|
||||
patch: number;
|
||||
@ApiProperty()
|
||||
preRelease?: string;
|
||||
@ApiProperty()
|
||||
commit?: string;
|
||||
}
|
||||
|
||||
export class ServerStatusDto {
|
||||
@ApiProperty()
|
||||
serverVersion: ServerVersion;
|
||||
@ApiProperty()
|
||||
onlineNotes: number;
|
||||
@ApiProperty()
|
||||
onlineUsers: number;
|
||||
destictOnlineUsers: number;
|
||||
@ApiProperty()
|
||||
distinctOnlineUsers: number;
|
||||
@ApiProperty()
|
||||
notesCount: number;
|
||||
@ApiProperty()
|
||||
registeredUsers: number;
|
||||
@ApiProperty()
|
||||
onlineRegisteredUsers: number;
|
||||
distictOnlineRegisteredUsers: number;
|
||||
@ApiProperty()
|
||||
distinctOnlineRegisteredUsers: number;
|
||||
@ApiProperty()
|
||||
isConnectionBusy: boolean;
|
||||
connectionSocketQueueLenght: number;
|
||||
@ApiProperty()
|
||||
connectionSocketQueueLength: number;
|
||||
@ApiProperty()
|
||||
isDisconnectBusy: boolean;
|
||||
@ApiProperty()
|
||||
disconnectSocketQueueLength: number;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
import { IsDate, IsNumber, IsString, Min } from 'class-validator';
|
||||
import { UserInfoDto } from '../users/user-info.dto';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class NoteAuthorshipDto {
|
||||
/**
|
||||
|
@ -13,6 +14,7 @@ export class NoteAuthorshipDto {
|
|||
* @example "john.smith"
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
userName: UserInfoDto['userName'];
|
||||
|
||||
/**
|
||||
|
@ -21,6 +23,7 @@ export class NoteAuthorshipDto {
|
|||
*/
|
||||
@IsNumber()
|
||||
@Min(0)
|
||||
@ApiProperty()
|
||||
startPos: number;
|
||||
|
||||
/**
|
||||
|
@ -30,6 +33,7 @@ export class NoteAuthorshipDto {
|
|||
*/
|
||||
@IsNumber()
|
||||
@Min(0)
|
||||
@ApiProperty()
|
||||
endPos: number;
|
||||
|
||||
/**
|
||||
|
@ -37,6 +41,7 @@ export class NoteAuthorshipDto {
|
|||
* @example "2020-12-01 12:23:34"
|
||||
*/
|
||||
@IsDate()
|
||||
@ApiProperty()
|
||||
createdAt: Date;
|
||||
|
||||
/**
|
||||
|
@ -44,5 +49,6 @@ export class NoteAuthorshipDto {
|
|||
* @example "2020-12-01 12:23:34"
|
||||
*/
|
||||
@IsDate()
|
||||
@ApiProperty()
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
|
|
@ -14,12 +14,14 @@ import {
|
|||
} from 'class-validator';
|
||||
import { UserInfoDto } from '../users/user-info.dto';
|
||||
import { NotePermissionsDto } from './note-permissions.dto';
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
|
||||
export class NoteMetadataDto {
|
||||
/**
|
||||
* ID of the note
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
id: string;
|
||||
|
||||
/**
|
||||
|
@ -28,6 +30,7 @@ export class NoteMetadataDto {
|
|||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
@ApiPropertyOptional()
|
||||
alias: string;
|
||||
|
||||
/**
|
||||
|
@ -36,6 +39,7 @@ export class NoteMetadataDto {
|
|||
* @example "Shopping List"
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
title: string;
|
||||
|
||||
/**
|
||||
|
@ -44,6 +48,7 @@ export class NoteMetadataDto {
|
|||
* @example Everything I want to buy
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
description: string;
|
||||
|
||||
/**
|
||||
|
@ -52,6 +57,7 @@ export class NoteMetadataDto {
|
|||
*/
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
@ApiProperty()
|
||||
tags: string[];
|
||||
|
||||
/**
|
||||
|
@ -59,12 +65,14 @@ export class NoteMetadataDto {
|
|||
* @example "2020-12-01 12:23:34"
|
||||
*/
|
||||
@IsDate()
|
||||
@ApiProperty()
|
||||
updateTime: Date;
|
||||
|
||||
/**
|
||||
* User that last edited the note
|
||||
*/
|
||||
@ValidateNested()
|
||||
@ApiProperty({ type: UserInfoDto })
|
||||
updateUser: UserInfoDto;
|
||||
|
||||
/**
|
||||
|
@ -72,6 +80,7 @@ export class NoteMetadataDto {
|
|||
* @example 42
|
||||
*/
|
||||
@IsNumber()
|
||||
@ApiProperty()
|
||||
viewCount: number;
|
||||
|
||||
/**
|
||||
|
@ -79,6 +88,7 @@ export class NoteMetadataDto {
|
|||
* @example "2020-12-01 12:23:34"
|
||||
*/
|
||||
@IsDate()
|
||||
@ApiProperty()
|
||||
createTime: Date;
|
||||
|
||||
/**
|
||||
|
@ -87,12 +97,14 @@ export class NoteMetadataDto {
|
|||
*/
|
||||
@IsArray()
|
||||
@ValidateNested()
|
||||
@ApiProperty()
|
||||
editedBy: UserInfoDto['userName'][];
|
||||
|
||||
/**
|
||||
* Permissions currently in effect for the note
|
||||
*/
|
||||
@ValidateNested()
|
||||
@ApiProperty({ type: NotePermissionsDto })
|
||||
permissions: NotePermissionsDto;
|
||||
}
|
||||
|
||||
|
@ -103,6 +115,7 @@ export class NoteMetadataUpdateDto {
|
|||
* @example "Shopping List"
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
title: string;
|
||||
|
||||
/**
|
||||
|
@ -111,6 +124,7 @@ export class NoteMetadataUpdateDto {
|
|||
* @example Everything I want to buy
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
description: string;
|
||||
|
||||
/**
|
||||
|
@ -119,5 +133,6 @@ export class NoteMetadataUpdateDto {
|
|||
*/
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
@ApiProperty()
|
||||
tags: string[];
|
||||
}
|
||||
|
|
|
@ -7,12 +7,14 @@
|
|||
import { IsArray, IsBoolean, IsString, ValidateNested } from 'class-validator';
|
||||
import { UserInfoDto } from '../users/user-info.dto';
|
||||
import { GroupInfoDto } from '../groups/group-info.dto';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class NoteUserPermissionEntryDto {
|
||||
/**
|
||||
* User this permission applies to
|
||||
*/
|
||||
@ValidateNested()
|
||||
@ApiProperty({ type: UserInfoDto })
|
||||
user: UserInfoDto;
|
||||
|
||||
/**
|
||||
|
@ -20,6 +22,7 @@ export class NoteUserPermissionEntryDto {
|
|||
* @example false
|
||||
*/
|
||||
@IsBoolean()
|
||||
@ApiProperty()
|
||||
canEdit: boolean;
|
||||
}
|
||||
|
||||
|
@ -29,6 +32,7 @@ export class NoteUserPermissionUpdateDto {
|
|||
* @example "john.smith"
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
username: string;
|
||||
|
||||
/**
|
||||
|
@ -36,6 +40,7 @@ export class NoteUserPermissionUpdateDto {
|
|||
* @example false
|
||||
*/
|
||||
@IsBoolean()
|
||||
@ApiProperty()
|
||||
canEdit: boolean;
|
||||
}
|
||||
|
||||
|
@ -44,6 +49,7 @@ export class NoteGroupPermissionEntryDto {
|
|||
* Group this permission applies to
|
||||
*/
|
||||
@ValidateNested()
|
||||
@ApiProperty({ type: GroupInfoDto })
|
||||
group: GroupInfoDto;
|
||||
|
||||
/**
|
||||
|
@ -51,6 +57,7 @@ export class NoteGroupPermissionEntryDto {
|
|||
* @example false
|
||||
*/
|
||||
@IsBoolean()
|
||||
@ApiProperty()
|
||||
canEdit: boolean;
|
||||
}
|
||||
|
||||
|
@ -60,6 +67,7 @@ export class NoteGroupPermissionUpdateDto {
|
|||
* @example "superheroes"
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
groupname: string;
|
||||
|
||||
/**
|
||||
|
@ -67,6 +75,7 @@ export class NoteGroupPermissionUpdateDto {
|
|||
* @example false
|
||||
*/
|
||||
@IsBoolean()
|
||||
@ApiProperty()
|
||||
canEdit: boolean;
|
||||
}
|
||||
|
||||
|
@ -75,6 +84,7 @@ export class NotePermissionsDto {
|
|||
* User this permission applies to
|
||||
*/
|
||||
@ValidateNested()
|
||||
@ApiProperty({ type: UserInfoDto })
|
||||
owner: UserInfoDto;
|
||||
|
||||
/**
|
||||
|
@ -82,6 +92,7 @@ export class NotePermissionsDto {
|
|||
*/
|
||||
@ValidateNested()
|
||||
@IsArray()
|
||||
@ApiProperty({ isArray: true, type: NoteUserPermissionEntryDto })
|
||||
sharedToUsers: NoteUserPermissionEntryDto[];
|
||||
|
||||
/**
|
||||
|
@ -89,6 +100,7 @@ export class NotePermissionsDto {
|
|||
*/
|
||||
@ValidateNested()
|
||||
@IsArray()
|
||||
@ApiProperty({ isArray: true, type: NoteGroupPermissionEntryDto })
|
||||
sharedToGroups: NoteGroupPermissionEntryDto[];
|
||||
}
|
||||
|
||||
|
@ -98,6 +110,7 @@ export class NotePermissionsUpdateDto {
|
|||
*/
|
||||
@IsArray()
|
||||
@ValidateNested()
|
||||
@ApiProperty({ isArray: true, type: NoteUserPermissionUpdateDto })
|
||||
sharedToUsers: NoteUserPermissionUpdateDto[];
|
||||
|
||||
/**
|
||||
|
@ -105,5 +118,6 @@ export class NotePermissionsUpdateDto {
|
|||
*/
|
||||
@IsArray()
|
||||
@ValidateNested()
|
||||
@ApiProperty({ isArray: true, type: NoteGroupPermissionUpdateDto })
|
||||
sharedToGroups: NoteGroupPermissionUpdateDto[];
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
import { IsArray, IsString, ValidateNested } from 'class-validator';
|
||||
import { NoteAuthorshipDto } from './note-authorship.dto';
|
||||
import { NoteMetadataDto } from './note-metadata.dto';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class NoteDto {
|
||||
/**
|
||||
|
@ -14,12 +15,14 @@ export class NoteDto {
|
|||
* @example "# I am a heading"
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
content: string;
|
||||
|
||||
/**
|
||||
* Metadata of the note
|
||||
*/
|
||||
@ValidateNested()
|
||||
@ApiProperty({ type: NoteMetadataDto })
|
||||
metadata: NoteMetadataDto;
|
||||
|
||||
/**
|
||||
|
@ -27,5 +30,6 @@ export class NoteDto {
|
|||
*/
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@ApiProperty({ isArray: true, type: NoteAuthorshipDto })
|
||||
editedByAtPosition: NoteAuthorshipDto[];
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
import { IsDate, IsNumber } from 'class-validator';
|
||||
import { Revision } from './revision.entity';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class RevisionMetadataDto {
|
||||
/**
|
||||
|
@ -13,6 +14,7 @@ export class RevisionMetadataDto {
|
|||
* @example 13
|
||||
*/
|
||||
@IsNumber()
|
||||
@ApiProperty()
|
||||
id: Revision['id'];
|
||||
|
||||
/**
|
||||
|
@ -20,6 +22,7 @@ export class RevisionMetadataDto {
|
|||
* @example "2020-12-01 12:23:34"
|
||||
*/
|
||||
@IsDate()
|
||||
@ApiProperty()
|
||||
createdAt: Date;
|
||||
|
||||
/**
|
||||
|
@ -27,5 +30,6 @@ export class RevisionMetadataDto {
|
|||
* @example 142
|
||||
*/
|
||||
@IsNumber()
|
||||
@ApiProperty()
|
||||
length: number;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
import { IsDate, IsNumber, IsString } from 'class-validator';
|
||||
import { Revision } from './revision.entity';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class RevisionDto {
|
||||
/**
|
||||
|
@ -13,6 +14,7 @@ export class RevisionDto {
|
|||
* @example 13
|
||||
*/
|
||||
@IsNumber()
|
||||
@ApiProperty()
|
||||
id: Revision['id'];
|
||||
|
||||
/**
|
||||
|
@ -20,12 +22,14 @@ export class RevisionDto {
|
|||
* @example "# I am a heading"
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
content: string;
|
||||
|
||||
/**
|
||||
* Patch from the preceding revision to this one
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
patch: string;
|
||||
|
||||
/**
|
||||
|
@ -33,5 +37,6 @@ export class RevisionDto {
|
|||
* @example "2020-12-01 12:23:34"
|
||||
*/
|
||||
@IsDate()
|
||||
@ApiProperty()
|
||||
createdAt: Date;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ export class UserInfoDto {
|
|||
* @example "john.smith"
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
userName: string;
|
||||
|
||||
/**
|
||||
|
@ -20,6 +21,7 @@ export class UserInfoDto {
|
|||
* @example "John Smith"
|
||||
*/
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
displayName: string;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue