From b67f3438e95af5c9a1143fa9214ae697a1372223 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 24 Feb 2019 19:42:26 +0900 Subject: [PATCH] Improve doc --- src/server/api/endpoints/blocking/list.ts | 9 +++- src/server/api/endpoints/mute/list.ts | 9 +++- src/server/api/endpoints/notes.ts | 9 +++- src/server/api/endpoints/users.ts | 9 +++- src/server/api/endpoints/users/followers.ts | 17 +++++++ src/server/api/endpoints/users/following.ts | 17 +++++++ .../users/get-frequently-replied-users.ts | 7 +++ .../api/endpoints/users/recommendation.ts | 9 +++- src/server/api/endpoints/users/search.ts | 7 +++ src/server/api/openapi/schemas.ts | 46 ++++++++++++++++++- 10 files changed, 133 insertions(+), 6 deletions(-) diff --git a/src/server/api/endpoints/blocking/list.ts b/src/server/api/endpoints/blocking/list.ts index 2921f48f2..b9ad6e8a3 100644 --- a/src/server/api/endpoints/blocking/list.ts +++ b/src/server/api/endpoints/blocking/list.ts @@ -30,7 +30,14 @@ export const meta = { validator: $.optional.type(ID), transform: transform, }, - } + }, + + res: { + type: 'array', + items: { + type: 'Blocking', + } + }, }; export default define(meta, async (ps, me) => { diff --git a/src/server/api/endpoints/mute/list.ts b/src/server/api/endpoints/mute/list.ts index da7189b48..1b8f75949 100644 --- a/src/server/api/endpoints/mute/list.ts +++ b/src/server/api/endpoints/mute/list.ts @@ -30,7 +30,14 @@ export const meta = { validator: $.optional.type(ID), transform: transform, }, - } + }, + + res: { + type: 'array', + items: { + type: 'Muting', + } + }, }; export default define(meta, async (ps, me) => { diff --git a/src/server/api/endpoints/notes.ts b/src/server/api/endpoints/notes.ts index b4716ac3e..8283e92bf 100644 --- a/src/server/api/endpoints/notes.ts +++ b/src/server/api/endpoints/notes.ts @@ -67,7 +67,14 @@ export const meta = { validator: $.optional.type(ID), transform: transform, }, - } + }, + + res: { + type: 'array', + items: { + type: 'Note', + } + }, }; export default define(meta, async (ps) => { diff --git a/src/server/api/endpoints/users.ts b/src/server/api/endpoints/users.ts index 7147a3541..be83dcd9c 100644 --- a/src/server/api/endpoints/users.ts +++ b/src/server/api/endpoints/users.ts @@ -53,7 +53,14 @@ export const meta = { ]), default: 'local' } - } + }, + + res: { + type: 'array', + items: { + type: 'User', + } + }, }; const state: any = { // < https://github.com/Microsoft/TypeScript/issues/1863 diff --git a/src/server/api/endpoints/users/followers.ts b/src/server/api/endpoints/users/followers.ts index 32c75fc8d..3c8290a8b 100644 --- a/src/server/api/endpoints/users/followers.ts +++ b/src/server/api/endpoints/users/followers.ts @@ -52,6 +52,23 @@ export const meta = { } }, + res: { + type: 'object', + properties: { + users: { + type: 'array', + items: { + type: 'User', + } + }, + next: { + type: 'string', + format: 'id', + nullable: true + } + } + }, + errors: { noSuchUser: { message: 'No such user.', diff --git a/src/server/api/endpoints/users/following.ts b/src/server/api/endpoints/users/following.ts index 3ce103621..4bc740cad 100644 --- a/src/server/api/endpoints/users/following.ts +++ b/src/server/api/endpoints/users/following.ts @@ -52,6 +52,23 @@ export const meta = { } }, + res: { + type: 'object', + properties: { + users: { + type: 'array', + items: { + type: 'User', + } + }, + next: { + type: 'string', + format: 'id', + nullable: true + } + } + }, + errors: { noSuchUser: { message: 'No such user.', diff --git a/src/server/api/endpoints/users/get-frequently-replied-users.ts b/src/server/api/endpoints/users/get-frequently-replied-users.ts index 6f9c746ac..46c7fba2f 100644 --- a/src/server/api/endpoints/users/get-frequently-replied-users.ts +++ b/src/server/api/endpoints/users/get-frequently-replied-users.ts @@ -29,6 +29,13 @@ export const meta = { }, }, + res: { + type: 'array', + items: { + type: 'User', + } + }, + errors: { noSuchUser: { message: 'No such user.', diff --git a/src/server/api/endpoints/users/recommendation.ts b/src/server/api/endpoints/users/recommendation.ts index 2261ee7df..60710fffc 100644 --- a/src/server/api/endpoints/users/recommendation.ts +++ b/src/server/api/endpoints/users/recommendation.ts @@ -31,7 +31,14 @@ export const meta = { validator: $.optional.num.min(0), default: 0 } - } + }, + + res: { + type: 'array', + items: { + type: 'User', + } + }, }; export default define(meta, async (ps, me) => { diff --git a/src/server/api/endpoints/users/search.ts b/src/server/api/endpoints/users/search.ts index a6b50b687..b8519eeba 100644 --- a/src/server/api/endpoints/users/search.ts +++ b/src/server/api/endpoints/users/search.ts @@ -52,6 +52,13 @@ export const meta = { } }, }, + + res: { + type: 'array', + items: { + type: 'User', + } + }, }; export default define(meta, async (ps, me) => { diff --git a/src/server/api/openapi/schemas.ts b/src/server/api/openapi/schemas.ts index a8d684923..4f63c7aef 100644 --- a/src/server/api/openapi/schemas.ts +++ b/src/server/api/openapi/schemas.ts @@ -221,5 +221,49 @@ export const schemas = { }, }, required: ['id', 'createdAt', 'name', 'type', 'datasize', 'md5'] - } + }, + + Muting: { + type: 'object', + properties: { + id: { + type: 'string', + format: 'id', + description: 'The unique identifier for this mute.', + example: 'xxxxxxxxxxxxxxxxxxxxxxxx', + }, + createdAt: { + type: 'string', + format: 'date-time', + description: 'The date that the mute was created.' + }, + mutee: { + $ref: '#/components/schemas/User', + description: 'The mutee.' + }, + }, + required: ['id', 'createdAt', 'mutee'] + }, + + Blocking: { + type: 'object', + properties: { + id: { + type: 'string', + format: 'id', + description: 'The unique identifier for this block.', + example: 'xxxxxxxxxxxxxxxxxxxxxxxx', + }, + createdAt: { + type: 'string', + format: 'date-time', + description: 'The date that the block was created.' + }, + blockee: { + $ref: '#/components/schemas/User', + description: 'The blockee.' + }, + }, + required: ['id', 'createdAt', 'blockee'] + }, };