diff --git a/src/services/RedocNormalizedOptions.ts b/src/services/RedocNormalizedOptions.ts index a99525295f..6007fe9cf7 100644 --- a/src/services/RedocNormalizedOptions.ts +++ b/src/services/RedocNormalizedOptions.ts @@ -12,6 +12,7 @@ export interface RedocRawOptions { expandResponses?: string | 'all'; requiredPropsFirst?: boolean | string; sortPropsAlphabetically?: boolean | string; + sortEnumValuesAlphabetically?: boolean | string; noAutoAuth?: boolean | string; nativeScrollbars?: boolean | string; pathInMiddlePanel?: boolean | string; @@ -154,6 +155,7 @@ export class RedocNormalizedOptions { expandResponses: { [code: string]: boolean } | 'all'; requiredPropsFirst: boolean; sortPropsAlphabetically: boolean; + sortEnumValuesAlphabetically: boolean; noAutoAuth: boolean; nativeScrollbars: boolean; pathInMiddlePanel: boolean; @@ -205,6 +207,7 @@ export class RedocNormalizedOptions { this.expandResponses = RedocNormalizedOptions.normalizeExpandResponses(raw.expandResponses); this.requiredPropsFirst = argValueToBoolean(raw.requiredPropsFirst); this.sortPropsAlphabetically = argValueToBoolean(raw.sortPropsAlphabetically); + this.sortEnumValuesAlphabetically = argValueToBoolean(raw.sortEnumValuesAlphabetically); this.noAutoAuth = argValueToBoolean(raw.noAutoAuth); this.nativeScrollbars = argValueToBoolean(raw.nativeScrollbars); this.pathInMiddlePanel = argValueToBoolean(raw.pathInMiddlePanel); diff --git a/src/services/models/Schema.ts b/src/services/models/Schema.ts index e393614e93..8e0b169abc 100644 --- a/src/services/models/Schema.ts +++ b/src/services/models/Schema.ts @@ -168,6 +168,10 @@ export class SchemaModel { this.enum = this.items.enum; } } + + if (this.enum.length && this.options.sortEnumValuesAlphabetically) { + this.enum.sort(); + } } private initOneOf(oneOf: OpenAPISchema[], parser: OpenAPIParser) {