Skip to content

Commit

Permalink
fix: add support generatedSamplesMaxDepth instead of generatedPayload…
Browse files Browse the repository at this point in the history
…SamplesMaxDepth
  • Loading branch information
AlexVarchuk committed Jan 17, 2025
1 parent bf97710 commit 349a194
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"expandDefaultServerVariables": false,
"expandResponses": {},
"expandSingleSchemaField": false,
"generatedPayloadSamplesMaxDepth": 10,
"generatedSamplesMaxDepth": 10,
"hideDownloadButtons": false,
"hideFab": false,
"hideHostname": false,
Expand All @@ -104,6 +104,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"pathInMiddlePanel": false,
"payloadSampleIdx": 0,
"sanitize": false,
"schemaDefinitionsTagName": undefined,
"schemasExpansionLevel": 0,
"scrollYOffset": [Function],
"showExtensions": false,
Expand Down Expand Up @@ -358,7 +359,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"expandDefaultServerVariables": false,
"expandResponses": {},
"expandSingleSchemaField": false,
"generatedPayloadSamplesMaxDepth": 10,
"generatedSamplesMaxDepth": 10,
"hideDownloadButtons": false,
"hideFab": false,
"hideHostname": false,
Expand All @@ -378,6 +379,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"pathInMiddlePanel": false,
"payloadSampleIdx": 0,
"sanitize": false,
"schemaDefinitionsTagName": undefined,
"schemasExpansionLevel": 0,
"scrollYOffset": [Function],
"showExtensions": false,
Expand Down Expand Up @@ -619,7 +621,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"expandDefaultServerVariables": false,
"expandResponses": {},
"expandSingleSchemaField": false,
"generatedPayloadSamplesMaxDepth": 10,
"generatedSamplesMaxDepth": 10,
"hideDownloadButtons": false,
"hideFab": false,
"hideHostname": false,
Expand All @@ -639,6 +641,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"pathInMiddlePanel": false,
"payloadSampleIdx": 0,
"sanitize": false,
"schemaDefinitionsTagName": undefined,
"schemasExpansionLevel": 0,
"scrollYOffset": [Function],
"showExtensions": false,
Expand Down Expand Up @@ -942,7 +945,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"expandDefaultServerVariables": false,
"expandResponses": {},
"expandSingleSchemaField": false,
"generatedPayloadSamplesMaxDepth": 10,
"generatedSamplesMaxDepth": 10,
"hideDownloadButtons": false,
"hideFab": false,
"hideHostname": false,
Expand All @@ -962,6 +965,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"pathInMiddlePanel": false,
"payloadSampleIdx": 0,
"sanitize": false,
"schemaDefinitionsTagName": undefined,
"schemasExpansionLevel": 0,
"scrollYOffset": [Function],
"showExtensions": false,
Expand Down Expand Up @@ -1228,7 +1232,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"expandDefaultServerVariables": false,
"expandResponses": {},
"expandSingleSchemaField": false,
"generatedPayloadSamplesMaxDepth": 10,
"generatedSamplesMaxDepth": 10,
"hideDownloadButtons": false,
"hideFab": false,
"hideHostname": false,
Expand All @@ -1248,6 +1252,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"pathInMiddlePanel": false,
"payloadSampleIdx": 0,
"sanitize": false,
"schemaDefinitionsTagName": undefined,
"schemasExpansionLevel": 0,
"scrollYOffset": [Function],
"showExtensions": false,
Expand Down Expand Up @@ -1485,7 +1490,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"expandDefaultServerVariables": false,
"expandResponses": {},
"expandSingleSchemaField": false,
"generatedPayloadSamplesMaxDepth": 10,
"generatedSamplesMaxDepth": 10,
"hideDownloadButtons": false,
"hideFab": false,
"hideHostname": false,
Expand All @@ -1505,6 +1510,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"pathInMiddlePanel": false,
"payloadSampleIdx": 0,
"sanitize": false,
"schemaDefinitionsTagName": undefined,
"schemasExpansionLevel": 0,
"scrollYOffset": [Function],
"showExtensions": false,
Expand Down Expand Up @@ -1767,7 +1773,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"expandDefaultServerVariables": false,
"expandResponses": {},
"expandSingleSchemaField": false,
"generatedPayloadSamplesMaxDepth": 10,
"generatedSamplesMaxDepth": 10,
"hideDownloadButtons": false,
"hideFab": false,
"hideHostname": false,
Expand All @@ -1787,6 +1793,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"pathInMiddlePanel": false,
"payloadSampleIdx": 0,
"sanitize": false,
"schemaDefinitionsTagName": undefined,
"schemasExpansionLevel": 0,
"scrollYOffset": [Function],
"showExtensions": false,
Expand Down Expand Up @@ -2079,7 +2086,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"expandDefaultServerVariables": false,
"expandResponses": {},
"expandSingleSchemaField": false,
"generatedPayloadSamplesMaxDepth": 10,
"generatedSamplesMaxDepth": 10,
"hideDownloadButtons": false,
"hideFab": false,
"hideHostname": false,
Expand All @@ -2099,6 +2106,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"pathInMiddlePanel": false,
"payloadSampleIdx": 0,
"sanitize": false,
"schemaDefinitionsTagName": undefined,
"schemasExpansionLevel": 0,
"scrollYOffset": [Function],
"showExtensions": false,
Expand Down Expand Up @@ -2353,7 +2361,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"expandDefaultServerVariables": false,
"expandResponses": {},
"expandSingleSchemaField": false,
"generatedPayloadSamplesMaxDepth": 10,
"generatedSamplesMaxDepth": 10,
"hideDownloadButtons": false,
"hideFab": false,
"hideHostname": false,
Expand All @@ -2373,6 +2381,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"pathInMiddlePanel": false,
"payloadSampleIdx": 0,
"sanitize": false,
"schemaDefinitionsTagName": undefined,
"schemasExpansionLevel": 0,
"scrollYOffset": [Function],
"showExtensions": false,
Expand Down Expand Up @@ -2614,7 +2623,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"expandDefaultServerVariables": false,
"expandResponses": {},
"expandSingleSchemaField": false,
"generatedPayloadSamplesMaxDepth": 10,
"generatedSamplesMaxDepth": 10,
"hideDownloadButtons": false,
"hideFab": false,
"hideHostname": false,
Expand All @@ -2634,6 +2643,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
"pathInMiddlePanel": false,
"payloadSampleIdx": 0,
"sanitize": false,
"schemaDefinitionsTagName": undefined,
"schemasExpansionLevel": 0,
"scrollYOffset": [Function],
"showExtensions": false,
Expand Down
12 changes: 6 additions & 6 deletions src/services/RedocNormalizedOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ export interface RedocRawOptions {
maxDisplayedEnumValues?: number;
ignoreNamedSchemas?: string[] | string;
hideSchemaPattern?: boolean;
generatedPayloadSamplesMaxDepth?: number;
generatedPayloadSamplesMaxDepth?: number; // remove in next major release
generatedSamplesMaxDepth?: number;
nonce?: string;
hideFab?: boolean;
minCharacterLengthToInitSearch?: number;
Expand Down Expand Up @@ -268,7 +269,7 @@ export class RedocNormalizedOptions {

ignoreNamedSchemas: Set<string>;
hideSchemaPattern: boolean;
generatedPayloadSamplesMaxDepth: number;
generatedSamplesMaxDepth: number;
hideFab: boolean;
minCharacterLengthToInitSearch: number;
showWebhookVerb: boolean;
Expand Down Expand Up @@ -350,10 +351,9 @@ export class RedocNormalizedOptions {
: raw.ignoreNamedSchemas?.split(',').map(s => s.trim());
this.ignoreNamedSchemas = new Set(ignoreNamedSchemas);
this.hideSchemaPattern = argValueToBoolean(raw.hideSchemaPattern);
this.generatedPayloadSamplesMaxDepth =
RedocNormalizedOptions.normalizeGeneratedPayloadSamplesMaxDepth(
raw.generatedPayloadSamplesMaxDepth,
);
this.generatedSamplesMaxDepth = RedocNormalizedOptions.normalizeGeneratedPayloadSamplesMaxDepth(
raw.generatedSamplesMaxDepth || raw.generatedPayloadSamplesMaxDepth,
);
this.nonce = raw.nonce;
this.hideFab = argValueToBoolean(raw.hideFab);
this.minCharacterLengthToInitSearch = argValueToNumber(raw.minCharacterLengthToInitSearch) || 3;
Expand Down
6 changes: 3 additions & 3 deletions src/services/models/MediaType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class MediaTypeModel {
name: string;
isRequestType: boolean;
onlyRequiredInSamples: boolean;
generatedPayloadSamplesMaxDepth: number;
generatedSamplesMaxDepth: number;

/**
* @param isRequestType needed to know if skipe RO/RW fields in objects
Expand All @@ -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.generatedPayloadSamplesMaxDepth = options.generatedPayloadSamplesMaxDepth;
this.generatedSamplesMaxDepth = options.generatedSamplesMaxDepth;
if (info.examples !== undefined) {
this.examples = mapValues(
info.examples,
Expand All @@ -55,7 +55,7 @@ export class MediaTypeModel {
skipReadOnly: this.isRequestType,
skipWriteOnly: !this.isRequestType,
skipNonRequired: this.isRequestType && this.onlyRequiredInSamples,
maxSampleDepth: this.generatedPayloadSamplesMaxDepth,
maxSampleDepth: this.generatedSamplesMaxDepth,
};
if (this.schema && this.schema.oneOf) {
this.examples = {};
Expand Down

0 comments on commit 349a194

Please sign in to comment.