From c3773a3ad177a404db6cecb5e0590df12c02d322 Mon Sep 17 00:00:00 2001 From: osamu <46447427+sam-osamu@users.noreply.github.com> Date: Tue, 21 Nov 2023 21:25:07 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=95=E3=82=A3=E3=83=BC=E3=83=AB=E3=83=89?= =?UTF-8?q?=E3=81=AE=E6=B6=88=E3=81=97=E6=96=B9=E3=81=AB=E4=B8=8D=E5=82=99?= =?UTF-8?q?=E3=81=8C=E3=81=82=E3=81=A3=E3=81=9F=E3=81=AE=E3=81=A7=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/server/api/openapi/schemas.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/backend/src/server/api/openapi/schemas.ts b/packages/backend/src/server/api/openapi/schemas.ts index 65efe4d31c..2716f5f162 100644 --- a/packages/backend/src/server/api/openapi/schemas.ts +++ b/packages/backend/src/server/api/openapi/schemas.ts @@ -7,7 +7,9 @@ import type { Schema } from '@/misc/json-schema.js'; import { refs } from '@/misc/json-schema.js'; export function convertSchemaToOpenApiSchema(schema: Schema) { - const res: any = schema; + // optional, refはスキーマ定義に含まれないので分離しておく + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { optional, ref, ...res }: any = schema; if (schema.type === 'object' && schema.properties) { const required = Object.entries(schema.properties).filter(([k, v]) => !v.optional).map(([k]) => k); @@ -36,15 +38,8 @@ export function convertSchemaToOpenApiSchema(schema: Schema) { } else { res.$ref = $ref; } - - // $refを抽出したので不要. - res.ref = undefined; } - // requiredを抽出したので不要. - // object以外の型も親階層のobjectによって列挙されているはずなので構わず消す - res.optional = undefined; - return res; }