rapidoc 9.3.3 → 9.3.4
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/workflow/words.yaml +22 -0
- package/dist/rapidoc-min.js +815 -709
- package/dist/rapidoc-min.js.LICENSE.txt +8 -7
- 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 +17680 -31489
- package/dist/report.html +5 -4
- package/package.json +18 -18
- package/src/components/api-request.js +218 -112
- package/src/components/api-response.js +11 -10
- package/src/components/json-tree.js +17 -12
- package/src/components/schema-table.js +47 -39
- package/src/components/schema-tree.js +55 -52
- package/src/components/tag-input.js +7 -4
- package/src/json-schema-viewer.js +1 -1
- package/src/rapidoc-mini.js +1 -1
- package/src/rapidoc.js +98 -30
- package/src/styles/endpoint-styles.js +1 -1
- package/src/styles/info-styles.js +2 -1
- package/src/styles/input-styles.js +2 -16
- package/src/styles/nav-styles.js +57 -10
- package/src/styles/schema-styles.js +27 -15
- package/src/styles/tab-styles.js +1 -0
- package/src/templates/callback-template.js +3 -3
- package/src/templates/code-samples-template.js +1 -0
- package/src/templates/components-template.js +3 -5
- package/src/templates/endpoint-template.js +38 -25
- package/src/templates/expanded-endpoint-template.js +57 -8
- package/src/templates/focused-endpoint-template.js +4 -1
- package/src/templates/header-template.js +2 -2
- package/src/templates/json-schema-viewer-template.js +2 -1
- package/src/templates/main-body-template.js +19 -18
- package/src/templates/navbar-template.js +98 -81
- package/src/templates/overview-template.js +1 -1
- package/src/templates/security-scheme-template.js +48 -25
- package/src/templates/server-template.js +1 -1
- package/src/utils/common-utils.js +1 -1
- package/src/utils/schema-utils.js +161 -63
- package/src/utils/spec-parser.js +1 -0
- package/src/utils/theme.js +9 -3
- package/webpack.config.js +2 -1
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
// Takes a value as input and provides a printable string to replresent null values, spaces, blankstring etc
|
|
2
|
+
export function getPrintableVal(val) {
|
|
3
|
+
if (val === undefined) {
|
|
4
|
+
return '';
|
|
5
|
+
}
|
|
6
|
+
if (val === null) {
|
|
7
|
+
return 'null';
|
|
8
|
+
}
|
|
9
|
+
if (val === '') {
|
|
10
|
+
return '∅';
|
|
11
|
+
}
|
|
12
|
+
if (typeof val === 'boolean' || typeof val === 'number') {
|
|
13
|
+
return `${val}`;
|
|
14
|
+
}
|
|
15
|
+
if (Array.isArray(val)) {
|
|
16
|
+
return val.map((v) => (v === null ? 'null' : v === '' ? '∅' : v.toString().replace(/^ +| +$/g, (m) => '●'.repeat(m.length)) || '')).join(', ');
|
|
17
|
+
}
|
|
18
|
+
return val.toString().replace(/^ +| +$/g, (m) => '●'.repeat(m.length)) || '';
|
|
19
|
+
}
|
|
20
|
+
|
|
1
21
|
/* Generates an schema object containing type and constraint info */
|
|
2
22
|
export function getTypeInfo(schema) {
|
|
3
23
|
if (!schema) {
|
|
@@ -13,12 +33,14 @@ export function getTypeInfo(schema) {
|
|
|
13
33
|
dataType = `{recursive: ${schemaNode}} `;
|
|
14
34
|
} else if (schema.type) {
|
|
15
35
|
dataType = Array.isArray(schema.type) ? schema.type.join(schema.length === 2 ? ' or ' : '┃') : schema.type;
|
|
16
|
-
if (schema.format || schema.enum) {
|
|
17
|
-
dataType = dataType.replace('string', schema.enum ? 'enum' : schema.format);
|
|
36
|
+
if (schema.format || schema.enum || schema.const) {
|
|
37
|
+
dataType = dataType.replace('string', schema.enum ? 'enum' : schema.const ? 'const' : schema.format);
|
|
18
38
|
}
|
|
19
39
|
if (schema.nullable) {
|
|
20
40
|
dataType += '┃null';
|
|
21
41
|
}
|
|
42
|
+
} else if (schema.const) {
|
|
43
|
+
dataType = 'const';
|
|
22
44
|
} else if (Object.keys(schema).length === 0) {
|
|
23
45
|
dataType = 'any';
|
|
24
46
|
} else {
|
|
@@ -32,7 +54,7 @@ export function getTypeInfo(schema) {
|
|
|
32
54
|
readOrWriteOnly: (schema.readOnly ? '🆁' : schema.writeOnly ? '🆆' : ''),
|
|
33
55
|
deprecated: schema.deprecated ? '❌' : '',
|
|
34
56
|
examples: schema.examples || schema.example,
|
|
35
|
-
default: schema.default
|
|
57
|
+
default: getPrintableVal(schema.default),
|
|
36
58
|
description: schema.description || '',
|
|
37
59
|
constrain: '',
|
|
38
60
|
allowedValues: '',
|
|
@@ -45,16 +67,24 @@ export function getTypeInfo(schema) {
|
|
|
45
67
|
} else if (info.type === '{missing-type-info}' || info.type === 'any') {
|
|
46
68
|
info.description = info.description || '';
|
|
47
69
|
}
|
|
48
|
-
|
|
49
70
|
// Set Allowed Values
|
|
50
|
-
info.allowedValues =
|
|
71
|
+
info.allowedValues = schema.const
|
|
72
|
+
? schema.const
|
|
73
|
+
: Array.isArray(schema.enum)
|
|
74
|
+
? schema.enum.map((v) => (getPrintableVal(v))).join('┃')
|
|
75
|
+
: '';
|
|
76
|
+
|
|
51
77
|
if (dataType === 'array' && schema.items) {
|
|
52
78
|
const arrayItemType = schema.items?.type;
|
|
53
|
-
const arrayItemDefault = schema.items
|
|
79
|
+
const arrayItemDefault = getPrintableVal(schema.items.default);
|
|
54
80
|
|
|
55
81
|
info.arrayType = `${schema.type} of ${Array.isArray(arrayItemType) ? arrayItemType.join('') : arrayItemType}`;
|
|
56
82
|
info.default = arrayItemDefault;
|
|
57
|
-
info.allowedValues =
|
|
83
|
+
info.allowedValues = schema.items.const
|
|
84
|
+
? schema.const
|
|
85
|
+
: Array.isArray(schema.items?.enum)
|
|
86
|
+
? schema.items.enum.map((v) => (getPrintableVal(v))).join('┃')
|
|
87
|
+
: '';
|
|
58
88
|
}
|
|
59
89
|
if (dataType.match(/integer|number/g)) {
|
|
60
90
|
if (schema.minimum !== undefined || schema.exclusiveMinimum !== undefined) {
|
|
@@ -80,8 +110,9 @@ export function getTypeInfo(schema) {
|
|
|
80
110
|
info.html = `${info.type}~|~${info.readOrWriteOnly}~|~${info.constrain}~|~${info.default}~|~${info.allowedValues}~|~${info.pattern}~|~${info.description}~|~${schema.title || ''}~|~${info.deprecated ? 'deprecated' : ''}`;
|
|
81
111
|
return info;
|
|
82
112
|
}
|
|
113
|
+
|
|
83
114
|
export function nestExampleIfPresent(example) {
|
|
84
|
-
if (typeof example === 'boolean') {
|
|
115
|
+
if (typeof example === 'boolean' || typeof example === 'number') {
|
|
85
116
|
return {
|
|
86
117
|
Example: { value: `${example}` },
|
|
87
118
|
};
|
|
@@ -94,6 +125,18 @@ export function nestExampleIfPresent(example) {
|
|
|
94
125
|
return example ? { Example: { value: example } } : example;
|
|
95
126
|
}
|
|
96
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Normalize example object in the following format (List of object which is used to render example links and fill the input boxes)
|
|
130
|
+
* [{
|
|
131
|
+
* exampleVal : 'value to be rendered on the input control (text-box)',
|
|
132
|
+
* exampleList : [
|
|
133
|
+
* value : '',
|
|
134
|
+
* printableValue: '',
|
|
135
|
+
* summary : '',
|
|
136
|
+
* description : ''
|
|
137
|
+
* ]
|
|
138
|
+
* }]
|
|
139
|
+
* */
|
|
97
140
|
export function normalizeExamples(examples, dataType = 'string') {
|
|
98
141
|
if (!examples) {
|
|
99
142
|
return {
|
|
@@ -101,19 +144,18 @@ export function normalizeExamples(examples, dataType = 'string') {
|
|
|
101
144
|
exampleList: [],
|
|
102
145
|
};
|
|
103
146
|
}
|
|
104
|
-
|
|
105
147
|
if (examples.constructor === Object) {
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
?
|
|
110
|
-
:
|
|
148
|
+
const exampleList = Object.values(examples)
|
|
149
|
+
.filter((v) => (v['x-example-show-value'] !== false))
|
|
150
|
+
.map((v) => ({
|
|
151
|
+
value: (typeof v.value === 'boolean' || typeof v.value === 'number' ? `${v.value}` : (v.value || '')),
|
|
152
|
+
printableValue: getPrintableVal(v.value),
|
|
153
|
+
summary: v.summary || '',
|
|
154
|
+
description: v.description || '',
|
|
155
|
+
}));
|
|
156
|
+
const exampleVal = exampleList.length > 0
|
|
157
|
+
? exampleList[0].value.toString()
|
|
111
158
|
: '';
|
|
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
159
|
return { exampleVal, exampleList };
|
|
118
160
|
}
|
|
119
161
|
|
|
@@ -131,12 +173,18 @@ export function normalizeExamples(examples, dataType = 'string') {
|
|
|
131
173
|
|
|
132
174
|
if (dataType === 'array') {
|
|
133
175
|
const [exampleVal] = examples;
|
|
134
|
-
const exampleList = examples.map((v) => ({
|
|
176
|
+
const exampleList = examples.map((v) => ({
|
|
177
|
+
value: v,
|
|
178
|
+
printableValue: getPrintableVal(v),
|
|
179
|
+
}));
|
|
135
180
|
return { exampleVal, exampleList };
|
|
136
181
|
}
|
|
137
182
|
|
|
138
183
|
const exampleVal = examples[0].toString();
|
|
139
|
-
const exampleList = examples.map((v) => ({
|
|
184
|
+
const exampleList = examples.map((v) => ({
|
|
185
|
+
value: v.toString(),
|
|
186
|
+
printableValue: getPrintableVal(v),
|
|
187
|
+
}));
|
|
140
188
|
return { exampleVal, exampleList };
|
|
141
189
|
}
|
|
142
190
|
|
|
@@ -153,6 +201,17 @@ export function getSampleValueByType(schemaObj) {
|
|
|
153
201
|
if (example === '') { return ''; }
|
|
154
202
|
if (example === null) { return null; }
|
|
155
203
|
if (example === 0) { return 0; }
|
|
204
|
+
if (example === false) { return false; }
|
|
205
|
+
if (example instanceof Date) {
|
|
206
|
+
switch (schemaObj.format.toLowerCase()) {
|
|
207
|
+
case 'date':
|
|
208
|
+
return example.toISOString().split('T')[0];
|
|
209
|
+
case 'time':
|
|
210
|
+
return example.toISOString().split('T')[1];
|
|
211
|
+
default:
|
|
212
|
+
return example.toISOString();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
156
215
|
if (example) { return example; }
|
|
157
216
|
|
|
158
217
|
if (Object.keys(schemaObj).length === 0) {
|
|
@@ -162,6 +221,12 @@ export function getSampleValueByType(schemaObj) {
|
|
|
162
221
|
// Indicates a Circular ref
|
|
163
222
|
return schemaObj.$ref;
|
|
164
223
|
}
|
|
224
|
+
if (schemaObj.const === false || schemaObj.const === 0 || schemaObj.const === null || schemaObj.const === '') {
|
|
225
|
+
return schemaObj.const;
|
|
226
|
+
}
|
|
227
|
+
if (schemaObj.const) {
|
|
228
|
+
return schemaObj.const;
|
|
229
|
+
}
|
|
165
230
|
const typeValue = Array.isArray(schemaObj.type) ? schemaObj.type[0] : schemaObj.type;
|
|
166
231
|
if (!typeValue) {
|
|
167
232
|
return '?';
|
|
@@ -187,6 +252,7 @@ export function getSampleValueByType(schemaObj) {
|
|
|
187
252
|
if (typeValue.match(/^null/g)) { return null; }
|
|
188
253
|
if (typeValue.match(/^string/g)) {
|
|
189
254
|
if (schemaObj.enum) { return schemaObj.enum[0]; }
|
|
255
|
+
if (schemaObj.const) { return schemaObj.const; }
|
|
190
256
|
if (schemaObj.pattern) { return schemaObj.pattern; }
|
|
191
257
|
if (schemaObj.format) {
|
|
192
258
|
const u = `${Date.now().toString(16)}${Math.random().toString(16)}0`.repeat(16);
|
|
@@ -242,9 +308,9 @@ json2xml- TestCase
|
|
|
242
308
|
<root>
|
|
243
309
|
<prop1>simple</prop1>
|
|
244
310
|
<prop2>
|
|
245
|
-
<0>
|
|
246
|
-
<1>
|
|
247
|
-
<2>
|
|
311
|
+
<0>a</0>
|
|
312
|
+
<1>b</1>
|
|
313
|
+
<2>c</2>
|
|
248
314
|
</prop2>
|
|
249
315
|
<prop3>
|
|
250
316
|
<ob1>val-1</ob1>
|
|
@@ -259,12 +325,22 @@ export function json2xml(obj, level = 1) {
|
|
|
259
325
|
return `\n${indent}${obj.toString()}`;
|
|
260
326
|
}
|
|
261
327
|
for (const prop in obj) {
|
|
328
|
+
const tagNameOrProp = (obj[prop]['::XML_TAG'] || prop);
|
|
329
|
+
let tagName = '';
|
|
330
|
+
if (Array.isArray(obj[prop])) {
|
|
331
|
+
tagName = tagNameOrProp[0]['::XML_TAG'] || `${prop}`;
|
|
332
|
+
} else {
|
|
333
|
+
tagName = tagNameOrProp;
|
|
334
|
+
}
|
|
335
|
+
if (prop.startsWith('::')) {
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
262
338
|
if (Array.isArray(obj[prop])) {
|
|
263
|
-
xmlText = `${xmlText}\n${indent}<${
|
|
339
|
+
xmlText = `${xmlText}\n${indent}<${tagName}>${json2xml(obj[prop], level + 1)}\n${indent}</${tagName}>`;
|
|
264
340
|
} else if (typeof obj[prop] === 'object') {
|
|
265
|
-
xmlText = `${xmlText}\n${indent}<${
|
|
341
|
+
xmlText = `${xmlText}\n${indent}<${tagName}>${json2xml(obj[prop], level + 1)}\n${indent}</${tagName}>`;
|
|
266
342
|
} else {
|
|
267
|
-
xmlText = `${xmlText}\n${indent}<${
|
|
343
|
+
xmlText = `${xmlText}\n${indent}<${tagName}>${obj[prop].toString()}</${tagName}>`;
|
|
268
344
|
}
|
|
269
345
|
}
|
|
270
346
|
return xmlText;
|
|
@@ -280,6 +356,12 @@ function addSchemaInfoToExample(schema, obj) {
|
|
|
280
356
|
if (schema.description) {
|
|
281
357
|
obj['::DESCRIPTION'] = schema.description;
|
|
282
358
|
}
|
|
359
|
+
if (schema.xml?.name) {
|
|
360
|
+
obj['::XML_TAG'] = schema.xml?.name;
|
|
361
|
+
}
|
|
362
|
+
if (schema.xml?.wrapped) {
|
|
363
|
+
obj['::XML_WRAP'] = schema.xml?.wrapped.toString();
|
|
364
|
+
}
|
|
283
365
|
}
|
|
284
366
|
|
|
285
367
|
function removeTitlesAndDescriptions(obj) {
|
|
@@ -288,6 +370,8 @@ function removeTitlesAndDescriptions(obj) {
|
|
|
288
370
|
}
|
|
289
371
|
delete obj['::TITLE'];
|
|
290
372
|
delete obj['::DESCRIPTION'];
|
|
373
|
+
delete obj['::XML_TAG'];
|
|
374
|
+
delete obj['::XML_WRAP'];
|
|
291
375
|
for (const k in obj) {
|
|
292
376
|
removeTitlesAndDescriptions(obj[k]);
|
|
293
377
|
}
|
|
@@ -326,11 +410,10 @@ export function schemaToSampleObj(schema, config = { }) {
|
|
|
326
410
|
if (!schema) {
|
|
327
411
|
return;
|
|
328
412
|
}
|
|
329
|
-
|
|
330
413
|
if (schema.allOf) {
|
|
331
414
|
const objWithAllProps = {};
|
|
332
415
|
|
|
333
|
-
if (schema.allOf.length === 1 && !schema.allOf[0]
|
|
416
|
+
if (schema.allOf.length === 1 && !schema.allOf[0]?.properties && !schema.allOf[0]?.items) {
|
|
334
417
|
// If allOf has single item and the type is not an object or array, then its a primitive
|
|
335
418
|
if (schema.allOf[0].$ref) {
|
|
336
419
|
return '{ }';
|
|
@@ -363,7 +446,11 @@ export function schemaToSampleObj(schema, config = { }) {
|
|
|
363
446
|
const objWithSchemaProps = {};
|
|
364
447
|
if (schema.properties) {
|
|
365
448
|
for (const propertyName in schema.properties) {
|
|
366
|
-
|
|
449
|
+
if (schema.properties[propertyName].properties || schema.properties[propertyName].properties?.items) {
|
|
450
|
+
objWithSchemaProps[propertyName] = schemaToSampleObj(schema.properties[propertyName], config);
|
|
451
|
+
} else {
|
|
452
|
+
objWithSchemaProps[propertyName] = getSampleValueByType(schema.properties[propertyName]);
|
|
453
|
+
}
|
|
367
454
|
}
|
|
368
455
|
}
|
|
369
456
|
|
|
@@ -477,11 +564,21 @@ export function schemaToSampleObj(schema, config = { }) {
|
|
|
477
564
|
addPropertyExampleToObjectExamples([schema.properties[propertyName].items.example], obj, propertyName);
|
|
478
565
|
} else {
|
|
479
566
|
const itemSamples = schemaToSampleObj(schema.properties[propertyName].items, config);
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
567
|
+
if (config.useXmlTagForProp) {
|
|
568
|
+
const xmlTagName = schema.properties[propertyName].xml?.name || propertyName;
|
|
569
|
+
if (schema.properties[propertyName].xml?.wrapped) {
|
|
570
|
+
const wrappedItemSample = JSON.parse(`{ "${xmlTagName}" : { "${xmlTagName}" : ${JSON.stringify(itemSamples['example-0'])} } }`);
|
|
571
|
+
obj = mergePropertyExamples(obj, xmlTagName, wrappedItemSample);
|
|
572
|
+
} else {
|
|
573
|
+
obj = mergePropertyExamples(obj, xmlTagName, itemSamples);
|
|
574
|
+
}
|
|
575
|
+
} else {
|
|
576
|
+
const arraySamples = [];
|
|
577
|
+
for (const key in itemSamples) {
|
|
578
|
+
arraySamples[key] = [itemSamples[key]];
|
|
579
|
+
}
|
|
580
|
+
obj = mergePropertyExamples(obj, propertyName, arraySamples);
|
|
483
581
|
}
|
|
484
|
-
obj = mergePropertyExamples(obj, propertyName, arraySamples);
|
|
485
582
|
}
|
|
486
583
|
continue;
|
|
487
584
|
}
|
|
@@ -513,26 +610,29 @@ export function schemaToSampleObj(schema, config = { }) {
|
|
|
513
610
|
}
|
|
514
611
|
|
|
515
612
|
function generateMarkdownForArrayAndObjectDescription(schema, level = 0) {
|
|
516
|
-
let markdown = '';
|
|
613
|
+
let markdown = ((schema.description || schema.title) && (schema.minItems || schema.maxItems)) ? '<span class="descr-expand-toggle">➔</span>' : '';
|
|
517
614
|
if (schema.title) {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
615
|
+
if (schema.description) {
|
|
616
|
+
markdown = `${markdown} <b>${schema.title}:</b> ${schema.description}<br/>`;
|
|
617
|
+
} else {
|
|
618
|
+
markdown = `${markdown} ${schema.title}<br/>`;
|
|
619
|
+
}
|
|
620
|
+
} else if (schema.description) {
|
|
621
|
+
markdown = `${markdown} ${schema.description}<br/>`;
|
|
522
622
|
}
|
|
523
623
|
if (schema.minItems) {
|
|
524
|
-
markdown = `${markdown}
|
|
624
|
+
markdown = `${markdown} <b>Min Items:</b> ${schema.minItems}`;
|
|
525
625
|
}
|
|
526
626
|
if (schema.maxItems) {
|
|
527
|
-
markdown = `${markdown}
|
|
627
|
+
markdown = `${markdown} <b>Max Items:</b> ${schema.maxItems}`;
|
|
528
628
|
}
|
|
529
629
|
if (level > 0 && schema.items?.description) {
|
|
530
630
|
let itemsMarkdown = '';
|
|
531
631
|
if (schema.items.minProperties) {
|
|
532
|
-
itemsMarkdown =
|
|
632
|
+
itemsMarkdown = `<b>Min Properties:</b> ${schema.items.minProperties}`;
|
|
533
633
|
}
|
|
534
634
|
if (schema.items.maxProperties) {
|
|
535
|
-
itemsMarkdown = `${itemsMarkdown}
|
|
635
|
+
itemsMarkdown = `${itemsMarkdown} <b>Max Properties:</b> ${schema.items.maxProperties}`;
|
|
536
636
|
}
|
|
537
637
|
markdown = `${markdown} ⮕ ${itemsMarkdown} [ ${schema.items.description} ] `;
|
|
538
638
|
}
|
|
@@ -597,11 +697,13 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
597
697
|
if (v.type === 'object' || v.properties || v.allOf || v.anyOf || v.oneOf) {
|
|
598
698
|
const partialObj = schemaInObjectNotation(v, {});
|
|
599
699
|
objWithAnyOfProps[`::OPTION~${index + 1}${v.title ? `~${v.title}` : ''}`] = partialObj;
|
|
700
|
+
objWithAnyOfProps[`::OPTION~${index + 1}${v.title ? `~${v.title}` : ''}`]['::readwrite'] = ''; // xxx-options cannot be read or write only
|
|
600
701
|
objWithAnyOfProps['::type'] = 'xxx-of-option';
|
|
601
702
|
} else if (v.type === 'array' || v.items) {
|
|
602
703
|
// This else-if block never seems to get executed
|
|
603
704
|
const partialObj = schemaInObjectNotation(v, {});
|
|
604
705
|
objWithAnyOfProps[`::OPTION~${index + 1}${v.title ? `~${v.title}` : ''}`] = partialObj;
|
|
706
|
+
objWithAnyOfProps[`::OPTION~${index + 1}${v.title ? `~${v.title}` : ''}`]['::readwrite'] = ''; // xxx-options cannot be read or write only
|
|
605
707
|
objWithAnyOfProps['::type'] = 'xxx-of-array';
|
|
606
708
|
} else {
|
|
607
709
|
const prop = `::OPTION~${index + 1}${v.title ? `~${v.title}` : ''}`;
|
|
@@ -610,7 +712,8 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
610
712
|
}
|
|
611
713
|
});
|
|
612
714
|
obj[(schema.anyOf ? `::ANY~OF ${suffix}` : `::ONE~OF ${suffix}`)] = objWithAnyOfProps;
|
|
613
|
-
obj['::type'] = '
|
|
715
|
+
// obj['::type'] = 'object';
|
|
716
|
+
obj['::type'] = 'object';
|
|
614
717
|
} else if (Array.isArray(schema.type)) {
|
|
615
718
|
// When a property has multiple types, then check further if any of the types are array or object, if yes then modify the schema using one-of
|
|
616
719
|
// Clone the schema - as it will be modified to replace multi-data-types with one-of;
|
|
@@ -640,7 +743,7 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
640
743
|
}
|
|
641
744
|
}
|
|
642
745
|
if (complexTypes.length > 0) {
|
|
643
|
-
obj['::type'] = '
|
|
746
|
+
obj['::type'] = 'object';
|
|
644
747
|
const multiTypeOptions = {
|
|
645
748
|
'::type': 'xxx-of-option',
|
|
646
749
|
};
|
|
@@ -697,8 +800,11 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
697
800
|
obj[key] = schemaInObjectNotation(schema.properties[key], {}, (level + 1));
|
|
698
801
|
}
|
|
699
802
|
}
|
|
803
|
+
for (const key in schema.patternProperties) {
|
|
804
|
+
obj[`[pattern: ${key}]`] = schemaInObjectNotation(schema.patternProperties[key], obj, (level + 1));
|
|
805
|
+
}
|
|
700
806
|
if (schema.additionalProperties) {
|
|
701
|
-
obj['
|
|
807
|
+
obj['[any-key]'] = schemaInObjectNotation(schema.additionalProperties, {});
|
|
702
808
|
}
|
|
703
809
|
} else if (schema.type === 'array' || schema.items) { // If Array
|
|
704
810
|
obj['::title'] = schema.title || '';
|
|
@@ -739,7 +845,8 @@ export function generateExample(schema, mimeType, examples = '', example = '', i
|
|
|
739
845
|
egContent = examples[eg].value;
|
|
740
846
|
if (typeof examples[eg].value === 'string') {
|
|
741
847
|
try {
|
|
742
|
-
const fixedJsonString = examples[eg].value.replace((/([\w]+)(:)/g), '"$1"$2').replace((/'/g), '"');
|
|
848
|
+
// const fixedJsonString = examples[eg].value.replace((/([\w]+)(:)/g), '"$1"$2').replace((/'/g), '"');
|
|
849
|
+
const fixedJsonString = examples[eg].value;
|
|
743
850
|
egContent = JSON.parse(fixedJsonString);
|
|
744
851
|
egFormat = 'json';
|
|
745
852
|
} catch (err) {
|
|
@@ -797,7 +904,8 @@ export function generateExample(schema, mimeType, examples = '', example = '', i
|
|
|
797
904
|
// If schema-level examples are not provided or includeGeneratedExample === true then generate one based on the schema field types
|
|
798
905
|
if (finalExamples.length === 0 || includeGeneratedExample === true) {
|
|
799
906
|
if (schema) {
|
|
800
|
-
if (schema.example) {
|
|
907
|
+
if (schema.example) {
|
|
908
|
+
// Note: Deprecated: The 'example' property has been deprecated in 3.1.0 in favor of the JSON Schema 'examples' keyword
|
|
801
909
|
finalExamples.push({
|
|
802
910
|
exampleId: 'Example',
|
|
803
911
|
exampleSummary: '',
|
|
@@ -812,22 +920,13 @@ export function generateExample(schema, mimeType, examples = '', example = '', i
|
|
|
812
920
|
let exampleFormat = '';
|
|
813
921
|
let exampleValue = '';
|
|
814
922
|
if (mimeType?.toLowerCase().includes('xml')) {
|
|
815
|
-
xmlRootStart =
|
|
816
|
-
xmlRootEnd =
|
|
923
|
+
xmlRootStart = schema.xml?.name ? `<${schema.xml.name} ${schema.xml.namespace ? `xmlns="${schema.xml.namespace}"` : ''}>` : '<root>';
|
|
924
|
+
xmlRootEnd = schema.xml?.name ? `</${schema.xml.name}>` : '</root>';
|
|
817
925
|
exampleFormat = 'text';
|
|
818
926
|
} else {
|
|
819
927
|
exampleFormat = outputType;
|
|
820
928
|
}
|
|
821
|
-
|
|
822
|
-
const samples = schemaToSampleObj(
|
|
823
|
-
schema,
|
|
824
|
-
{
|
|
825
|
-
includeReadOnly,
|
|
826
|
-
includeWriteOnly,
|
|
827
|
-
deprecated: true,
|
|
828
|
-
},
|
|
829
|
-
);
|
|
830
|
-
|
|
929
|
+
const samples = schemaToSampleObj(schema, { includeReadOnly, includeWriteOnly, deprecated: true, useXmlTagForProp: mimeType?.toLowerCase().includes('xml') });
|
|
831
930
|
let i = 0;
|
|
832
931
|
for (const samplesKey in samples) {
|
|
833
932
|
if (!samples[samplesKey]) {
|
|
@@ -835,11 +934,10 @@ export function generateExample(schema, mimeType, examples = '', example = '', i
|
|
|
835
934
|
}
|
|
836
935
|
const summary = samples[samplesKey]['::TITLE'] || `Example ${++i}`;
|
|
837
936
|
const description = samples[samplesKey]['::DESCRIPTION'] || '';
|
|
838
|
-
removeTitlesAndDescriptions(samples[samplesKey]);
|
|
839
|
-
|
|
840
937
|
if (mimeType?.toLowerCase().includes('xml')) {
|
|
841
|
-
exampleValue =
|
|
938
|
+
exampleValue = `<?xml version="1.0" encoding="UTF-8"?>\n${xmlRootStart}${json2xml(samples[samplesKey], 1)}\n${xmlRootEnd}`;
|
|
842
939
|
} else {
|
|
940
|
+
removeTitlesAndDescriptions(samples[samplesKey]);
|
|
843
941
|
exampleValue = outputType === 'text' ? JSON.stringify(samples[samplesKey], null, 2) : samples[samplesKey];
|
|
844
942
|
}
|
|
845
943
|
|
package/src/utils/spec-parser.js
CHANGED
|
@@ -347,6 +347,7 @@ function groupByTags(openApiSpec, sortEndpointsBy, generateMissingTags = false,
|
|
|
347
347
|
expandedAtLeastOnce: false,
|
|
348
348
|
summary: (pathOrHookObj.summary || ''),
|
|
349
349
|
description: (pathOrHookObj.description || ''),
|
|
350
|
+
externalDocs: pathOrHookObj.externalDocs,
|
|
350
351
|
shortSummary,
|
|
351
352
|
method: methodName,
|
|
352
353
|
path: pathOrHookName,
|
package/src/utils/theme.js
CHANGED
|
@@ -7,7 +7,7 @@ export default function setTheme(baseTheme, theme = {}) {
|
|
|
7
7
|
// Common Theme colors
|
|
8
8
|
const primaryColor = theme.primaryColor ? theme.primaryColor : baseTheme === 'dark' ? '#f76b39' : '#ff591e';
|
|
9
9
|
const primaryColorInvert = ColorUtils.color.invert(primaryColor);
|
|
10
|
-
const primaryColorTrans = ColorUtils.color.opacity(primaryColor, '0.
|
|
10
|
+
const primaryColorTrans = ColorUtils.color.opacity(primaryColor, '0.4');
|
|
11
11
|
|
|
12
12
|
// Dark and Light Theme colors
|
|
13
13
|
if (baseTheme === 'dark') {
|
|
@@ -31,6 +31,8 @@ export default function setTheme(baseTheme, theme = {}) {
|
|
|
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);
|
|
34
|
+
const navAccentTextColor = theme.navAccentTextColor ? theme.navAccenttextColor : ColorUtils.color.invert(navAccentColor);
|
|
35
|
+
|
|
34
36
|
const overlayBg = 'rgba(80, 80, 80, 0.4)';
|
|
35
37
|
|
|
36
38
|
newTheme = {
|
|
@@ -54,7 +56,7 @@ export default function setTheme(baseTheme, theme = {}) {
|
|
|
54
56
|
navHoverBgColor,
|
|
55
57
|
navHoverTextColor,
|
|
56
58
|
navAccentColor,
|
|
57
|
-
|
|
59
|
+
navAccentTextColor,
|
|
58
60
|
headerColor,
|
|
59
61
|
headerColorInvert: ColorUtils.color.invert(headerColor),
|
|
60
62
|
headerColorDarker: ColorUtils.color.brightness(headerColor, -20),
|
|
@@ -123,6 +125,7 @@ export default function setTheme(baseTheme, theme = {}) {
|
|
|
123
125
|
const navHoverBgColor = theme.navHoverBgColor ? theme.navHoverBgColor : ColorUtils.color.brightness(navBgColor, -15);
|
|
124
126
|
const navHoverTextColor = theme.navHoverTextColor ? theme.navHoverTextColor : ColorUtils.color.invert(navBgColor);
|
|
125
127
|
const navAccentColor = theme.navAccentColor ? theme.navAccentColor : ColorUtils.color.brightness(primaryColor, 25);
|
|
128
|
+
const navAccentTextColor = theme.navAccentTextColor ? theme.navAccenttextColor : ColorUtils.color.invert(navAccentColor);
|
|
126
129
|
const overlayBg = 'rgba(0, 0, 0, 0.4)';
|
|
127
130
|
|
|
128
131
|
newTheme = {
|
|
@@ -146,7 +149,7 @@ export default function setTheme(baseTheme, theme = {}) {
|
|
|
146
149
|
navHoverBgColor,
|
|
147
150
|
navHoverTextColor,
|
|
148
151
|
navAccentColor,
|
|
149
|
-
|
|
152
|
+
navAccentTextColor,
|
|
150
153
|
headerColor,
|
|
151
154
|
headerColorInvert: ColorUtils.color.invert(headerColor),
|
|
152
155
|
headerColorDarker: ColorUtils.color.brightness(headerColor, -20),
|
|
@@ -211,6 +214,8 @@ export default function setTheme(baseTheme, theme = {}) {
|
|
|
211
214
|
--font-size-regular: ${this.fontSize === 'default' ? '14px' : (this.fontSize === 'large' ? '15px' : '16px')};
|
|
212
215
|
--dialog-z-index: 1000;
|
|
213
216
|
|
|
217
|
+
--focus-shadow: 0 0 0 1px transparent, 0 0 0 3px ${newTheme.primaryColorTrans};
|
|
218
|
+
|
|
214
219
|
/* Theme specific styles */
|
|
215
220
|
--bg:${newTheme.bg1};
|
|
216
221
|
--bg2:${newTheme.bg2};
|
|
@@ -259,6 +264,7 @@ export default function setTheme(baseTheme, theme = {}) {
|
|
|
259
264
|
--nav-hover-bg-color:${newTheme.navHoverBgColor};
|
|
260
265
|
--nav-hover-text-color:${newTheme.navHoverTextColor};
|
|
261
266
|
--nav-accent-color:${newTheme.navAccentColor};
|
|
267
|
+
--nav-accent-text-color:${newTheme.navAccentTextColor};
|
|
262
268
|
|
|
263
269
|
/* Nav API Method Colors*/
|
|
264
270
|
--nav-get-color:${newTheme.blue};
|
package/webpack.config.js
CHANGED