rapidoc 9.2.0 → 9.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/FUNDING.yml +13 -0
- package/CONTRIBUTING.md +1 -1
- package/README.md +13 -6
- package/dist/index.html +1 -1
- package/dist/index.html.gz +0 -0
- package/dist/rapidoc-min.js +472 -353
- package/dist/rapidoc-min.js.LICENSE.txt +9 -11
- package/dist/rapidoc-min.js.LICENSE.txt.gz +0 -0
- package/dist/rapidoc-min.js.gz +0 -0
- package/dist/rapidoc-min.js.map +1 -1
- package/dist/rapidoc-min.js.map.gz +0 -0
- package/dist/rapidoc.js +1839 -3420
- package/dist/report.html +2 -2
- package/index.html +6 -5
- package/package.json +22 -20
- package/src/components/api-request.js +184 -85
- package/src/components/api-response.js +8 -4
- package/src/components/json-tree.js +13 -2
- package/src/components/schema-table.js +40 -18
- package/src/components/schema-tree.js +41 -12
- package/src/json-schema-viewer.js +1 -2
- package/src/rapidoc-mini.js +23 -0
- package/src/rapidoc.js +54 -17
- package/src/styles/endpoint-styles.js +9 -9
- package/src/styles/font-styles.js +1 -1
- package/src/styles/nav-styles.js +3 -1
- package/src/styles/schema-styles.js +3 -1
- package/src/styles/tab-styles.js +1 -0
- package/src/templates/callback-template.js +8 -4
- package/src/templates/components-template.js +2 -0
- package/src/templates/endpoint-template.js +20 -15
- package/src/templates/expanded-endpoint-template.js +76 -71
- package/src/templates/header-template.js +1 -1
- package/src/templates/json-schema-viewer-template.js +1 -1
- package/src/templates/main-body-template.js +1 -1
- package/src/templates/navbar-template.js +21 -8
- package/src/templates/overview-template.js +1 -1
- package/src/templates/security-scheme-template.js +30 -20
- package/src/templates/server-template.js +2 -2
- package/src/utils/common-utils.js +1 -4
- package/src/utils/schema-utils.js +96 -57
- package/src/utils/spec-parser.js +1 -1
- package/src/utils/theme.js +13 -6
- package/webpack.config.js +1 -1
- package/.vscode/settings.json +0 -12
|
@@ -12,7 +12,7 @@ export function getTypeInfo(schema) {
|
|
|
12
12
|
const schemaNode = schema.$ref.substring(n + 1);
|
|
13
13
|
dataType = `{recursive: ${schemaNode}} `;
|
|
14
14
|
} else if (schema.type) {
|
|
15
|
-
dataType = Array.isArray(schema.type) ? schema.type.join('┃') : schema.type;
|
|
15
|
+
dataType = Array.isArray(schema.type) ? schema.type.join(schema.length === 2 ? ' or ' : '┃') : schema.type;
|
|
16
16
|
if (schema.format || schema.enum) {
|
|
17
17
|
dataType = dataType.replace('string', schema.enum ? 'enum' : schema.format);
|
|
18
18
|
}
|
|
@@ -81,48 +81,69 @@ export function getTypeInfo(schema) {
|
|
|
81
81
|
return info;
|
|
82
82
|
}
|
|
83
83
|
export function nestExampleIfPresent(example) {
|
|
84
|
+
if (typeof example === 'boolean') {
|
|
85
|
+
return {
|
|
86
|
+
Example: { value: `${example}` },
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
if (example === '') {
|
|
90
|
+
return {
|
|
91
|
+
Example: { value: '' },
|
|
92
|
+
};
|
|
93
|
+
}
|
|
84
94
|
return example ? { Example: { value: example } } : example;
|
|
85
95
|
}
|
|
96
|
+
|
|
86
97
|
export function normalizeExamples(examples, dataType = 'string') {
|
|
87
|
-
|
|
88
|
-
let exampleList;
|
|
89
|
-
if (examples) {
|
|
90
|
-
if (examples.constructor === Object) {
|
|
91
|
-
const exampleValAndDescr = Object.values(examples);
|
|
92
|
-
exampleVal = exampleValAndDescr.length > 0
|
|
93
|
-
? typeof exampleValAndDescr[0].value === 'boolean' || typeof exampleValAndDescr[0].value === 'number'
|
|
94
|
-
? exampleValAndDescr[0].value.toString()
|
|
95
|
-
: exampleValAndDescr[0].value
|
|
96
|
-
: '';
|
|
97
|
-
exampleList = Object.values(examples).map((v) => ({
|
|
98
|
-
value: typeof v.value === 'boolean' || typeof v.value === 'number' ? v.value.toString() : v.value,
|
|
99
|
-
description: v.description || v.summary || v.value,
|
|
100
|
-
}));
|
|
101
|
-
} else {
|
|
102
|
-
// This is non standard way to provide example but will support for now
|
|
103
|
-
if (!Array.isArray(examples)) {
|
|
104
|
-
examples = examples ? [examples] : [];
|
|
105
|
-
}
|
|
106
|
-
if (examples.length > 0) {
|
|
107
|
-
if (dataType === 'array') {
|
|
108
|
-
[exampleVal] = examples;
|
|
109
|
-
exampleList = examples.map((v) => ({ value: v, description: Array.isArray(v) ? v.join(' , ') : v }));
|
|
110
|
-
} else {
|
|
111
|
-
exampleVal = examples[0].toString();
|
|
112
|
-
exampleList = examples.map((v) => ({ value: v.toString(), description: v }));
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
98
|
+
if (!examples) {
|
|
116
99
|
return {
|
|
117
|
-
exampleVal,
|
|
118
|
-
exampleList,
|
|
100
|
+
exampleVal: '',
|
|
101
|
+
exampleList: [],
|
|
119
102
|
};
|
|
120
103
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
104
|
+
|
|
105
|
+
if (examples.constructor === Object) {
|
|
106
|
+
const exampleValAndDescr = Object.values(examples);
|
|
107
|
+
const exampleVal = exampleValAndDescr.length > 0
|
|
108
|
+
? typeof exampleValAndDescr[0].value === 'boolean' || typeof exampleValAndDescr[0].value === 'number'
|
|
109
|
+
? exampleValAndDescr[0].value.toString()
|
|
110
|
+
: exampleValAndDescr[0].value
|
|
111
|
+
: '';
|
|
112
|
+
const exampleList = Object.values(examples).map((v) => ({
|
|
113
|
+
value: typeof v.value === 'boolean' || typeof v.value === 'number' ? v.value.toString() : v.value,
|
|
114
|
+
summary: v.summary,
|
|
115
|
+
description: v.description,
|
|
116
|
+
}));
|
|
117
|
+
return { exampleVal, exampleList };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// This is non-standard way to provide example but will support for now
|
|
121
|
+
if (!Array.isArray(examples)) {
|
|
122
|
+
examples = examples ? [examples] : [];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (examples.length === 0) {
|
|
126
|
+
return {
|
|
127
|
+
exampleVal: '',
|
|
128
|
+
exampleList: [],
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (dataType === 'array') {
|
|
133
|
+
const [exampleVal] = examples;
|
|
134
|
+
const exampleList = examples.map((v) => ({ value: v }));
|
|
135
|
+
return { exampleVal, exampleList };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
const exampleVal = examples[0].toString();
|
|
139
|
+
const exampleList = examples.map((v) => ({ value: v.toString() }));
|
|
140
|
+
return { exampleVal, exampleList };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function anyExampleWithSummaryOrDescription(examples) {
|
|
144
|
+
return examples.some((x) => x.summary?.length > 0 || x.description?.length > 0);
|
|
125
145
|
}
|
|
146
|
+
|
|
126
147
|
export function getSampleValueByType(schemaObj) {
|
|
127
148
|
const example = schemaObj.examples
|
|
128
149
|
? schemaObj.examples[0]
|
|
@@ -389,12 +410,20 @@ export function schemaToSampleObj(schema, config = { }) {
|
|
|
389
410
|
const oneOfSamples = schemaToSampleObj(schema.oneOf[key], config);
|
|
390
411
|
for (const sampleKey in oneOfSamples) {
|
|
391
412
|
// 2. In the final example include a one-of item along with properties
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
413
|
+
let finalExample;
|
|
414
|
+
if (Object.keys(objWithSchemaProps).length > 0) {
|
|
415
|
+
if (oneOfSamples[sampleKey] === null || typeof oneOfSamples[sampleKey] !== 'object') {
|
|
416
|
+
// This doesn't really make sense since every oneOf schema _should_ be an object if there are common properties, so we'll skip this
|
|
417
|
+
continue;
|
|
418
|
+
} else {
|
|
419
|
+
finalExample = Object.assign(oneOfSamples[sampleKey], objWithSchemaProps);
|
|
420
|
+
}
|
|
421
|
+
} else {
|
|
422
|
+
finalExample = oneOfSamples[sampleKey];
|
|
397
423
|
}
|
|
424
|
+
obj[`example-${i}`] = finalExample;
|
|
425
|
+
addSchemaInfoToExample(schema.oneOf[key], obj[`example-${i}`]);
|
|
426
|
+
i++;
|
|
398
427
|
}
|
|
399
428
|
}
|
|
400
429
|
}
|
|
@@ -460,18 +489,22 @@ export function schemaToSampleObj(schema, config = { }) {
|
|
|
460
489
|
}
|
|
461
490
|
}
|
|
462
491
|
} else if (schema.type === 'array' || schema.items) {
|
|
463
|
-
if (schema.example) {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
492
|
+
if (schema.items || schema.example) {
|
|
493
|
+
if (schema.example) {
|
|
494
|
+
obj['example-0'] = schema.example;
|
|
495
|
+
} else if (schema.items?.example) { // schemas and properties support single example but not multiple examples.
|
|
496
|
+
obj['example-0'] = [schema.items.example];
|
|
497
|
+
} else {
|
|
498
|
+
const samples = schemaToSampleObj(schema.items, config);
|
|
499
|
+
let i = 0;
|
|
500
|
+
for (const key in samples) {
|
|
501
|
+
obj[`example-${i}`] = [samples[key]];
|
|
502
|
+
addSchemaInfoToExample(schema.items, obj[`example-${i}`]);
|
|
503
|
+
i++;
|
|
504
|
+
}
|
|
474
505
|
}
|
|
506
|
+
} else {
|
|
507
|
+
obj['example-0'] = [];
|
|
475
508
|
}
|
|
476
509
|
} else {
|
|
477
510
|
return { 'example-0': getSampleValueByType(schema) };
|
|
@@ -484,15 +517,15 @@ function generateMarkdownForArrayAndObjectDescription(schema, level = 0) {
|
|
|
484
517
|
if (schema.title) {
|
|
485
518
|
markdown = `**${schema.title}:** `;
|
|
486
519
|
}
|
|
520
|
+
if (schema.description) {
|
|
521
|
+
markdown = `${markdown} ${schema.description} ${schema.minItems || schema.maxItems ? '<span class="more-content">⤵</span><br/>' : ''}`;
|
|
522
|
+
}
|
|
487
523
|
if (schema.minItems) {
|
|
488
524
|
markdown = `${markdown} **Min Items:** ${schema.minItems}`;
|
|
489
525
|
}
|
|
490
526
|
if (schema.maxItems) {
|
|
491
527
|
markdown = `${markdown} **Max Items:** ${schema.maxItems}`;
|
|
492
528
|
}
|
|
493
|
-
if (schema.description) {
|
|
494
|
-
markdown = `${markdown} ${schema.description}`;
|
|
495
|
-
}
|
|
496
529
|
if (level > 0 && schema.items?.description) {
|
|
497
530
|
let itemsMarkdown = '';
|
|
498
531
|
if (schema.items.minProperties) {
|
|
@@ -600,7 +633,7 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
600
633
|
});
|
|
601
634
|
let multiPrimitiveTypes;
|
|
602
635
|
if (primitiveType.length > 0) {
|
|
603
|
-
subSchema.type = primitiveType.join('┃');
|
|
636
|
+
subSchema.type = primitiveType.join(primitiveType.length === 2 ? ' or ' : '┃');
|
|
604
637
|
multiPrimitiveTypes = getTypeInfo(subSchema);
|
|
605
638
|
if (complexTypes.length === 0) {
|
|
606
639
|
return `${multiPrimitiveTypes?.html || ''}`;
|
|
@@ -652,6 +685,9 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
652
685
|
obj['::title'] = schema.title || '';
|
|
653
686
|
obj['::description'] = generateMarkdownForArrayAndObjectDescription(schema, level);
|
|
654
687
|
obj['::type'] = 'object';
|
|
688
|
+
if ((Array.isArray(schema.type) && schema.type.includes('null')) || schema.nullable) {
|
|
689
|
+
obj['::dataTypeLabel'] = 'object or null';
|
|
690
|
+
}
|
|
655
691
|
obj['::deprecated'] = schema.deprecated || false;
|
|
656
692
|
obj['::readwrite'] = schema.readOnly ? 'readonly' : schema.writeOnly ? 'writeonly' : '';
|
|
657
693
|
for (const key in schema.properties) {
|
|
@@ -668,9 +704,12 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
668
704
|
obj['::title'] = schema.title || '';
|
|
669
705
|
obj['::description'] = generateMarkdownForArrayAndObjectDescription(schema, level);
|
|
670
706
|
obj['::type'] = 'array';
|
|
707
|
+
if ((Array.isArray(schema.type) && schema.type.includes('null')) || schema.nullable) {
|
|
708
|
+
obj['::dataTypeLabel'] = 'array or null';
|
|
709
|
+
}
|
|
671
710
|
obj['::deprecated'] = schema.deprecated || false;
|
|
672
711
|
obj['::readwrite'] = schema.readOnly ? 'readonly' : schema.writeOnly ? 'writeonly' : '';
|
|
673
|
-
if (schema.items
|
|
712
|
+
if (schema.items?.items) {
|
|
674
713
|
obj['::array-type'] = schema.items.items.type;
|
|
675
714
|
}
|
|
676
715
|
obj['::props'] = schemaInObjectNotation(schema.items, {}, (level + 1));
|
package/src/utils/spec-parser.js
CHANGED
|
@@ -106,7 +106,7 @@ export default async function ProcessSpec(specUrl, generateMissingTags = false,
|
|
|
106
106
|
} else if (v.type === 'oauth2') {
|
|
107
107
|
v.typeDisplay = `OAuth (${v.securitySchemeId})`;
|
|
108
108
|
} else {
|
|
109
|
-
v.typeDisplay = v.type;
|
|
109
|
+
v.typeDisplay = v.type || 'None';
|
|
110
110
|
}
|
|
111
111
|
});
|
|
112
112
|
|
package/src/utils/theme.js
CHANGED
|
@@ -11,7 +11,7 @@ export default function setTheme(baseTheme, theme = {}) {
|
|
|
11
11
|
|
|
12
12
|
// Dark and Light Theme colors
|
|
13
13
|
if (baseTheme === 'dark') {
|
|
14
|
-
const bg1 = theme.bg1 ? theme.bg1 : '#
|
|
14
|
+
const bg1 = theme.bg1 ? theme.bg1 : '#2a2b2c';
|
|
15
15
|
const fg1 = theme.fg1 ? theme.fg1 : '#bbb';
|
|
16
16
|
|
|
17
17
|
const bg2 = theme.bg2 ? theme.bg2 : ColorUtils.color.brightness(bg1, 5); // or #383838;
|
|
@@ -27,7 +27,7 @@ export default function setTheme(baseTheme, theme = {}) {
|
|
|
27
27
|
const headerColor = theme.headerColor ? theme.headerColor : ColorUtils.color.brightness(bg1, 10);
|
|
28
28
|
|
|
29
29
|
const navBgColor = theme.navBgColor ? theme.navBgColor : ColorUtils.color.brightness(bg1, 10);
|
|
30
|
-
const navTextColor = theme.navTextColor ? theme.navTextColor : ColorUtils.color.opacity(ColorUtils.color.invert(navBgColor), '0.
|
|
30
|
+
const navTextColor = theme.navTextColor ? theme.navTextColor : ColorUtils.color.opacity(ColorUtils.color.invert(navBgColor), '0.50');
|
|
31
31
|
const navHoverBgColor = theme.navHoverBgColor ? theme.navHoverBgColor : ColorUtils.color.brightness(navBgColor, -15);
|
|
32
32
|
const navHoverTextColor = theme.navHoverTextColor ? theme.navHoverTextColor : ColorUtils.color.invert(navBgColor);
|
|
33
33
|
const navAccentColor = theme.navAccentColor ? theme.navAccentColor : ColorUtils.color.brightness(primaryColor, 25);
|
|
@@ -96,7 +96,7 @@ export default function setTheme(baseTheme, theme = {}) {
|
|
|
96
96
|
codeOperatorColor: theme.codeOperatorColor || '#67cdcc',
|
|
97
97
|
};
|
|
98
98
|
} else {
|
|
99
|
-
const bg1 = (theme.bg1 ? theme.bg1 : '#
|
|
99
|
+
const bg1 = (theme.bg1 ? theme.bg1 : '#fafbfc');
|
|
100
100
|
const fg1 = (theme.fg1 ? theme.fg1 : '#444444');
|
|
101
101
|
const bg2 = theme.bg2 ? theme.bg2 : ColorUtils.color.brightness(bg1, -5); // or '#fafafa'
|
|
102
102
|
const bg3 = theme.bg3 ? theme.bg3 : ColorUtils.color.brightness(bg1, -15); // or '#f6f6f6'
|
|
@@ -118,7 +118,7 @@ export default function setTheme(baseTheme, theme = {}) {
|
|
|
118
118
|
const navHoverTextColor = theme.navHoverTextColor ? theme.navHoverTextColor : primaryColor;
|
|
119
119
|
const navAccentColor = theme.navAccentColor ? theme.navAccentColor : primaryColor;
|
|
120
120
|
*/
|
|
121
|
-
const navBgColor = theme.navBgColor ? theme.navBgColor : ColorUtils.color.brightness(bg1, -
|
|
121
|
+
const navBgColor = theme.navBgColor ? theme.navBgColor : ColorUtils.color.brightness(bg1, -200);
|
|
122
122
|
const navTextColor = theme.navTextColor ? theme.navTextColor : ColorUtils.color.opacity(ColorUtils.color.invert(navBgColor), '0.65');
|
|
123
123
|
const navHoverBgColor = theme.navHoverBgColor ? theme.navHoverBgColor : ColorUtils.color.brightness(navBgColor, -15);
|
|
124
124
|
const navHoverTextColor = theme.navHoverTextColor ? theme.navHoverTextColor : ColorUtils.color.invert(navBgColor);
|
|
@@ -206,8 +206,8 @@ export default function setTheme(baseTheme, theme = {}) {
|
|
|
206
206
|
: '7px 16px 7px 10px')};
|
|
207
207
|
|
|
208
208
|
--resp-area-height: ${this.responseAreaHeight};
|
|
209
|
-
--font-size-small:
|
|
210
|
-
--font-size-mono:
|
|
209
|
+
--font-size-small: ${this.fontSize === 'default' ? '12px' : (this.fontSize === 'large' ? '13px' : '14px')};
|
|
210
|
+
--font-size-mono: ${this.fontSize === 'default' ? '13px' : (this.fontSize === 'large' ? '14px' : '15px')};
|
|
211
211
|
--font-size-regular: ${this.fontSize === 'default' ? '14px' : (this.fontSize === 'large' ? '15px' : '16px')};
|
|
212
212
|
--dialog-z-index: 1000;
|
|
213
213
|
|
|
@@ -260,6 +260,13 @@ export default function setTheme(baseTheme, theme = {}) {
|
|
|
260
260
|
--nav-hover-text-color:${newTheme.navHoverTextColor};
|
|
261
261
|
--nav-accent-color:${newTheme.navAccentColor};
|
|
262
262
|
|
|
263
|
+
/* Nav API Method Colors*/
|
|
264
|
+
--nav-get-color:${newTheme.blue};
|
|
265
|
+
--nav-put-color:${newTheme.orange};
|
|
266
|
+
--nav-post-color:${newTheme.green};
|
|
267
|
+
--nav-delete-color:${newTheme.red};
|
|
268
|
+
--nav-head-color:${newTheme.yellow};
|
|
269
|
+
|
|
263
270
|
/* Primary Colors */
|
|
264
271
|
--primary-color:${newTheme.primaryColor};
|
|
265
272
|
--primary-color-invert:${newTheme.primaryColorInvert};
|
package/webpack.config.js
CHANGED
|
@@ -29,7 +29,7 @@ const rapidocBanner = `
|
|
|
29
29
|
* @preserve
|
|
30
30
|
* RapiDoc ${rapidocVersion.replace()} - WebComponent to View OpenAPI docs
|
|
31
31
|
* License: MIT
|
|
32
|
-
* Repo : https://github.com/
|
|
32
|
+
* Repo : https://github.com/rapi-doc/RapiDoc
|
|
33
33
|
* Author : Mrinmoy Majumdar
|
|
34
34
|
*`;
|
|
35
35
|
|