diff --git a/src/services/RedocNormalizedOptions.ts b/src/services/RedocNormalizedOptions.ts index 283eba90..2128a359 100644 --- a/src/services/RedocNormalizedOptions.ts +++ b/src/services/RedocNormalizedOptions.ts @@ -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( diff --git a/src/services/models/Operation.ts b/src/services/models/Operation.ts index 1af413ee..91fda8d4 100644 --- a/src/services/models/Operation.ts +++ b/src/services/models/Operation.ts @@ -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.