mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-27 12:08:02 -05:00
Merge pull request #512 from codimd/fix/public-api-spec
This commit is contained in:
commit
6b92b012e2
5 changed files with 109 additions and 58 deletions
|
@ -47,7 +47,9 @@ paths:
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
"$ref": "#/components/schemas/History"
|
type: array
|
||||||
|
items:
|
||||||
|
"$ref": "#/components/schemas/History"
|
||||||
'401':
|
'401':
|
||||||
"$ref": "#/components/responses/UnauthorizedError"
|
"$ref": "#/components/responses/UnauthorizedError"
|
||||||
/me/history/{note}:
|
/me/history/{note}:
|
||||||
|
@ -60,11 +62,11 @@ paths:
|
||||||
description: JSON Object which contains id, title, tags, last visit time and pinned status
|
description: JSON Object which contains id, title, tags, last visit time and pinned status
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: The list of recently viewed notes and pinned notes.
|
description: Information about the history entry
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
"$ref": "#/components/schemas/HistoryObject"
|
"$ref": "#/components/schemas/History"
|
||||||
'401':
|
'401':
|
||||||
"$ref": "#/components/responses/UnauthorizedError"
|
"$ref": "#/components/responses/UnauthorizedError"
|
||||||
'404':
|
'404':
|
||||||
|
@ -88,7 +90,7 @@ paths:
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
"$ref": "#/components/schemas/HistoryObject"
|
"$ref": "#/components/schemas/HistoryUpdate"
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: The new history.
|
description: The new history.
|
||||||
|
@ -169,7 +171,7 @@ paths:
|
||||||
markdownExample:
|
markdownExample:
|
||||||
"$ref": '#/components/examples/markdownExample'
|
"$ref": '#/components/examples/markdownExample'
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'201':
|
||||||
description: Get information about the newly created note.
|
description: Get information about the newly created note.
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
|
@ -212,7 +214,7 @@ paths:
|
||||||
- note
|
- note
|
||||||
summary: Imports some markdown data into a new note with a given alias
|
summary: Imports some markdown data into a new note with a given alias
|
||||||
operationId: createNoteWithAlias
|
operationId: createNoteWithAlias
|
||||||
description: This endpoint equals to the above one except that the alias from the url will be assigned to the note if [FreeURL-mode](https://github.com/codimd/server/tree/master/docs/configuration-env-vars.md#users-and-privileges) is enabled.
|
description: This endpoint creates a new note with the content of the HTTP request body and the alias from the URL parameter.
|
||||||
requestBody:
|
requestBody:
|
||||||
required: true
|
required: true
|
||||||
description: The content of the note to be imported as markdown.
|
description: The content of the note to be imported as markdown.
|
||||||
|
@ -224,7 +226,7 @@ paths:
|
||||||
markdownExample:
|
markdownExample:
|
||||||
"$ref": '#/components/examples/markdownExample'
|
"$ref": '#/components/examples/markdownExample'
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'201':
|
||||||
description: Get information about the newly created note.
|
description: Get information about the newly created note.
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
|
@ -271,7 +273,7 @@ paths:
|
||||||
- note
|
- note
|
||||||
summary: Imports some markdown data into an existing note, creating a new revision
|
summary: Imports some markdown data into an existing note, creating a new revision
|
||||||
operationId: createNewRevisionForNote
|
operationId: createNewRevisionForNote
|
||||||
description: This endpoint equals to the above one except that the alias from the url will be assigned to the note if [FreeURL-mode](https://github.com/codimd/server/tree/master/docs/configuration-env-vars.md#users-and-privileges) is enabled.
|
description: This endpoint updates the note content of an existing note. The old content is completely replaced and a new revision is created.
|
||||||
requestBody:
|
requestBody:
|
||||||
required: true
|
required: true
|
||||||
description: The content of the note to be imported as markdown.
|
description: The content of the note to be imported as markdown.
|
||||||
|
@ -304,20 +306,14 @@ paths:
|
||||||
text/plain:
|
text/plain:
|
||||||
example: my-note
|
example: my-note
|
||||||
/notes/{note}/metadata:
|
/notes/{note}/metadata:
|
||||||
put:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- note
|
- note
|
||||||
summary: Set the permissions of a note
|
summary: Get the metadata of a note
|
||||||
operationId: updateNoteMetadata
|
operationId: getNoteMetadata
|
||||||
requestBody:
|
|
||||||
required: true
|
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
"$ref": "#/components/schemas/NoteMetadata"
|
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: The updated permissions of the note.
|
description: The metadata of the note.
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
|
@ -336,18 +332,24 @@ paths:
|
||||||
content:
|
content:
|
||||||
text/plain:
|
text/plain:
|
||||||
example: my-note
|
example: my-note
|
||||||
get:
|
/notes/{note}/permissions:
|
||||||
tags:
|
put:
|
||||||
- note
|
tags: [ note ]
|
||||||
summary: Get the permissions of a note
|
summary: Set permissions of a note
|
||||||
operationId: getNoteMetadata
|
operationId: updateNotePermissions
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
"$ref": "#/components/schemas/NotePermissionsUpdate"
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: The permissions of the note.
|
description: The updated permissions of the note.
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
"$ref": "#/components/schemas/NoteMetadata"
|
"$ref": "#/components/schemas/NotePermissions"
|
||||||
'401':
|
'401':
|
||||||
"$ref": "#/components/responses/UnauthorizedError"
|
"$ref": "#/components/responses/UnauthorizedError"
|
||||||
'403':
|
'403':
|
||||||
|
@ -375,7 +377,9 @@ paths:
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
"$ref": "#/components/schemas/NoteRevisionsMetadata"
|
type: array
|
||||||
|
items:
|
||||||
|
"$ref": "#/components/schemas/NoteRevisionsMetadata"
|
||||||
'401':
|
'401':
|
||||||
"$ref": "#/components/responses/UnauthorizedError"
|
"$ref": "#/components/responses/UnauthorizedError"
|
||||||
'403':
|
'403':
|
||||||
|
@ -524,7 +528,7 @@ paths:
|
||||||
required: true
|
required: true
|
||||||
description: ID or alias of the parent note
|
description: ID or alias of the parent note
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'201':
|
||||||
description: The file was uploaded successfully.
|
description: The file was uploaded successfully.
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
|
@ -614,6 +618,15 @@ components:
|
||||||
properties:
|
properties:
|
||||||
password:
|
password:
|
||||||
type: string
|
type: string
|
||||||
|
GroupInfo:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
displayName:
|
||||||
|
type: string
|
||||||
|
special:
|
||||||
|
type: boolean
|
||||||
ImageProxyRequest:
|
ImageProxyRequest:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
@ -685,9 +698,32 @@ components:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
owner:
|
owner:
|
||||||
type: string
|
$ref: "#/components/schemas/UserInfo"
|
||||||
description: Username of the owner of the note
|
sharedToUsers:
|
||||||
sharedTo:
|
type: array
|
||||||
|
description: Contains all users that can read the note and a boolean that denotes if they can also edit.
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
user:
|
||||||
|
$ref: "#/components/schemas/UserInfo"
|
||||||
|
canEdit:
|
||||||
|
type: boolean
|
||||||
|
sharedToGroups:
|
||||||
|
type: array
|
||||||
|
description: Contains all groups that can read the note and a boolean that denotes if they can also edit.
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
group:
|
||||||
|
$ref: "#/components/schemas/GroupInfo"
|
||||||
|
canEdit:
|
||||||
|
type: boolean
|
||||||
|
NotePermissionsUpdate:
|
||||||
|
type: object
|
||||||
|
description: Contains only title, description and tags of a note.
|
||||||
|
properties:
|
||||||
|
sharedToUsers:
|
||||||
type: array
|
type: array
|
||||||
description: Contains all usernames that can read the note and a boolean that denotes if they can also edit.
|
description: Contains all usernames that can read the note and a boolean that denotes if they can also edit.
|
||||||
items:
|
items:
|
||||||
|
@ -697,21 +733,28 @@ components:
|
||||||
type: string
|
type: string
|
||||||
canEdit:
|
canEdit:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
sharedToGroups:
|
||||||
|
type: array
|
||||||
|
description: Contains all groups that can read the note and a boolean that denotes if they can also edit.
|
||||||
|
items:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
groupname:
|
||||||
|
type: string
|
||||||
|
canEdit:
|
||||||
|
type: boolean
|
||||||
NoteRevisionsMetadata:
|
NoteRevisionsMetadata:
|
||||||
type: array
|
type: object
|
||||||
items:
|
properties:
|
||||||
type: object
|
id:
|
||||||
properties:
|
type: integer
|
||||||
id:
|
description: The id of the revision
|
||||||
type: integer
|
createdTime:
|
||||||
description: The id of the revision
|
type: string
|
||||||
createdTime:
|
description: ISO-timestamp of when the revision was saved. Is also the revision-id.
|
||||||
type: string
|
length:
|
||||||
description: ISO-timestamp of when the revision was saved. Is also the revision-id.
|
type: integer
|
||||||
length:
|
description: Length of the document to the timepoint the revision was saved.
|
||||||
type: integer
|
|
||||||
description: Length of the document to the timepoint the revision was saved.
|
|
||||||
NoteRevision:
|
NoteRevision:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
@ -812,7 +855,7 @@ components:
|
||||||
type: boolean
|
type: boolean
|
||||||
disconnectSocketQueueLength:
|
disconnectSocketQueueLength:
|
||||||
type: integer
|
type: integer
|
||||||
HistoryObject:
|
History:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
metadata:
|
metadata:
|
||||||
|
@ -820,14 +863,12 @@ components:
|
||||||
pinned:
|
pinned:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: Whether the user has pinned this note.
|
description: Whether the user has pinned this note.
|
||||||
History:
|
HistoryUpdate:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
history:
|
pinned:
|
||||||
type: array
|
type: boolean
|
||||||
description: The array that contains history objects.
|
description: Whether the user has pinned this note.
|
||||||
items:
|
|
||||||
"$ref": "#/components/schemas/HistoryObject"
|
|
||||||
examples:
|
examples:
|
||||||
markdownExample:
|
markdownExample:
|
||||||
value: '# Some header\nSome normal text. **Some bold text**'
|
value: '# Some header\nSome normal text. **Some bold text**'
|
||||||
|
|
|
@ -20,7 +20,7 @@ export class HistoryService {
|
||||||
description: 'Very descriptive text.',
|
description: 'Very descriptive text.',
|
||||||
editedBy: [],
|
editedBy: [],
|
||||||
id: 'foobar-barfoo',
|
id: 'foobar-barfoo',
|
||||||
permission: {
|
permissions: {
|
||||||
owner: {
|
owner: {
|
||||||
displayName: 'foo',
|
displayName: 'foo',
|
||||||
userName: 'fooUser',
|
userName: 'fooUser',
|
||||||
|
@ -59,7 +59,7 @@ export class HistoryService {
|
||||||
description: 'Very descriptive text.',
|
description: 'Very descriptive text.',
|
||||||
editedBy: [],
|
editedBy: [],
|
||||||
id: 'foobar-barfoo',
|
id: 'foobar-barfoo',
|
||||||
permission: {
|
permissions: {
|
||||||
owner: {
|
owner: {
|
||||||
displayName: 'foo',
|
displayName: 'foo',
|
||||||
userName: 'fooUser',
|
userName: 'fooUser',
|
||||||
|
|
|
@ -32,5 +32,5 @@ export class NoteMetadataDto {
|
||||||
@ValidateNested()
|
@ValidateNested()
|
||||||
editedBy: UserInfoDto['userName'][];
|
editedBy: UserInfoDto['userName'][];
|
||||||
@ValidateNested()
|
@ValidateNested()
|
||||||
permission: NotePermissionsDto;
|
permissions: NotePermissionsDto;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ export class NoteUserPermissionEntryDto {
|
||||||
canEdit: boolean;
|
canEdit: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class NotePermissionEntryUpdateDto {
|
export class NoteUserPermissionUpdateDto {
|
||||||
@IsString()
|
@IsString()
|
||||||
username: string;
|
username: string;
|
||||||
@IsBoolean()
|
@IsBoolean()
|
||||||
|
@ -31,6 +31,13 @@ export class NoteGroupPermissionEntryDto {
|
||||||
canEdit: boolean;
|
canEdit: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class NoteGroupPermissionUpdateDto {
|
||||||
|
@IsString()
|
||||||
|
groupname: string;
|
||||||
|
@IsBoolean()
|
||||||
|
canEdit: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export class NotePermissionsDto {
|
export class NotePermissionsDto {
|
||||||
@ValidateNested()
|
@ValidateNested()
|
||||||
owner: UserInfoDto;
|
owner: UserInfoDto;
|
||||||
|
@ -45,5 +52,8 @@ export class NotePermissionsDto {
|
||||||
export class NotePermissionsUpdateDto {
|
export class NotePermissionsUpdateDto {
|
||||||
@IsArray()
|
@IsArray()
|
||||||
@ValidateNested()
|
@ValidateNested()
|
||||||
sharedTo: NotePermissionEntryUpdateDto[];
|
sharedToUsers: NoteUserPermissionUpdateDto[];
|
||||||
|
@IsArray()
|
||||||
|
@ValidateNested()
|
||||||
|
sharedToGroups: NoteGroupPermissionUpdateDto[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ export class NotesService {
|
||||||
description: 'Very descriptive text.',
|
description: 'Very descriptive text.',
|
||||||
editedBy: [],
|
editedBy: [],
|
||||||
id: 'foobar-barfoo',
|
id: 'foobar-barfoo',
|
||||||
permission: {
|
permissions: {
|
||||||
owner: {
|
owner: {
|
||||||
displayName: 'foo',
|
displayName: 'foo',
|
||||||
userName: 'fooUser',
|
userName: 'fooUser',
|
||||||
|
@ -108,7 +108,7 @@ export class NotesService {
|
||||||
description: NoteUtils.parseDescription(note),
|
description: NoteUtils.parseDescription(note),
|
||||||
editedBy: note.authorColors.map(authorColor => authorColor.user.userName),
|
editedBy: note.authorColors.map(authorColor => authorColor.user.userName),
|
||||||
// TODO: Extract into method
|
// TODO: Extract into method
|
||||||
permission: {
|
permissions: {
|
||||||
owner: this.usersService.toUserDto(note.owner),
|
owner: this.usersService.toUserDto(note.owner),
|
||||||
sharedToUsers: note.userPermissions.map(noteUserPermission => ({
|
sharedToUsers: note.userPermissions.map(noteUserPermission => ({
|
||||||
user: this.usersService.toUserDto(noteUserPermission.user),
|
user: this.usersService.toUserDto(noteUserPermission.user),
|
||||||
|
|
Loading…
Reference in a new issue