@@ -6,36 +6,47 @@ import { setRedocLabels } from './Labels';
6
6
import { SideNavStyleEnum } from './types' ;
7
7
import type { LabelsConfigRaw , MDXComponentMeta } from './types' ;
8
8
9
+ export type DownloadUrlsConfig = {
10
+ title ?: string ;
11
+ url : string ;
12
+ } [ ] ;
13
+
9
14
export interface RedocRawOptions {
10
15
theme ?: ThemeInterface ;
11
16
scrollYOffset ?: number | string | ( ( ) => number ) ;
12
17
hideHostname ?: boolean | string ;
13
18
expandResponses ?: string | 'all' ;
14
- requiredPropsFirst ?: boolean | string ;
19
+ requiredPropsFirst ?: boolean | string ; // remove in next major release
20
+ sortRequiredPropsFirst ?: boolean | string ;
15
21
sortPropsAlphabetically ?: boolean | string ;
16
22
sortEnumValuesAlphabetically ?: boolean | string ;
17
23
sortOperationsAlphabetically ?: boolean | string ;
18
24
sortTagsAlphabetically ?: boolean | string ;
19
25
nativeScrollbars ?: boolean | string ;
20
26
pathInMiddlePanel ?: boolean | string ;
21
- untrustedSpec ?: boolean | string ;
27
+ untrustedSpec ?: boolean | string ; // remove in next major release
28
+ sanitize ?: boolean | string ;
22
29
hideLoading ?: boolean | string ;
23
- hideDownloadButton ?: boolean | string ;
30
+ hideDownloadButton ?: boolean | string ; // remove in next major release
31
+ hideDownloadButtons ?: boolean | string ;
24
32
downloadFileName ?: string ;
25
33
downloadDefinitionUrl ?: string ;
34
+ downloadUrls ?: DownloadUrlsConfig ;
26
35
disableSearch ?: boolean | string ;
27
36
onlyRequiredInSamples ?: boolean | string ;
28
37
showExtensions ?: boolean | string | string [ ] ;
29
38
sideNavStyle ?: SideNavStyleEnum ;
30
39
hideSingleRequestSampleTab ?: boolean | string ;
31
40
hideRequestPayloadSample ?: boolean ;
32
41
menuToggle ?: boolean | string ;
33
- jsonSampleExpandLevel ?: number | string | 'all' ;
42
+ jsonSampleExpandLevel ?: number | string | 'all' ; // remove in next major release
43
+ jsonSamplesExpandLevel ?: number | string | 'all' ;
34
44
hideSchemaTitles ?: boolean | string ;
35
45
simpleOneOfTypeLabel ?: boolean | string ;
36
46
payloadSampleIdx ?: number ;
37
47
expandSingleSchemaField ?: boolean | string ;
38
- schemaExpansionLevel ?: number | string | 'all' ;
48
+ schemaExpansionLevel ?: number | string | 'all' ; // remove in next major release
49
+ schemasExpansionLevel ?: number | string | 'all' ;
39
50
showObjectSchemaExamples ?: boolean | string ;
40
51
showSecuritySchemeType ?: boolean ;
41
52
hideSecuritySection ?: boolean ;
@@ -216,31 +227,30 @@ export class RedocNormalizedOptions {
216
227
scrollYOffset : ( ) => number ;
217
228
hideHostname : boolean ;
218
229
expandResponses : { [ code : string ] : boolean } | 'all' ;
219
- requiredPropsFirst : boolean ;
230
+ sortRequiredPropsFirst : boolean ;
220
231
sortPropsAlphabetically : boolean ;
221
232
sortEnumValuesAlphabetically : boolean ;
222
233
sortOperationsAlphabetically : boolean ;
223
234
sortTagsAlphabetically : boolean ;
224
235
nativeScrollbars : boolean ;
225
236
pathInMiddlePanel : boolean ;
226
- untrustedSpec : boolean ;
227
- hideDownloadButton : boolean ;
228
- downloadFileName ?: string ;
229
- downloadDefinitionUrl ?: string ;
237
+ sanitize : boolean ;
238
+ hideDownloadButtons : boolean ;
239
+ downloadUrls ?: DownloadUrlsConfig ;
230
240
disableSearch : boolean ;
231
241
onlyRequiredInSamples : boolean ;
232
242
showExtensions : boolean | string [ ] ;
233
243
sideNavStyle : SideNavStyleEnum ;
234
244
hideSingleRequestSampleTab : boolean ;
235
245
hideRequestPayloadSample : boolean ;
236
246
menuToggle : boolean ;
237
- jsonSampleExpandLevel : number ;
247
+ jsonSamplesExpandLevel : number ;
238
248
enumSkipQuotes : boolean ;
239
249
hideSchemaTitles : boolean ;
240
250
simpleOneOfTypeLabel : boolean ;
241
251
payloadSampleIdx : number ;
242
252
expandSingleSchemaField : boolean ;
243
- schemaExpansionLevel : number ;
253
+ schemasExpansionLevel : number ;
244
254
showObjectSchemaExamples : boolean ;
245
255
showSecuritySchemeType ?: boolean ;
246
256
hideSecuritySection ?: boolean ;
@@ -288,33 +298,38 @@ export class RedocNormalizedOptions {
288
298
this . scrollYOffset = RedocNormalizedOptions . normalizeScrollYOffset ( raw . scrollYOffset ) ;
289
299
this . hideHostname = RedocNormalizedOptions . normalizeHideHostname ( raw . hideHostname ) ;
290
300
this . expandResponses = RedocNormalizedOptions . normalizeExpandResponses ( raw . expandResponses ) ;
291
- this . requiredPropsFirst = argValueToBoolean ( raw . requiredPropsFirst ) ;
301
+ this . sortRequiredPropsFirst = argValueToBoolean (
302
+ raw . sortRequiredPropsFirst || raw . requiredPropsFirst ,
303
+ ) ;
292
304
this . sortPropsAlphabetically = argValueToBoolean ( raw . sortPropsAlphabetically ) ;
293
305
this . sortEnumValuesAlphabetically = argValueToBoolean ( raw . sortEnumValuesAlphabetically ) ;
294
306
this . sortOperationsAlphabetically = argValueToBoolean ( raw . sortOperationsAlphabetically ) ;
295
307
this . sortTagsAlphabetically = argValueToBoolean ( raw . sortTagsAlphabetically ) ;
296
308
this . nativeScrollbars = argValueToBoolean ( raw . nativeScrollbars ) ;
297
309
this . pathInMiddlePanel = argValueToBoolean ( raw . pathInMiddlePanel ) ;
298
- this . untrustedSpec = argValueToBoolean ( raw . untrustedSpec ) ;
299
- this . hideDownloadButton = argValueToBoolean ( raw . hideDownloadButton ) ;
300
- this . downloadFileName = raw . downloadFileName ;
301
- this . downloadDefinitionUrl = raw . downloadDefinitionUrl ;
310
+ this . sanitize = argValueToBoolean ( raw . sanitize || raw . untrustedSpec ) ;
311
+ this . hideDownloadButtons = argValueToBoolean ( raw . hideDownloadButtons || raw . hideDownloadButton ) ;
312
+ this . downloadUrls =
313
+ raw . downloadUrls ||
314
+ ( [ { title : raw . downloadFileName , url : raw . downloadDefinitionUrl } ] as DownloadUrlsConfig ) ;
302
315
this . disableSearch = argValueToBoolean ( raw . disableSearch ) ;
303
316
this . onlyRequiredInSamples = argValueToBoolean ( raw . onlyRequiredInSamples ) ;
304
317
this . showExtensions = RedocNormalizedOptions . normalizeShowExtensions ( raw . showExtensions ) ;
305
318
this . sideNavStyle = RedocNormalizedOptions . normalizeSideNavStyle ( raw . sideNavStyle ) ;
306
319
this . hideSingleRequestSampleTab = argValueToBoolean ( raw . hideSingleRequestSampleTab ) ;
307
320
this . hideRequestPayloadSample = argValueToBoolean ( raw . hideRequestPayloadSample ) ;
308
321
this . menuToggle = argValueToBoolean ( raw . menuToggle , true ) ;
309
- this . jsonSampleExpandLevel = RedocNormalizedOptions . normalizeJsonSampleExpandLevel (
310
- raw . jsonSampleExpandLevel ,
322
+ this . jsonSamplesExpandLevel = RedocNormalizedOptions . normalizeJsonSampleExpandLevel (
323
+ raw . jsonSamplesExpandLevel || raw . jsonSampleExpandLevel ,
311
324
) ;
312
325
this . enumSkipQuotes = argValueToBoolean ( raw . enumSkipQuotes ) ;
313
326
this . hideSchemaTitles = argValueToBoolean ( raw . hideSchemaTitles ) ;
314
327
this . simpleOneOfTypeLabel = argValueToBoolean ( raw . simpleOneOfTypeLabel ) ;
315
328
this . payloadSampleIdx = RedocNormalizedOptions . normalizePayloadSampleIdx ( raw . payloadSampleIdx ) ;
316
329
this . expandSingleSchemaField = argValueToBoolean ( raw . expandSingleSchemaField ) ;
317
- this . schemaExpansionLevel = argValueToExpandLevel ( raw . schemaExpansionLevel ) ;
330
+ this . schemasExpansionLevel = argValueToExpandLevel (
331
+ raw . schemasExpansionLevel || raw . schemaExpansionLevel ,
332
+ ) ;
318
333
this . showObjectSchemaExamples = argValueToBoolean ( raw . showObjectSchemaExamples ) ;
319
334
this . showSecuritySchemeType = argValueToBoolean ( raw . showSecuritySchemeType ) ;
320
335
this . hideSecuritySection = argValueToBoolean ( raw . hideSecuritySection ) ;
0 commit comments