From c8e237f75202fb6957a1a9ff8b052b9417820bab Mon Sep 17 00:00:00 2001 From: netweng Date: Sat, 12 Oct 2024 14:13:20 +0800 Subject: [PATCH] TOWER-14722/ISSUE-55:show all fields --- cloudtower-api-doc/swagger/App.tsx | 12 +----------- cloudtower-api-doc/swagger/overwrite.css | 5 +++++ cloudtower-api-doc/swagger/utils/wrap.ts | 25 ------------------------ 3 files changed, 6 insertions(+), 36 deletions(-) diff --git a/cloudtower-api-doc/swagger/App.tsx b/cloudtower-api-doc/swagger/App.tsx index 41e1e7c2..8b7d7a03 100644 --- a/cloudtower-api-doc/swagger/App.tsx +++ b/cloudtower-api-doc/swagger/App.tsx @@ -8,7 +8,6 @@ import { ISpec, specMap, wrapSpecWithI18n, - splitSchema, overwriteSchemaTitle, } from "./utils"; import Redocly from "./redoc/Redoc"; @@ -66,13 +65,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(); @@ -86,9 +78,7 @@ const App: React.FC = () => { const swaggerSpec: ISpec = _.cloneDeep(data.default); setRawSpec(swaggerSpec); i18next.changeLanguage(i18n.currentLocale); - const newSpec = splitSchema( - wrapSpecWithI18n(swaggerSpec, i18n.currentLocale, version) - ); + const newSpec = wrapSpecWithI18n(swaggerSpec, i18n.currentLocale, version); setSpec(newSpec); }) diff --git a/cloudtower-api-doc/swagger/overwrite.css b/cloudtower-api-doc/swagger/overwrite.css index d2230ec6..72e2a55b 100644 --- a/cloudtower-api-doc/swagger/overwrite.css +++ b/cloudtower-api-doc/swagger/overwrite.css @@ -245,4 +245,9 @@ div.menu__list-item-collapsible > a::after { div.menu__list-item-collapsible > a[aria-expanded=true]::after { transform: rotate(180deg); transition: transform var(--ifm-transition-fast) linear; +} + +/* recursive label */ +.sc-kqnjJL.sc-zjkyB.kMcpvW.kGqNFZ { + display: none; } \ No newline at end of file diff --git a/cloudtower-api-doc/swagger/utils/wrap.ts b/cloudtower-api-doc/swagger/utils/wrap.ts index 05eec320..0c99839b 100644 --- a/cloudtower-api-doc/swagger/utils/wrap.ts +++ b/cloudtower-api-doc/swagger/utils/wrap.ts @@ -105,28 +105,3 @@ export const wrapSpecWithI18n = ( })); return cloneSpec; }; - - -export const splitSchema = (spec: ISpec,) => { - const cloneSpec = _.cloneDeep(spec); - const traveseSchema = (name: string, schemaContent: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject, properties_path: string[]) => { - if((schemaContent as OpenAPIV3.SchemaObject)?.type === 'object') { - Object.entries((schemaContent as OpenAPIV3.SchemaObject)?.properties || {}).forEach(([key, value]) => { - if( - ['AND', 'OR', 'NOT'].includes(key) || - ((key.endsWith('_some') || key.endsWith('_every') || key.endsWith('none') && ((value as OpenAPIV3.SchemaObject).allOf?.[0] as OpenAPIV3.ReferenceObject)?.$ref?.endsWith('WhereInput'))) - ) { - _.unset(cloneSpec, ['components', 'schemas', ...properties_path, 'properties', key]); - } - traveseSchema(key, value, properties_path.concat(['properties', key])); - }) - } - } - Object.entries(cloneSpec.components.schemas).forEach(( - [ schemaName, schema ] - ) => { - const properties_path = [ schemaName ]; - traveseSchema(schemaName, schema, properties_path); - }) - return cloneSpec; -} \ No newline at end of file