mirror of
https://github.com/Dokploy/website.git
synced 2026-06-15 20:25:25 +02:00
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.
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user