Skip to content

Commit

Permalink
feat: Add support for displaying operationId in the sidebar (#1927)
Browse files Browse the repository at this point in the history
* feat: Add support for displaying id in the sidebar

* fix: previous commit `feat: Add support for displaying id in the sidebar`

Co-authored-by: Oprysk <vyacheslav@redocly.com>
  • Loading branch information
Rycochet and Oprysk authored Mar 23, 2022
1 parent ab3e8a8 commit 09786f2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ You can use all of the following options with the standalone version of the <red
* `sideNavStyle` - can be specified in various ways:
* **summary-only**: displays a summary in the sidebar navigation item. (**default**)
* **path-only**: displays a path in the sidebar navigation item.
* **id-only**: displays the operation id with a fallback to the path in the sidebar navigation item.

### `<redoc>` theme object
* `spacing`
Expand Down
3 changes: 3 additions & 0 deletions src/services/RedocNormalizedOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { MDXComponentMeta } from './MarkdownRenderer';
export enum SideNavStyleEnum {
SummaryOnly = 'summary-only',
PathOnly = 'path-only',
IdOnly = 'id-only',
}

export interface RedocRawOptions {
Expand Down Expand Up @@ -170,6 +171,8 @@ export class RedocNormalizedOptions {
return value;
case SideNavStyleEnum.PathOnly:
return SideNavStyleEnum.PathOnly;
case SideNavStyleEnum.IdOnly:
return SideNavStyleEnum.IdOnly;
default:
return defaultValue;
}
Expand Down
7 changes: 6 additions & 1 deletion src/services/models/Operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ export class OperationModel implements IMenuItem {

this.name = getOperationSummary(operationSpec);

this.sidebarLabel = options.sideNavStyle === SideNavStyleEnum.PathOnly ? this.path : this.name;
this.sidebarLabel =
options.sideNavStyle === SideNavStyleEnum.IdOnly
? this.operationId || this.path
: options.sideNavStyle === SideNavStyleEnum.PathOnly
? this.path
: this.name;

if (this.isCallback) {
// NOTE: Callbacks by default should not inherit the specification's global `security` definition.
Expand Down

0 comments on commit 09786f2

Please sign in to comment.