2018-03-17 00:58:25 +03:00
|
|
|
import defaultTheme, { ResolvedThemeInterface, resolveTheme, ThemeInterface } from '../theme';
|
2018-01-09 20:00:17 +03:00
|
|
|
import { querySelector } from '../utils/dom';
|
2022-05-06 19:01:47 +03:00
|
|
|
import { isArray, isNumeric, mergeObjects } from '../utils/helpers';
|
2017-11-20 19:02:49 +03:00
|
|
|
|
2022-07-18 17:47:06 +03:00
|
|
|
import { setRedocLabels } from './Labels';
|
|
|
|
import { SideNavStyleEnum } from './types';
|
|
|
|
import type { LabelsConfigRaw, MDXComponentMeta } from './types';
|
2021-12-08 16:53:14 +03:00
|
|
|
|
2017-11-20 23:36:21 +03:00
|
|
|
export interface RedocRawOptions {
|
|
|
|
theme?: ThemeInterface;
|
2018-01-22 21:30:53 +03:00
|
|
|
scrollYOffset?: number | string | (() => number);
|
2017-11-20 23:36:21 +03:00
|
|
|
hideHostname?: boolean | string;
|
2017-11-21 14:00:33 +03:00
|
|
|
expandResponses?: string | 'all';
|
2017-11-21 14:24:41 +03:00
|
|
|
requiredPropsFirst?: boolean | string;
|
2018-10-04 11:09:59 +03:00
|
|
|
sortPropsAlphabetically?: boolean | string;
|
2020-07-21 16:10:48 +03:00
|
|
|
sortEnumValuesAlphabetically?: boolean | string;
|
2021-12-30 15:31:00 +03:00
|
|
|
sortOperationsAlphabetically?: boolean | string;
|
|
|
|
sortTagsAlphabetically?: boolean | string;
|
2017-11-21 17:55:20 +03:00
|
|
|
nativeScrollbars?: boolean | string;
|
2017-11-22 11:57:51 +03:00
|
|
|
pathInMiddlePanel?: boolean | string;
|
2017-11-22 14:26:28 +03:00
|
|
|
untrustedSpec?: boolean | string;
|
2017-11-22 12:02:26 +03:00
|
|
|
hideLoading?: boolean | string;
|
2018-03-07 18:21:17 +03:00
|
|
|
hideDownloadButton?: boolean | string;
|
2022-05-10 20:09:01 +03:00
|
|
|
downloadFileName?: string;
|
|
|
|
downloadDefinitionUrl?: string;
|
2018-07-17 11:07:34 +03:00
|
|
|
disableSearch?: boolean | string;
|
2018-10-05 16:14:41 +03:00
|
|
|
onlyRequiredInSamples?: boolean | string;
|
2018-10-03 10:02:30 +03:00
|
|
|
showExtensions?: boolean | string | string[];
|
2021-12-08 16:53:14 +03:00
|
|
|
sideNavStyle?: SideNavStyleEnum;
|
2019-05-10 16:21:14 +03:00
|
|
|
hideSingleRequestSampleTab?: boolean | string;
|
2019-07-11 12:25:13 +03:00
|
|
|
menuToggle?: boolean | string;
|
2019-07-29 15:26:16 +03:00
|
|
|
jsonSampleExpandLevel?: number | string | 'all';
|
2019-12-12 17:59:04 +03:00
|
|
|
hideSchemaTitles?: boolean | string;
|
2020-08-04 12:19:49 +03:00
|
|
|
simpleOneOfTypeLabel?: boolean | string;
|
2019-12-12 20:08:05 +03:00
|
|
|
payloadSampleIdx?: number;
|
2020-03-13 19:23:24 +03:00
|
|
|
expandSingleSchemaField?: boolean | string;
|
2022-01-25 17:43:14 +03:00
|
|
|
schemaExpansionLevel?: number | string | 'all';
|
2021-12-29 13:22:57 +03:00
|
|
|
showObjectSchemaExamples?: boolean | string;
|
2022-05-30 18:55:39 +03:00
|
|
|
showSecuritySchemeType?: boolean;
|
2022-05-31 13:20:23 +03:00
|
|
|
hideSecuritySection?: boolean;
|
2018-05-29 17:41:50 +03:00
|
|
|
|
|
|
|
unstable_ignoreMimeParameters?: boolean;
|
2018-08-17 14:41:22 +03:00
|
|
|
|
2020-05-25 16:37:38 +03:00
|
|
|
allowedMdComponents?: Record<string, MDXComponentMeta>;
|
2019-05-12 21:19:36 +03:00
|
|
|
|
|
|
|
labels?: LabelsConfigRaw;
|
2019-09-30 10:39:19 +03:00
|
|
|
|
2019-07-15 11:14:48 +03:00
|
|
|
enumSkipQuotes?: boolean | string;
|
2019-09-30 10:39:19 +03:00
|
|
|
|
|
|
|
expandDefaultServerVariables?: boolean;
|
2020-07-21 16:36:08 +03:00
|
|
|
maxDisplayedEnumValues?: number;
|
2020-09-24 13:59:59 +03:00
|
|
|
ignoreNamedSchemas?: string[] | string;
|
2020-11-30 12:54:46 +03:00
|
|
|
hideSchemaPattern?: boolean;
|
2021-09-14 13:08:50 +03:00
|
|
|
generatedPayloadSamplesMaxDepth?: number;
|
2022-03-23 19:02:30 +03:00
|
|
|
nonce?: string;
|
2022-03-14 16:36:50 +03:00
|
|
|
hideFab?: boolean;
|
2022-05-03 10:48:08 +03:00
|
|
|
minCharacterLengthToInitSearch?: number;
|
2022-05-11 19:13:50 +03:00
|
|
|
showWebhookVerb?: boolean;
|
2017-11-21 14:24:41 +03:00
|
|
|
}
|
|
|
|
|
2021-08-03 13:37:01 +03:00
|
|
|
export function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean {
|
2018-01-22 21:30:53 +03:00
|
|
|
if (val === undefined) {
|
2019-12-12 14:16:42 +03:00
|
|
|
return defaultValue || false;
|
2018-01-22 21:30:53 +03:00
|
|
|
}
|
|
|
|
if (typeof val === 'string') {
|
2021-08-31 15:39:55 +03:00
|
|
|
return val !== 'false';
|
2018-01-22 21:30:53 +03:00
|
|
|
}
|
2017-11-21 14:24:41 +03:00
|
|
|
return val;
|
2017-11-20 23:36:21 +03:00
|
|
|
}
|
|
|
|
|
2020-07-21 16:36:08 +03:00
|
|
|
function argValueToNumber(value: number | string | undefined): number | undefined {
|
|
|
|
if (typeof value === 'string') {
|
|
|
|
return parseInt(value, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof value === 'number') {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-25 17:43:14 +03:00
|
|
|
function argValueToExpandLevel(value?: number | string | undefined, defaultValue = 0): number {
|
|
|
|
if (value === 'all') return Infinity;
|
|
|
|
|
|
|
|
return argValueToNumber(value) || defaultValue;
|
|
|
|
}
|
|
|
|
|
2017-11-20 19:02:49 +03:00
|
|
|
export class RedocNormalizedOptions {
|
2017-11-21 14:00:33 +03:00
|
|
|
static normalizeExpandResponses(value: RedocRawOptions['expandResponses']) {
|
|
|
|
if (value === 'all') {
|
|
|
|
return 'all';
|
|
|
|
}
|
|
|
|
if (typeof value === 'string') {
|
|
|
|
const res = {};
|
2021-11-24 17:47:24 +03:00
|
|
|
value.split(',').forEach(code => {
|
2017-11-21 14:00:33 +03:00
|
|
|
res[code.trim()] = true;
|
|
|
|
});
|
|
|
|
return res;
|
2017-11-21 14:24:41 +03:00
|
|
|
} else if (value !== undefined) {
|
2017-11-21 14:00:33 +03:00
|
|
|
console.warn(
|
|
|
|
`expandResponses must be a string but received value "${value}" of type ${typeof value}`,
|
|
|
|
);
|
|
|
|
}
|
2017-11-21 14:24:41 +03:00
|
|
|
return {};
|
2017-11-20 23:36:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static normalizeHideHostname(value: RedocRawOptions['hideHostname']): boolean {
|
|
|
|
return !!value;
|
2017-11-20 19:02:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static normalizeScrollYOffset(value: RedocRawOptions['scrollYOffset']): () => number {
|
|
|
|
// just number is not valid selector and leads to crash so checking if isNumeric here
|
|
|
|
if (typeof value === 'string' && !isNumeric(value)) {
|
2018-01-09 20:00:17 +03:00
|
|
|
const el = querySelector(value);
|
2017-11-20 19:02:49 +03:00
|
|
|
if (!el) {
|
|
|
|
console.warn(
|
|
|
|
'scrollYOffset value is a selector to non-existing element. Using offset 0 by default',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
const bottom = (el && el.getBoundingClientRect().bottom) || 0;
|
|
|
|
return () => bottom;
|
|
|
|
} else if (typeof value === 'number' || isNumeric(value)) {
|
|
|
|
return () => (typeof value === 'number' ? value : parseFloat(value));
|
|
|
|
} else if (typeof value === 'function') {
|
|
|
|
return () => {
|
|
|
|
const res = value();
|
|
|
|
if (typeof res !== 'number') {
|
|
|
|
console.warn(
|
|
|
|
`scrollYOffset should return number but returned value "${res}" of type ${typeof res}`,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
};
|
|
|
|
} else if (value !== undefined) {
|
|
|
|
console.warn(
|
|
|
|
'Wrong value for scrollYOffset ReDoc option: should be string, number or function',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return () => 0;
|
|
|
|
}
|
2018-01-22 21:30:53 +03:00
|
|
|
|
2018-10-03 10:02:30 +03:00
|
|
|
static normalizeShowExtensions(value: RedocRawOptions['showExtensions']): string[] | boolean {
|
|
|
|
if (typeof value === 'undefined') {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (value === '') {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-03-20 15:37:22 +03:00
|
|
|
if (typeof value !== 'string') {
|
2020-03-27 17:31:53 +03:00
|
|
|
return value;
|
2018-10-03 10:02:30 +03:00
|
|
|
}
|
|
|
|
|
2020-03-20 15:37:22 +03:00
|
|
|
switch (value) {
|
|
|
|
case 'true':
|
2020-03-27 17:31:53 +03:00
|
|
|
return true;
|
2020-03-20 15:37:22 +03:00
|
|
|
case 'false':
|
2020-03-27 17:31:53 +03:00
|
|
|
return false;
|
2020-03-20 15:37:22 +03:00
|
|
|
default:
|
2021-11-24 17:47:24 +03:00
|
|
|
return value.split(',').map(ext => ext.trim());
|
2020-03-20 15:37:22 +03:00
|
|
|
}
|
2018-10-03 10:02:30 +03:00
|
|
|
}
|
|
|
|
|
2021-12-08 16:53:14 +03:00
|
|
|
static normalizeSideNavStyle(value: RedocRawOptions['sideNavStyle']): SideNavStyleEnum {
|
|
|
|
const defaultValue = SideNavStyleEnum.SummaryOnly;
|
|
|
|
if (typeof value !== 'string') {
|
|
|
|
return defaultValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (value) {
|
|
|
|
case defaultValue:
|
|
|
|
return value;
|
|
|
|
case SideNavStyleEnum.PathOnly:
|
|
|
|
return SideNavStyleEnum.PathOnly;
|
2022-03-23 13:39:26 +03:00
|
|
|
case SideNavStyleEnum.IdOnly:
|
|
|
|
return SideNavStyleEnum.IdOnly;
|
2021-12-08 16:53:14 +03:00
|
|
|
default:
|
|
|
|
return defaultValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-12 20:08:05 +03:00
|
|
|
static normalizePayloadSampleIdx(value: RedocRawOptions['payloadSampleIdx']): number {
|
|
|
|
if (typeof value === 'number') {
|
|
|
|
return Math.max(0, value); // always greater or equal than 0
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof value === 'string') {
|
|
|
|
return isFinite(value) ? parseInt(value, 10) : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-07-29 15:26:16 +03:00
|
|
|
private static normalizeJsonSampleExpandLevel(level?: number | string | 'all'): number {
|
|
|
|
if (level === 'all') {
|
|
|
|
return +Infinity;
|
|
|
|
}
|
|
|
|
if (!isNaN(Number(level))) {
|
|
|
|
return Math.ceil(Number(level));
|
|
|
|
}
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2021-09-14 13:08:50 +03:00
|
|
|
private static normalizeGeneratedPayloadSamplesMaxDepth(
|
|
|
|
value?: number | string | undefined,
|
|
|
|
): number {
|
|
|
|
if (!isNaN(Number(value))) {
|
|
|
|
return Math.max(0, Number(value));
|
|
|
|
}
|
|
|
|
|
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
|
2018-03-16 18:02:31 +03:00
|
|
|
theme: ResolvedThemeInterface;
|
2018-01-22 21:30:53 +03:00
|
|
|
scrollYOffset: () => number;
|
|
|
|
hideHostname: boolean;
|
|
|
|
expandResponses: { [code: string]: boolean } | 'all';
|
|
|
|
requiredPropsFirst: boolean;
|
2018-10-04 11:09:59 +03:00
|
|
|
sortPropsAlphabetically: boolean;
|
2020-07-21 16:10:48 +03:00
|
|
|
sortEnumValuesAlphabetically: boolean;
|
2021-12-30 15:31:00 +03:00
|
|
|
sortOperationsAlphabetically: boolean;
|
|
|
|
sortTagsAlphabetically: boolean;
|
2018-01-22 21:30:53 +03:00
|
|
|
nativeScrollbars: boolean;
|
|
|
|
pathInMiddlePanel: boolean;
|
|
|
|
untrustedSpec: boolean;
|
2018-03-07 18:21:17 +03:00
|
|
|
hideDownloadButton: boolean;
|
2022-05-10 20:09:01 +03:00
|
|
|
downloadFileName?: string;
|
|
|
|
downloadDefinitionUrl?: string;
|
2018-07-17 11:07:34 +03:00
|
|
|
disableSearch: boolean;
|
2018-10-05 16:14:41 +03:00
|
|
|
onlyRequiredInSamples: boolean;
|
2018-10-03 10:02:30 +03:00
|
|
|
showExtensions: boolean | string[];
|
2021-12-08 16:53:14 +03:00
|
|
|
sideNavStyle: SideNavStyleEnum;
|
2019-05-10 16:21:14 +03:00
|
|
|
hideSingleRequestSampleTab: boolean;
|
2019-07-11 12:25:13 +03:00
|
|
|
menuToggle: boolean;
|
2019-07-29 15:26:16 +03:00
|
|
|
jsonSampleExpandLevel: number;
|
2019-07-15 11:14:48 +03:00
|
|
|
enumSkipQuotes: boolean;
|
2019-12-12 17:59:04 +03:00
|
|
|
hideSchemaTitles: boolean;
|
2020-08-04 12:19:49 +03:00
|
|
|
simpleOneOfTypeLabel: boolean;
|
2019-12-12 20:08:05 +03:00
|
|
|
payloadSampleIdx: number;
|
2020-03-13 19:23:24 +03:00
|
|
|
expandSingleSchemaField: boolean;
|
2022-01-25 17:43:14 +03:00
|
|
|
schemaExpansionLevel: number;
|
2021-12-29 13:22:57 +03:00
|
|
|
showObjectSchemaExamples: boolean;
|
2022-05-30 18:55:39 +03:00
|
|
|
showSecuritySchemeType?: boolean;
|
2022-05-31 13:20:23 +03:00
|
|
|
hideSecuritySection?: boolean;
|
2018-01-22 21:30:53 +03:00
|
|
|
|
2018-05-29 17:41:50 +03:00
|
|
|
/* tslint:disable-next-line */
|
|
|
|
unstable_ignoreMimeParameters: boolean;
|
2020-05-25 16:37:38 +03:00
|
|
|
allowedMdComponents: Record<string, MDXComponentMeta>;
|
2018-05-29 17:41:50 +03:00
|
|
|
|
2019-09-30 10:39:19 +03:00
|
|
|
expandDefaultServerVariables: boolean;
|
2020-07-21 16:36:08 +03:00
|
|
|
maxDisplayedEnumValues?: number;
|
2019-09-30 10:39:19 +03:00
|
|
|
|
2020-09-24 13:59:59 +03:00
|
|
|
ignoreNamedSchemas: Set<string>;
|
2020-11-30 12:54:46 +03:00
|
|
|
hideSchemaPattern: boolean;
|
2021-09-14 13:08:50 +03:00
|
|
|
generatedPayloadSamplesMaxDepth: number;
|
2022-03-14 16:36:50 +03:00
|
|
|
hideFab: boolean;
|
2022-05-03 10:48:08 +03:00
|
|
|
minCharacterLengthToInitSearch: number;
|
2022-05-11 19:13:50 +03:00
|
|
|
showWebhookVerb: boolean;
|
2020-09-24 13:59:59 +03:00
|
|
|
|
2022-03-23 19:02:30 +03:00
|
|
|
nonce?: string;
|
|
|
|
|
2018-08-17 14:41:22 +03:00
|
|
|
constructor(raw: RedocRawOptions, defaults: RedocRawOptions = {}) {
|
|
|
|
raw = { ...defaults, ...raw };
|
2018-10-08 11:54:07 +03:00
|
|
|
const hook = raw.theme && raw.theme.extensionsHook;
|
2020-03-27 17:31:53 +03:00
|
|
|
|
|
|
|
// migrate from old theme
|
|
|
|
if ((raw.theme as any)?.menu && !raw.theme?.sidebar) {
|
|
|
|
console.warn('Theme setting "menu" is deprecated. Rename to "sidebar"');
|
|
|
|
raw.theme!.sidebar = (raw.theme as any).menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((raw.theme as any)?.codeSample && !raw.theme?.codeBlock) {
|
|
|
|
console.warn('Theme setting "codeSample" is deprecated. Rename to "codeBlock"');
|
|
|
|
raw.theme!.codeBlock = (raw.theme as any).codeSample;
|
|
|
|
}
|
|
|
|
|
2018-10-08 11:54:07 +03:00
|
|
|
this.theme = resolveTheme(
|
|
|
|
mergeObjects({} as any, defaultTheme, { ...raw.theme, extensionsHook: undefined }),
|
|
|
|
);
|
|
|
|
|
|
|
|
this.theme.extensionsHook = hook as any;
|
2018-06-29 23:49:53 +03:00
|
|
|
|
2019-05-12 21:19:36 +03:00
|
|
|
// do not support dynamic labels changes. Labels should be configured before
|
|
|
|
setRedocLabels(raw.labels);
|
|
|
|
|
2018-01-22 21:30:53 +03:00
|
|
|
this.scrollYOffset = RedocNormalizedOptions.normalizeScrollYOffset(raw.scrollYOffset);
|
|
|
|
this.hideHostname = RedocNormalizedOptions.normalizeHideHostname(raw.hideHostname);
|
|
|
|
this.expandResponses = RedocNormalizedOptions.normalizeExpandResponses(raw.expandResponses);
|
|
|
|
this.requiredPropsFirst = argValueToBoolean(raw.requiredPropsFirst);
|
2018-10-04 11:09:59 +03:00
|
|
|
this.sortPropsAlphabetically = argValueToBoolean(raw.sortPropsAlphabetically);
|
2020-07-21 16:10:48 +03:00
|
|
|
this.sortEnumValuesAlphabetically = argValueToBoolean(raw.sortEnumValuesAlphabetically);
|
2021-12-30 15:31:00 +03:00
|
|
|
this.sortOperationsAlphabetically = argValueToBoolean(raw.sortOperationsAlphabetically);
|
|
|
|
this.sortTagsAlphabetically = argValueToBoolean(raw.sortTagsAlphabetically);
|
2018-01-22 21:30:53 +03:00
|
|
|
this.nativeScrollbars = argValueToBoolean(raw.nativeScrollbars);
|
|
|
|
this.pathInMiddlePanel = argValueToBoolean(raw.pathInMiddlePanel);
|
|
|
|
this.untrustedSpec = argValueToBoolean(raw.untrustedSpec);
|
2018-03-07 18:21:17 +03:00
|
|
|
this.hideDownloadButton = argValueToBoolean(raw.hideDownloadButton);
|
2022-05-10 20:09:01 +03:00
|
|
|
this.downloadFileName = raw.downloadFileName;
|
|
|
|
this.downloadDefinitionUrl = raw.downloadDefinitionUrl;
|
2018-07-17 11:07:34 +03:00
|
|
|
this.disableSearch = argValueToBoolean(raw.disableSearch);
|
2018-10-05 16:14:41 +03:00
|
|
|
this.onlyRequiredInSamples = argValueToBoolean(raw.onlyRequiredInSamples);
|
2018-10-03 10:02:30 +03:00
|
|
|
this.showExtensions = RedocNormalizedOptions.normalizeShowExtensions(raw.showExtensions);
|
2021-12-08 16:53:14 +03:00
|
|
|
this.sideNavStyle = RedocNormalizedOptions.normalizeSideNavStyle(raw.sideNavStyle);
|
2019-05-10 16:21:14 +03:00
|
|
|
this.hideSingleRequestSampleTab = argValueToBoolean(raw.hideSingleRequestSampleTab);
|
2019-12-12 14:16:42 +03:00
|
|
|
this.menuToggle = argValueToBoolean(raw.menuToggle, true);
|
2019-07-29 15:26:16 +03:00
|
|
|
this.jsonSampleExpandLevel = RedocNormalizedOptions.normalizeJsonSampleExpandLevel(
|
|
|
|
raw.jsonSampleExpandLevel,
|
|
|
|
);
|
2019-07-15 11:14:48 +03:00
|
|
|
this.enumSkipQuotes = argValueToBoolean(raw.enumSkipQuotes);
|
2019-12-12 17:59:04 +03:00
|
|
|
this.hideSchemaTitles = argValueToBoolean(raw.hideSchemaTitles);
|
2020-08-04 12:19:49 +03:00
|
|
|
this.simpleOneOfTypeLabel = argValueToBoolean(raw.simpleOneOfTypeLabel);
|
2019-12-12 20:08:05 +03:00
|
|
|
this.payloadSampleIdx = RedocNormalizedOptions.normalizePayloadSampleIdx(raw.payloadSampleIdx);
|
2020-03-13 19:23:24 +03:00
|
|
|
this.expandSingleSchemaField = argValueToBoolean(raw.expandSingleSchemaField);
|
2022-01-25 17:43:14 +03:00
|
|
|
this.schemaExpansionLevel = argValueToExpandLevel(raw.schemaExpansionLevel);
|
2021-12-29 13:22:57 +03:00
|
|
|
this.showObjectSchemaExamples = argValueToBoolean(raw.showObjectSchemaExamples);
|
2022-05-30 18:55:39 +03:00
|
|
|
this.showSecuritySchemeType = argValueToBoolean(raw.showSecuritySchemeType);
|
2022-05-31 13:20:23 +03:00
|
|
|
this.hideSecuritySection = argValueToBoolean(raw.hideSecuritySection);
|
2018-05-29 17:41:50 +03:00
|
|
|
|
|
|
|
this.unstable_ignoreMimeParameters = argValueToBoolean(raw.unstable_ignoreMimeParameters);
|
2018-08-17 14:41:22 +03:00
|
|
|
|
|
|
|
this.allowedMdComponents = raw.allowedMdComponents || {};
|
2019-09-30 10:39:19 +03:00
|
|
|
|
|
|
|
this.expandDefaultServerVariables = argValueToBoolean(raw.expandDefaultServerVariables);
|
2020-07-21 16:36:08 +03:00
|
|
|
this.maxDisplayedEnumValues = argValueToNumber(raw.maxDisplayedEnumValues);
|
2022-05-06 19:01:47 +03:00
|
|
|
const ignoreNamedSchemas = isArray(raw.ignoreNamedSchemas)
|
2020-11-30 12:54:46 +03:00
|
|
|
? raw.ignoreNamedSchemas
|
2021-11-24 17:47:24 +03:00
|
|
|
: raw.ignoreNamedSchemas?.split(',').map(s => s.trim());
|
2020-09-24 13:59:59 +03:00
|
|
|
this.ignoreNamedSchemas = new Set(ignoreNamedSchemas);
|
2020-11-30 12:54:46 +03:00
|
|
|
this.hideSchemaPattern = argValueToBoolean(raw.hideSchemaPattern);
|
2021-09-14 13:08:50 +03:00
|
|
|
this.generatedPayloadSamplesMaxDepth =
|
|
|
|
RedocNormalizedOptions.normalizeGeneratedPayloadSamplesMaxDepth(
|
|
|
|
raw.generatedPayloadSamplesMaxDepth,
|
|
|
|
);
|
2022-03-23 19:02:30 +03:00
|
|
|
this.nonce = raw.nonce;
|
2022-03-14 16:36:50 +03:00
|
|
|
this.hideFab = argValueToBoolean(raw.hideFab);
|
2022-05-03 10:48:08 +03:00
|
|
|
this.minCharacterLengthToInitSearch = argValueToNumber(raw.minCharacterLengthToInitSearch) || 3;
|
2022-05-11 19:13:50 +03:00
|
|
|
this.showWebhookVerb = argValueToBoolean(raw.showWebhookVerb);
|
2018-01-22 21:30:53 +03:00
|
|
|
}
|
2017-11-20 19:02:49 +03:00
|
|
|
}
|