From cfb87236182933358a3bc16abdb331c96ae63d7e Mon Sep 17 00:00:00 2001 From: Johann150 Date: Thu, 20 Oct 2022 20:40:48 +0200 Subject: [PATCH] fix API definitions --- .../server/api/endpoints/notes/mentions.ts | 6 +- .../server/api/endpoints/notes/translate.ts | 67 +++++++++++-------- 2 files changed, 43 insertions(+), 30 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/notes/mentions.ts b/packages/backend/src/server/api/endpoints/notes/mentions.ts index 9b4154452..f86465ef6 100644 --- a/packages/backend/src/server/api/endpoints/notes/mentions.ts +++ b/packages/backend/src/server/api/endpoints/notes/mentions.ts @@ -1,4 +1,5 @@ import { Brackets } from 'typeorm'; +import { noteVisibilities } from 'foundkey-js'; import read from '@/services/note/read.js'; import { Notes, Followings } from '@/models/index.js'; import define from '../../define.js'; @@ -31,7 +32,10 @@ export const paramDef = { limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 }, sinceId: { type: 'string', format: 'misskey:id' }, untilId: { type: 'string', format: 'misskey:id' }, - visibility: { type: 'string' }, + visibility: { + type: 'string', + enum: noteVisibilities, + }, }, required: [], } as const; diff --git a/packages/backend/src/server/api/endpoints/notes/translate.ts b/packages/backend/src/server/api/endpoints/notes/translate.ts index a5eca5e99..c29623aa8 100644 --- a/packages/backend/src/server/api/endpoints/notes/translate.ts +++ b/packages/backend/src/server/api/endpoints/notes/translate.ts @@ -8,6 +8,36 @@ import { ApiError } from '../../error.js'; import { getNote } from '../../common/getters.js'; import define from '../../define.js'; +const sourceLangs = [ + 'BG', + 'CS', + 'DA', + 'DE', + 'EL', + 'EN', + 'ES', + 'ET', + 'FI', + 'FR', + 'HU', + 'ID', + 'IT', + 'JA', + 'LT', + 'LV', + 'NL', + 'PL', + 'PT', + 'RO', + 'RU', + 'SK', + 'SL', + 'SV', + 'TR', + 'UK', + 'ZH', +]; + export const meta = { tags: ['notes'], @@ -16,6 +46,13 @@ export const meta = { res: { type: 'object', optional: false, nullable: false, + properties: { + sourceLang: { + type: 'string', + enum: sourceLangs, + }, + text: { type: 'string' }, + }, }, errors: { @@ -34,35 +71,7 @@ export const paramDef = { noteId: { type: 'string', format: 'misskey:id' }, sourceLang: { type: 'string', - enum: [ - 'BG', - 'CS', - 'DA', - 'DE', - 'EL', - 'EN', - 'ES', - 'ET', - 'FI', - 'FR', - 'HU', - 'ID', - 'IT', - 'JA', - 'LT', - 'LV', - 'NL', - 'PL', - 'PT', - 'RO', - 'RU', - 'SK', - 'SL', - 'SV', - 'TR', - 'UK', - 'ZH', - ], + enum: sourceLangs, }, targetLang: { type: 'string',