Skip to content

Commit 3683ccf

Browse files
committed
fallback to origin
1 parent ec9ca85 commit 3683ccf

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

cloudtower-api-doc/swagger/SKS-App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
ISpec,
99
sksSpecMap as specMap,
1010
overwriteSchemaTitle,
11-
// wrapSpecWithI18n,
11+
wrapSpecWithI18n,
1212
} from "./utils";
1313
import Redocly from "./redoc/Redoc";
1414
import { LOCAL_STORAGE_SERVERS_KEY } from "./redoc/Console/ServerDropdown";
@@ -78,7 +78,7 @@ const App: React.FC = () => {
7878
const swaggerSpec: ISpec = _.cloneDeep(data.default);
7979
setRawSpec(swaggerSpec);
8080
i18next.changeLanguage(i18n.currentLocale);
81-
setSpec(swaggerSpec);
81+
setSpec(wrapSpecWithI18n(swaggerSpec, i18n.currentLocale, version));
8282
})
8383

8484
}, [version, i18n.currentLocale]);

cloudtower-api-doc/swagger/utils/wrap.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ export const wrapSpecWithI18n = (
4040
const method = Object.keys(paths[p])[0]
4141
const operationObj = paths[p][method] as OpenAPIV3.OperationObject;
4242
const { description, summary } = apiDoc;
43-
operationObj .description = description;
44-
operationObj .summary = summary;
43+
const { description: originDes, summary: originSum } = operationObj;
44+
operationObj.description = description || originDes;
45+
operationObj.summary = summary || originSum;
4546
const example = swaggerSpecExample [p] || {};
4647
if(example) {
4748
operationObj["x-codeSamples"] = [
@@ -88,7 +89,8 @@ export const wrapSpecWithI18n = (
8889
schema: components.schemas[s],
8990
prefix: ["components", "schemas", s],
9091
describeFn: ({ prefix, path }) => {
91-
_.set(cloneSpec, [...prefix, "description"], schema[path]);
92+
const originDes = _.get(cloneSpec, [...prefix, 'description']);
93+
_.set(cloneSpec, [...prefix, "description"], schema[path] || originDes);
9294
},
9395
});
9496
});

0 commit comments

Comments
 (0)