From 4b295088fd6b4bead05087537415b10419eee78f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Sun, 22 Oct 2023 10:52:06 +0900 Subject: [PATCH] Update schemas.ts (#12103) --- packages/backend/src/server/api/openapi/schemas.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/server/api/openapi/schemas.ts b/packages/backend/src/server/api/openapi/schemas.ts index 0b9eb4fe2..1a1d973e5 100644 --- a/packages/backend/src/server/api/openapi/schemas.ts +++ b/packages/backend/src/server/api/openapi/schemas.ts @@ -26,7 +26,12 @@ export function convertSchemaToOpenApiSchema(schema: Schema) { if (schema.allOf) res.allOf = schema.allOf.map(convertSchemaToOpenApiSchema); if (schema.ref) { - res.$ref = `#/components/schemas/${schema.ref}`; + const $ref = `#/components/schemas/${schema.ref}`; + if (schema.nullable || schema.optional) { + res.allOf = [{ $ref }]; + } else { + res.$ref = $ref; + } } return res;