Rename usePathInSidebar to sideNavStyle

This commit is contained in:
Junghyun Colin Kim 2021-11-27 02:33:51 +09:00
parent e16fa80030
commit bd41e3e18b
2 changed files with 20 additions and 4 deletions

View File

@ -22,7 +22,7 @@ export interface RedocRawOptions {
disableSearch?: boolean | string;
onlyRequiredInSamples?: boolean | string;
showExtensions?: boolean | string | string[];
usePathInSidebar?: boolean;
sideNavStyle?: string | 'summary-only';
hideSingleRequestSampleTab?: boolean | string;
menuToggle?: boolean | string;
jsonSampleExpandLevel?: number | string | 'all';
@ -143,6 +143,22 @@ export class RedocNormalizedOptions {
}
}
static normalizeSideNavStyle(value: RedocRawOptions['sideNavStyle']): string {
const defaultValue = 'summary-only';
if (typeof value !== 'string') {
return defaultValue;
}
switch (value) {
case defaultValue:
return value;
case 'path-only':
return value;
default:
return defaultValue;
}
}
static normalizePayloadSampleIdx(value: RedocRawOptions['payloadSampleIdx']): number {
if (typeof value === 'number') {
return Math.max(0, value); // always greater or equal than 0
@ -190,7 +206,7 @@ export class RedocNormalizedOptions {
disableSearch: boolean;
onlyRequiredInSamples: boolean;
showExtensions: boolean | string[];
usePathInSidebar: boolean;
sideNavStyle: string;
hideSingleRequestSampleTab: boolean;
menuToggle: boolean;
jsonSampleExpandLevel: number;
@ -249,7 +265,7 @@ export class RedocNormalizedOptions {
this.disableSearch = argValueToBoolean(raw.disableSearch);
this.onlyRequiredInSamples = argValueToBoolean(raw.onlyRequiredInSamples);
this.showExtensions = RedocNormalizedOptions.normalizeShowExtensions(raw.showExtensions);
this.usePathInSidebar = argValueToBoolean(raw.usePathInSidebar);
this.sideNavStyle = RedocNormalizedOptions.normalizeSideNavStyle(raw.sideNavStyle);
this.hideSingleRequestSampleTab = argValueToBoolean(raw.hideSingleRequestSampleTab);
this.menuToggle = argValueToBoolean(raw.menuToggle, true);
this.jsonSampleExpandLevel = RedocNormalizedOptions.normalizeJsonSampleExpandLevel(

View File

@ -106,7 +106,7 @@ export class OperationModel implements IMenuItem {
this.name = getOperationSummary(operationSpec);
this.sidebarName = this.name;
if (options.usePathInSidebar) this.sidebarName = this.path;
if (options.sideNavStyle === 'path-only') this.sidebarName = this.path;
if (this.isCallback) {
// NOTE: Callbacks by default should not inherit the specification's global `security` definition.