From aa524f56e56a03348ef13346353f89e0502003ea Mon Sep 17 00:00:00 2001 From: Mauricio Siu Date: Tue, 24 Feb 2026 01:03:44 -0600 Subject: [PATCH] fix: enhance OpenAPI schema handling in fix-openapi script - Added logic to unwrap nested OpenAPI specifications from migrated APIs, improving compatibility with various API structures. - Updated the condition for writing the fixed schema to include unwrapped status, ensuring all necessary changes are saved. --- apps/docs/scripts/fix-openapi.mjs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/docs/scripts/fix-openapi.mjs b/apps/docs/scripts/fix-openapi.mjs index a95b153..5270609 100644 --- a/apps/docs/scripts/fix-openapi.mjs +++ b/apps/docs/scripts/fix-openapi.mjs @@ -6,7 +6,15 @@ const openapiPath = join(process.cwd(), "public", "openapi.json"); console.log("Fixing OpenAPI schema..."); try { - const openapi = JSON.parse(readFileSync(openapiPath, "utf8")); + let openapi = JSON.parse(readFileSync(openapiPath, "utf8")); + + let unwrapped = false; + // If the spec is nested (e.g. result.data.json from a migrated/source API), use the inner spec + if (openapi.result?.data?.json && typeof openapi.result.data.json === "object") { + openapi = openapi.result.data.json; + unwrapped = true; + console.log("✓ Unwrapped nested OpenAPI spec (result.data.json)"); + } let fixed = 0; let securityFixed = false; @@ -87,7 +95,7 @@ try { } } - if (fixed > 0 || securityFixed) { + if (unwrapped || fixed > 0 || securityFixed) { writeFileSync(openapiPath, JSON.stringify(openapi, null, 2)); if (fixed > 0) console.log(`✓ Fixed ${fixed} empty response schemas`); if (securityFixed) console.log("✓ Added x-api-key security scheme");