Skip to content

Commit

Permalink
feat: new option sortEnumValuesAlphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed Jul 21, 2020
1 parent 4db5bc4 commit 2f45300
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/services/RedocNormalizedOptions.ts
Expand Up @@ -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;
Expand Down Expand Up @@ -154,6 +155,7 @@ export class RedocNormalizedOptions {
expandResponses: { [code: string]: boolean } | 'all';
requiredPropsFirst: boolean;
sortPropsAlphabetically: boolean;
sortEnumValuesAlphabetically: boolean;
noAutoAuth: boolean;
nativeScrollbars: boolean;
pathInMiddlePanel: boolean;
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/services/models/Schema.ts
Expand Up @@ -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) {
Expand Down

0 comments on commit 2f45300

Please sign in to comment.