diff --git a/src/components/SideMenu/SideMenu.tsx b/src/components/SideMenu/SideMenu.tsx index 58dd34c5..93ff9875 100644 --- a/src/components/SideMenu/SideMenu.tsx +++ b/src/components/SideMenu/SideMenu.tsx @@ -13,10 +13,32 @@ import RedoclyLogo from './Logo'; @observer export class SideMenu extends React.Component<{ menu: MenuStore; className?: string }> { static contextType = OptionsContext; + private _updateScroll?: () => void; render() { const store = this.props.menu; + const items = store.items; + + if (this.context.putDownScheme) { + const reorderSchema = item => { + if (item.type === 'tag') { + return item.items.sort((a, b) => { + return a.type === 'schema' ? -1 : b.type === 'schema' ? -1 : 0; + }); + } else { + return item; + } + }; + + items.map(item => { + if (item.type === 'group') { + return item.items.map(reorderSchema); + } + return reorderSchema(item); + }); + } + return ( - + diff --git a/src/services/RedocNormalizedOptions.ts b/src/services/RedocNormalizedOptions.ts index 0cdd7f9e..3ff91b50 100644 --- a/src/services/RedocNormalizedOptions.ts +++ b/src/services/RedocNormalizedOptions.ts @@ -57,6 +57,7 @@ export interface RedocRawOptions { hideFab?: boolean; minCharacterLengthToInitSearch?: number; showWebhookVerb?: boolean; + putDownScheme?: boolean; } export function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean { @@ -258,6 +259,7 @@ export class RedocNormalizedOptions { hideFab: boolean; minCharacterLengthToInitSearch: number; showWebhookVerb: boolean; + putDownScheme: boolean; nonce?: string; @@ -338,5 +340,6 @@ export class RedocNormalizedOptions { this.hideFab = argValueToBoolean(raw.hideFab); this.minCharacterLengthToInitSearch = argValueToNumber(raw.minCharacterLengthToInitSearch) || 3; this.showWebhookVerb = argValueToBoolean(raw.showWebhookVerb); + this.putDownScheme = argValueToBoolean(raw.putDownScheme, false); } }