From eb8d1211ba51d1c9b17b2c47642123aa108ad213 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 25 Feb 2019 03:43:19 +0900 Subject: [PATCH] Improve doc --- src/server/api/endpoints/messaging/history.ts | 9 ++++- .../api/endpoints/messaging/messages.ts | 7 ++++ .../endpoints/messaging/messages/create.ts | 4 +++ src/server/api/openapi/schemas.ts | 33 +++++++++++++++++++ 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/server/api/endpoints/messaging/history.ts b/src/server/api/endpoints/messaging/history.ts index 0425ef0213..699dc7c253 100644 --- a/src/server/api/endpoints/messaging/history.ts +++ b/src/server/api/endpoints/messaging/history.ts @@ -20,7 +20,14 @@ export const meta = { validator: $.optional.num.range(1, 100), default: 10 } - } + }, + + res: { + type: 'array', + items: { + type: 'MessagingMessage', + }, + }, }; export default define(meta, async (ps, user) => { diff --git a/src/server/api/endpoints/messaging/messages.ts b/src/server/api/endpoints/messaging/messages.ts index f1408f87fe..c19db45f1f 100644 --- a/src/server/api/endpoints/messaging/messages.ts +++ b/src/server/api/endpoints/messaging/messages.ts @@ -50,6 +50,13 @@ export const meta = { } }, + res: { + type: 'array', + items: { + type: 'MessagingMessage', + }, + }, + errors: { noSuchUser: { message: 'No such user.', diff --git a/src/server/api/endpoints/messaging/messages/create.ts b/src/server/api/endpoints/messaging/messages/create.ts index cf32b4461d..fc048e6edd 100644 --- a/src/server/api/endpoints/messaging/messages/create.ts +++ b/src/server/api/endpoints/messaging/messages/create.ts @@ -45,6 +45,10 @@ export const meta = { } }, + res: { + type: 'MessagingMessage', + }, + errors: { recipientIsYourself: { message: 'You can not send a message to yourself.', diff --git a/src/server/api/openapi/schemas.ts b/src/server/api/openapi/schemas.ts index cca789bf7a..127a7939df 100644 --- a/src/server/api/openapi/schemas.ts +++ b/src/server/api/openapi/schemas.ts @@ -119,6 +119,39 @@ export const schemas = { required: ['id', 'createdAt', 'title'] }, + MessagingMessage: { + type: 'object', + properties: { + id: { + type: 'string', + format: 'id', + description: 'The unique identifier for this MessagingMessage.', + example: 'xxxxxxxxxxxxxxxxxxxxxxxx', + }, + createdAt: { + type: 'string', + format: 'date-time', + description: 'The date that the MessagingMessage was created.' + }, + text: { + type: 'string', + nullable: true + }, + file: { + type: 'DriveFile', + nullable: true + }, + recipientId: { + type: 'string', + format: 'id', + }, + recipient: { + $ref: '#/components/schemas/User' + }, + }, + required: ['id', 'createdAt'] + }, + Note: { type: 'object', properties: {