Skip to content

Commit

Permalink
TOWER-14722/ISSUE-55:show all fields
Browse files Browse the repository at this point in the history
  • Loading branch information
netweng committed Oct 12, 2024
1 parent 87e8be1 commit c8e237f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 36 deletions.
12 changes: 1 addition & 11 deletions cloudtower-api-doc/swagger/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
ISpec,
specMap,
wrapSpecWithI18n,
splitSchema,
overwriteSchemaTitle,
} from "./utils";
import Redocly from "./redoc/Redoc";
Expand Down Expand Up @@ -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();
Expand All @@ -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);
})

Expand Down
5 changes: 5 additions & 0 deletions cloudtower-api-doc/swagger/overwrite.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
25 changes: 0 additions & 25 deletions cloudtower-api-doc/swagger/utils/wrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit c8e237f

Please sign in to comment.