From 4d62ba1832c88c84d158f37716216db355141870 Mon Sep 17 00:00:00 2001 From: wengxiaojun Date: Mon, 14 Oct 2024 15:00:49 +0800 Subject: [PATCH] update allof description --- cloudtower-api-doc/swagger/utils/wrap.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cloudtower-api-doc/swagger/utils/wrap.ts b/cloudtower-api-doc/swagger/utils/wrap.ts index 0c99839..423ac21 100644 --- a/cloudtower-api-doc/swagger/utils/wrap.ts +++ b/cloudtower-api-doc/swagger/utils/wrap.ts @@ -87,6 +87,20 @@ export const wrapSpecWithI18n = ( schema: components.schemas[s], prefix: ["components", "schemas", s], describeFn: ({ prefix, path }) => { + const schemaObj = _.get(cloneSpec, prefix); + const type = schemaObj['type']; + if (type === "object") { + if(!schemaObj['properties']) { + _.set(cloneSpec, [...prefix, "title"], prefix[prefix.length - 1]); + } else { + Object.keys(schemaObj['properties']).forEach((key) => { + if(schemaObj['properties'][key]['allOf']) { + const allOfRef = schemaObj['properties'][key]['allOf'][0]['$ref']; + _.set(cloneSpec, [...prefix, "properties", key, "title"], allOfRef.split('/').pop()); + } + }) + } + } _.set(cloneSpec, [...prefix, "description"], schema[path]); }, });