Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
netweng committed Oct 19, 2023
1 parent 8e88574 commit d4053c2
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 110 deletions.
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

2 changes: 1 addition & 1 deletion cloudtower-api-doc/static/specs/3.3.0-swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -93352,7 +93352,7 @@
},
"info": {
"title": "CloudTower APIs",
"version": "2.3.0",
"version": "3.3.0",
"description": "cloudtower operation API and SDK"
},
"openapi": "3.0.0",
Expand Down
23 changes: 9 additions & 14 deletions cloudtower-api-doc/swagger/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ const Redoc: React.FC<{
);
};

// const Redoc = React.memo(RedocWrapper, (prev, next) => {
// return (
// JSON.stringify({ tags: prev.spec?.tags, servers: prev.spec?.servers }) ===
// JSON.stringify({ tags: next.spec?.tags, servers: next.spec?.servers })
// );
// });

const App: React.FC = () => {
const { i18n } = useDocusaurusContext();
const { search } = useLocation();
Expand All @@ -82,13 +75,15 @@ const App: React.FC = () => {
const specRef = useRef<ISpec>(spec);
useEffect(() => {
const lastVersion = specMap[version] ? version : Object.keys(specMap)[0];
const swaggerSpec: ISpec = _.cloneDeep(specMap[lastVersion]);
setRawSpec(swaggerSpec);
i18next.changeLanguage(i18n.currentLocale);
const newSpec = splitSchema(
wrapSpecWithI18n(swaggerSpec, i18n.currentLocale, version)
);
setSpec(newSpec);
specMap[lastVersion].then(data => {
const swaggerSpec: ISpec = _.cloneDeep(data.default);
setRawSpec(swaggerSpec);
i18next.changeLanguage(i18n.currentLocale);
const newSpec = splitSchema(
wrapSpecWithI18n(swaggerSpec, i18n.currentLocale, version)
);
setSpec(newSpec);
})
}, [version, i18n.currentLocale]);

useEffect(() => {
Expand Down
120 changes: 60 additions & 60 deletions cloudtower-api-doc/swagger/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,54 @@ import zhComponents from './locales/zh/components.json';
import zh1_8Api from './locales/zh/1.8.0.json';
import en1_8API from './locales/en/1.8.0.json'

import zh1_9Api from './locales/zh/1.9.0.json';
import en1_9API from './locales/en/1.9.0.json'
// import zh1_9Api from './locales/zh/1.9.0.json';
// import en1_9API from './locales/en/1.9.0.json'

import zh1_10Api from './locales/zh/1.10.0.json';
import en1_10Api from './locales/en/1.10.0.json'
// import zh1_10Api from './locales/zh/1.10.0.json';
// import en1_10Api from './locales/en/1.10.0.json'

import zh2_0API from './locales/zh/2.0.0.json';
import en2_0API from './locales/en/2.0.0.json';
// import zh2_0API from './locales/zh/2.0.0.json';
// import en2_0API from './locales/en/2.0.0.json';

import zh2_1API from './locales/zh/2.1.0.json';
import en2_1API from './locales/en/2.1.0.json';
// import zh2_1API from './locales/zh/2.1.0.json';
// import en2_1API from './locales/en/2.1.0.json';


import zh2_2API from './locales/zh/2.2.0.json';
import en2_2API from './locales/en/2.2.0.json';
// import zh2_2API from './locales/zh/2.2.0.json';
// import en2_2API from './locales/en/2.2.0.json';

import zh2_3API from './locales/zh/2.3.0.json';
import en2_3API from './locales/en/2.3.0.json';
// import zh2_3API from './locales/zh/2.3.0.json';
// import en2_3API from './locales/en/2.3.0.json';

import zh2_4API from './locales/zh/2.4.0.json';
import en2_4API from './locales/en/2.4.0.json';
// import zh2_4API from './locales/zh/2.4.0.json';
// import en2_4API from './locales/en/2.4.0.json';


import zh2_5API from './locales/zh/2.5.0.json';
import en2_5API from './locales/en/2.5.0.json';
// import zh2_5API from './locales/zh/2.5.0.json';
// import en2_5API from './locales/en/2.5.0.json';

import zh2_6API from './locales/zh/2.6.0.json';
import en2_6API from './locales/en/2.6.0.json';
// import zh2_6API from './locales/zh/2.6.0.json';
// import en2_6API from './locales/en/2.6.0.json';


import zh2_7API from './locales/zh/2.7.0.json';
import en2_7API from './locales/en/2.7.0.json';
// import zh2_7API from './locales/zh/2.7.0.json';
// import en2_7API from './locales/en/2.7.0.json';

import zh2_8API from './locales/zh/2.8.0.json';
import en2_8API from './locales/en/2.8.0.json';
// import zh2_8API from './locales/zh/2.8.0.json';
// import en2_8API from './locales/en/2.8.0.json';

import zh3_0API from './locales/zh/3.0.0.json';
import en3_0API from './locales/en/3.0.0.json';
// import zh3_0API from './locales/zh/3.0.0.json';
// import en3_0API from './locales/en/3.0.0.json';

import zh3_1API from './locales/zh/3.1.0.json';
import en3_1API from './locales/en/3.1.0.json';
// import zh3_1API from './locales/zh/3.1.0.json';
// import en3_1API from './locales/en/3.1.0.json';

import zh3_2API from './locales/zh/3.2.0.json';
import en3_2API from './locales/en/3.2.0.json';
// import zh3_2API from './locales/zh/3.2.0.json';
// import en3_2API from './locales/en/3.2.0.json';


import zh3_3API from './locales/zh/3.3.0.json';
import en3_3API from './locales/en/3.3.0.json';
// import zh3_3API from './locales/zh/3.3.0.json';
// import en3_3API from './locales/en/3.3.0.json';


export type ApiDoc = {
Expand All @@ -68,40 +68,40 @@ i18next.init({
resources: {
[SupportLanguage.en]: {
['1_8_0']: en1_8API,
['1_9_0']: en1_9API,
['1_10_0']: en1_10Api,
['2_0_0']: en2_0API,
['2_1_0']: en2_1API,
['2_2_0']: en2_2API,
['2_3_0']: en2_3API,
['2_4_0']: en2_4API,
['2_5_0']: en2_5API,
['2_6_0']: en2_6API,
['2_7_0']: en2_7API,
['2_8_0']: en2_8API,
['3_0_0']: en3_0API,
['3_1_0']: en3_1API,
['3_2_0']: en3_2API,
['3_3_0']: en3_3API,
// ['1_9_0']: en1_9API,
// ['1_10_0']: en1_10Api,
// ['2_0_0']: en2_0API,
// ['2_1_0']: en2_1API,
// ['2_2_0']: en2_2API,
// ['2_3_0']: en2_3API,
// ['2_4_0']: en2_4API,
// ['2_5_0']: en2_5API,
// ['2_6_0']: en2_6API,
// ['2_7_0']: en2_7API,
// ['2_8_0']: en2_8API,
// ['3_0_0']: en3_0API,
// ['3_1_0']: en3_1API,
// ['3_2_0']: en3_2API,
// ['3_3_0']: en3_3API,
components: enComponents,
},
[SupportLanguage.zh]: {
['1_8_0']:zh1_8Api,
['1_9_0']:zh1_9Api,
['1_10_0']: zh1_10Api,
['2_0_0']: zh2_0API,
['2_1_0']: zh2_1API,
['2_2_0']: zh2_2API,
['2_3_0']: zh2_3API,
['2_4_0']: zh2_4API,
['2_5_0']: zh2_5API,
['2_6_0']: zh2_6API,
['2_7_0']: zh2_7API,
['2_8_0']: zh2_8API,
['3_0_0']: zh3_0API,
['3_1_0']: zh3_1API,
['3_2_0']: zh3_2API,
['3_3_0']: zh3_3API,
// ['1_9_0']:zh1_9Api,
// ['1_10_0']: zh1_10Api,
// ['2_0_0']: zh2_0API,
// ['2_1_0']: zh2_1API,
// ['2_2_0']: zh2_2API,
// ['2_3_0']: zh2_3API,
// ['2_4_0']: zh2_4API,
// ['2_5_0']: zh2_5API,
// ['2_6_0']: zh2_6API,
// ['2_7_0']: zh2_7API,
// ['2_8_0']: zh2_8API,
// ['3_0_0']: zh3_0API,
// ['3_1_0']: zh3_1API,
// ['3_2_0']: zh3_2API,
// ['3_3_0']: zh3_3API,
components: zhComponents,
},
},
Expand Down
50 changes: 16 additions & 34 deletions cloudtower-api-doc/swagger/utils/swagger.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,22 @@
import { OpenAPIV3 } from 'openapi-types';

import swaggerSpec1_8 from "../../static/specs/1.8.0-swagger.json";
import swaggerSpec1_9 from '../../static/specs/1.9.0-swagger.json';
import swaggerSpec1_10 from '../../static/specs/1.10.0-swagger.json';
import swaggerSpec2_0 from '../../static/specs/2.0.0-swagger.json';
import swaggerSpec2_1 from '../../static/specs/2.1.0-swagger.json';
import swaggerSpec2_2 from '../../static/specs/2.2.0-swagger.json';
import swaggerSpec2_3 from '../../static/specs/2.3.0-swagger.json';
import swaggerSpec2_4 from '../../static/specs/2.4.0-swagger.json';
import swaggerSpec2_5 from '../../static/specs/2.5.0-swagger.json';
import swaggerSpec2_6 from '../../static/specs/2.6.0-swagger.json';
import swaggerSpec2_7 from '../../static/specs/2.7.0-swagger.json';
import swaggerSpec2_8 from '../../static/specs/2.8.0-swagger.json';
import swaggerSpec3_0 from '../../static/specs/3.0.0-swagger.json';
import swaggerSpec3_1 from '../../static/specs/3.1.0-swagger.json';
import swaggerSpec3_2 from '../../static/specs/3.2.0-swagger.json';
import swaggerSpec3_3 from '../../static/specs/3.3.0-swagger.json';


export const specMap = {
'3.3.0': swaggerSpec3_3,
'3.2.0': swaggerSpec3_2,
'3.1.0': swaggerSpec3_1,
'3.0.0': swaggerSpec3_0,
'2.8.0': swaggerSpec2_8,
'2.7.0': swaggerSpec2_7,
'2.6.0': swaggerSpec2_6,
'2.5.0': swaggerSpec2_5,
'2.4.0': swaggerSpec2_4,
'2.3.0': swaggerSpec2_3,
'2.2.0': swaggerSpec2_2,
'2.1.0': swaggerSpec2_1,
'2.0.0': swaggerSpec2_0,
'1.10.0': swaggerSpec1_10,
'1.9.0': swaggerSpec1_9,
'1.8.0': swaggerSpec1_8,
'3.3.0': import('../../static/specs/3.3.0-swagger.json'),
'3.2.0': import('../../static/specs/3.2.0-swagger.json'),
'3.1.0': import('../../static/specs/3.1.0-swagger.json'),
'3.0.0': import('../../static/specs/3.0.0-swagger.json'),
'2.8.0': import('../../static/specs/2.8.0-swagger.json'),
'2.7.0': import('../../static/specs/2.7.0-swagger.json'),
'2.6.0': import('../../static/specs/2.6.0-swagger.json'),
'2.5.0': import('../../static/specs/2.5.0-swagger.json'),
'2.4.0': import('../../static/specs/2.4.0-swagger.json'),
'2.3.0': import('../../static/specs/2.3.0-swagger.json'),
'2.2.0': import('../../static/specs/2.2.0-swagger.json'),
'2.1.0': import('../../static/specs/2.1.0-swagger.json'),
'2.0.0': import('../../static/specs/2.0.0-swagger.json'),
'1.10.0': import('../../static/specs/1.10.0-swagger.json'),
'1.9.0': import('../../static/specs/1.9.0-swagger.json'),
'1.8.0': import('../../static/specs/1.8.0-swagger.json'),
}


Expand Down

0 comments on commit d4053c2

Please sign in to comment.