From 1ef62e9e335d5875a8901d13f70c3cf386bba303 Mon Sep 17 00:00:00 2001 From: zyoshoka <107108195+zyoshoka@users.noreply.github.com> Date: Sat, 18 Jan 2025 13:05:33 +0900 Subject: fix(backend): clone schema before converting to OAS schema to avoid mutation (#15294) * fix(backend): clone schema before converting to OAS schema to avoid mutation * Update CHANGELOG.md * fix: use deepClone --- packages/backend/src/server/api/openapi/schemas.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'packages/backend/src/server/api/openapi/schemas.ts') diff --git a/packages/backend/src/server/api/openapi/schemas.ts b/packages/backend/src/server/api/openapi/schemas.ts index eb854a7141..c80dda8d96 100644 --- a/packages/backend/src/server/api/openapi/schemas.ts +++ b/packages/backend/src/server/api/openapi/schemas.ts @@ -3,13 +3,15 @@ * SPDX-License-Identifier: AGPL-3.0-only */ +import { deepClone } from '@/misc/clone.js'; import type { Schema } from '@/misc/json-schema.js'; import { refs } from '@/misc/json-schema.js'; export function convertSchemaToOpenApiSchema(schema: Schema, type: 'param' | 'res', includeSelfRef: boolean): any { // optional, nullable, refはスキーマ定義に含まれないので分離しておく // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { optional, nullable, ref, selfRef, ...res }: any = schema; + const { optional, nullable, ref, selfRef, ..._res }: any = schema; + const res = deepClone(_res); if (schema.type === 'object' && schema.properties) { if (type === 'res') { -- cgit v1.2.3-freya