From a41375495e1e40b7cbcafab33d841369fdbdba26 Mon Sep 17 00:00:00 2001 From: Mark Theisen Date: Fri, 30 Jul 2021 08:28:08 -0500 Subject: [PATCH] Rename parameter to generatedPayloadSamplesMaxDepth --- README.md | 2 +- src/services/RedocNormalizedOptions.ts | 13 +++++++++---- src/services/models/MediaType.ts | 6 +++--- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index b0a11721..13287f89 100644 --- a/README.md +++ b/README.md @@ -230,6 +230,7 @@ You can use all of the following options with standalone version on tag * `disableSearch` - disable search indexing and search box. * `expandDefaultServerVariables` - enable expanding default server variables, default `false`. * `expandResponses` - specify which responses to expand by default by response codes. Values should be passed as comma-separated list without spaces e.g. `expandResponses="200,201"`. Special value `"all"` expands all responses by default. Be careful: this option can slow-down documentation rendering time. +* `generatedPayloadSamplesMaxDepth` - set the maximum render depth for JSON payload samples (responses and request body). The default value is `10`. * `maxDisplayedEnumValues` - display only specified number of enum values. hide rest values under spoiler. * `hideDownloadButton` - do not show "Download" spec button. **THIS DOESN'T MAKE YOUR SPEC PRIVATE**, it just hides the button. * `hideHostname` - if set, the protocol and hostname is not shown in the operation definition. @@ -241,7 +242,6 @@ You can use all of the following options with standalone version on tag * `hideSchemaTitles` - do not display schema `title` next to to the type * `simpleOneOfTypeLabel` - show only unique oneOf types in the label without titles * `lazyRendering` - _Not implemented yet_ ~~if set, enables lazy rendering mode in ReDoc. This mode is useful for APIs with big number of operations (e.g. > 50). In this mode ReDoc shows initial screen ASAP and then renders the rest operations asynchronously while showing progress bar on the top. Check out the [demo](\\redocly.github.io/redoc) for the example.~~ -* `maxSampleDepth` - set the maximum render depth for JSON payload samples (responses and request body). The default value is `10`. * `menuToggle` - if true clicking second time on expanded menu item will collapse it, default `true`. * `nativeScrollbars` - use native scrollbar for sidemenu instead of perfect-scroll (scrolling performance optimization for big specs). * `noAutoAuth` - do not inject Authentication section automatically. diff --git a/src/services/RedocNormalizedOptions.ts b/src/services/RedocNormalizedOptions.ts index 7e6498d1..1cd3d38d 100644 --- a/src/services/RedocNormalizedOptions.ts +++ b/src/services/RedocNormalizedOptions.ts @@ -42,7 +42,7 @@ export interface RedocRawOptions { maxDisplayedEnumValues?: number; ignoreNamedSchemas?: string[] | string; hideSchemaPattern?: boolean; - maxSampleDepth?: number; + generatedPayloadSamplesMaxDepth?: number; } function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean { @@ -164,7 +164,9 @@ export class RedocNormalizedOptions { return 2; } - private static normalizeMaxSampleDepth(value?: number | string | undefined): number { + private static normalizeGeneratedPayloadSamplesMaxDepth( + value?: number | string | undefined, + ): number { if (!isNaN(Number(value))) { return Math.max(0, Number(value)); } @@ -205,7 +207,7 @@ export class RedocNormalizedOptions { ignoreNamedSchemas: Set; hideSchemaPattern: boolean; - maxSampleDepth: number; + generatedPayloadSamplesMaxDepth: number; constructor(raw: RedocRawOptions, defaults: RedocRawOptions = {}) { raw = { ...defaults, ...raw }; @@ -267,6 +269,9 @@ export class RedocNormalizedOptions { : raw.ignoreNamedSchemas?.split(',').map((s) => s.trim()); this.ignoreNamedSchemas = new Set(ignoreNamedSchemas); this.hideSchemaPattern = argValueToBoolean(raw.hideSchemaPattern); - this.maxSampleDepth = RedocNormalizedOptions.normalizeMaxSampleDepth(raw.maxSampleDepth); + this.generatedPayloadSamplesMaxDepth = + RedocNormalizedOptions.normalizeGeneratedPayloadSamplesMaxDepth( + raw.generatedPayloadSamplesMaxDepth, + ); } } diff --git a/src/services/models/MediaType.ts b/src/services/models/MediaType.ts index d780ada9..d84159c2 100644 --- a/src/services/models/MediaType.ts +++ b/src/services/models/MediaType.ts @@ -14,7 +14,7 @@ export class MediaTypeModel { name: string; isRequestType: boolean; onlyRequiredInSamples: boolean; - maxSampleDepth: number; + generatedPayloadSamplesMaxDepth: number; /** * @param isRequestType needed to know if skipe RO/RW fields in objects @@ -30,7 +30,7 @@ export class MediaTypeModel { this.isRequestType = isRequestType; this.schema = info.schema && new SchemaModel(parser, info.schema, '', options); this.onlyRequiredInSamples = options.onlyRequiredInSamples; - this.maxSampleDepth = options.maxSampleDepth; + this.generatedPayloadSamplesMaxDepth = options.generatedPayloadSamplesMaxDepth; if (info.examples !== undefined) { this.examples = mapValues( info.examples, @@ -55,7 +55,7 @@ export class MediaTypeModel { skipReadOnly: this.isRequestType, skipNonRequired: this.isRequestType && this.onlyRequiredInSamples, skipWriteOnly: !this.isRequestType, - maxSampleDepth: this.maxSampleDepth, + maxSampleDepth: this.generatedPayloadSamplesMaxDepth, }; if (this.schema && this.schema.oneOf) { this.examples = {};