rapidoc 9.1.8 → 9.3.2
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/LICENSE.txt +3 -1
- package/README.md +24 -6
- package/dist/index.html +1 -1
- package/dist/index.html.gz +0 -0
- package/dist/rapidoc-min.js +3776 -2
- package/dist/rapidoc-min.js.LICENSE.txt +12 -33
- 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 -0
- package/dist/rapidoc-min.js.map.gz +0 -0
- package/dist/rapidoc.js +4561 -3303
- package/dist/report.html +2 -2
- package/index.html +6 -4
- package/package.json +15 -15
- package/src/components/api-request.js +104 -78
- package/src/components/api-response.js +11 -8
- package/src/components/dialog-box.js +1 -1
- package/src/components/json-tree.js +15 -4
- package/src/components/schema-table.js +40 -18
- package/src/components/schema-tree.js +44 -15
- package/src/components/tag-input.js +1 -1
- package/src/json-schema-viewer.js +2 -2
- package/src/rapidoc-mini.js +27 -2
- package/src/rapidoc.js +41 -3
- package/src/styles/border-styles.js +1 -1
- package/src/styles/custom-styles.js +1 -1
- package/src/styles/dialog-box-styles.js +1 -1
- package/src/styles/endpoint-styles.js +10 -10
- package/src/styles/flex-styles.js +1 -1
- package/src/styles/font-styles.js +1 -1
- package/src/styles/info-styles.js +1 -1
- package/src/styles/input-styles.js +1 -1
- package/src/styles/nav-styles.js +4 -2
- package/src/styles/prism-styles.js +1 -1
- package/src/styles/schema-styles.js +4 -2
- package/src/styles/tab-styles.js +2 -1
- package/src/styles/table-styles.js +1 -1
- package/src/templates/advance-search-template.js +1 -1
- package/src/templates/callback-template.js +11 -4
- package/src/templates/code-samples-template.js +2 -2
- package/src/templates/components-template.js +4 -2
- package/src/templates/endpoint-template.js +23 -16
- package/src/templates/expanded-endpoint-template.js +77 -71
- package/src/templates/focused-endpoint-template.js +2 -2
- package/src/templates/header-template.js +2 -2
- package/src/templates/json-schema-viewer-template.js +3 -3
- package/src/templates/logo-template.js +1 -1
- package/src/templates/main-body-template.js +2 -2
- package/src/templates/navbar-template.js +22 -9
- package/src/templates/overview-template.js +3 -3
- package/src/templates/security-scheme-template.js +54 -44
- package/src/templates/server-template.js +4 -4
- package/src/utils/schema-utils.js +74 -27
- package/src/utils/spec-parser.js +1 -1
- package/src/utils/theme.js +12 -5
- package/webpack.config.js +1 -1
- package/.vscode/settings.json +0 -12
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable arrow-body-style */
|
|
2
|
-
import { html } from 'lit
|
|
3
|
-
import { unsafeHTML } from 'lit
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { unsafeHTML } from 'lit/directives/unsafe-html.js'; // eslint-disable-line import/extensions
|
|
4
4
|
import { marked } from 'marked';
|
|
5
5
|
|
|
6
6
|
const codeVerifier = '731DB1C3F7EA533B85E29492D26AA-1234567890-1234567890';
|
|
@@ -252,8 +252,8 @@ async function onInvokeOAuthFlow(securitySchemeId, flowType, authUrl, tokenUrl,
|
|
|
252
252
|
|
|
253
253
|
/* eslint-disable indent */
|
|
254
254
|
|
|
255
|
-
function oAuthFlowTemplate(flowName, clientId, clientSecret, securitySchemeId, authFlow) {
|
|
256
|
-
let { authorizationUrl, tokenUrl, refreshUrl } = authFlow
|
|
255
|
+
function oAuthFlowTemplate(flowName, clientId, clientSecret, securitySchemeId, authFlow, defaultScopes = [], receiveTokenIn = 'header') {
|
|
256
|
+
let { authorizationUrl, tokenUrl, refreshUrl } = authFlow;
|
|
257
257
|
const isUrlAbsolute = (url) => (url.indexOf('://') > 0 || url.indexOf('//') === 0);
|
|
258
258
|
if (refreshUrl && !isUrlAbsolute(refreshUrl)) {
|
|
259
259
|
refreshUrl = `${this.selectedServer.computedUrl}/${refreshUrl.replace(/^\//, '')}`;
|
|
@@ -277,8 +277,8 @@ function oAuthFlowTemplate(flowName, clientId, clientSecret, securitySchemeId, a
|
|
|
277
277
|
flowNameDisplay = flowName;
|
|
278
278
|
}
|
|
279
279
|
return html`
|
|
280
|
-
<div class="oauth-flow ${flowName}" style="padding: 12px 0; margin-bottom:12px;">
|
|
281
|
-
<div class="tiny-title upper" style="margin-bottom:8px;">${flowNameDisplay}</div>
|
|
280
|
+
<div class="oauth-flow ${flowName}" style="padding: 12px 0; margin-bottom:12px;">
|
|
281
|
+
<div class="tiny-title upper" style="margin-bottom:8px;">${flowNameDisplay}</div>
|
|
282
282
|
${authorizationUrl
|
|
283
283
|
? html`<div style="margin-bottom:5px"><span style="width:75px; display: inline-block;">Auth URL</span> <span class="mono-font"> ${authorizationUrl} </span></div>`
|
|
284
284
|
: ''
|
|
@@ -299,7 +299,7 @@ function oAuthFlowTemplate(flowName, clientId, clientSecret, securitySchemeId, a
|
|
|
299
299
|
<div class= "oauth-scopes" part="section-auth-scopes" style = "width:100%; display:flex; flex-direction:column; flex-wrap:wrap; margin:0 0 10px 24px">
|
|
300
300
|
${Object.entries(authFlow.scopes).map((scopeAndDescr, index) => html`
|
|
301
301
|
<div class="m-checkbox" style="display:inline-flex; align-items:center">
|
|
302
|
-
<input type="checkbox" part="checkbox checkbox-auth-scope" class="scope-checkbox" id="${securitySchemeId}${flowName}${index}" value="${scopeAndDescr[0]}">
|
|
302
|
+
<input type="checkbox" part="checkbox checkbox-auth-scope" class="scope-checkbox" id="${securitySchemeId}${flowName}${index}" ?checked="${defaultScopes.includes(scopeAndDescr[0])}" value="${scopeAndDescr[0]}">
|
|
303
303
|
<label for="${securitySchemeId}${flowName}${index}" style="margin-left:5px; cursor:pointer">
|
|
304
304
|
<span class="mono-font">${scopeAndDescr[0]}</span>
|
|
305
305
|
${scopeAndDescr[0] !== scopeAndDescr[1] ? ` - ${scopeAndDescr[1] || ''}` : ''}
|
|
@@ -317,16 +317,16 @@ function oAuthFlowTemplate(flowName, clientId, clientSecret, securitySchemeId, a
|
|
|
317
317
|
<input type="password" value = "" placeholder="password" spellcheck="false" class="oauth2 ${flowName} ${securitySchemeId} api-key-password" style = "margin:0 5px;" part="textbox textbox-password">
|
|
318
318
|
</div>`
|
|
319
319
|
: ''
|
|
320
|
-
}
|
|
320
|
+
}
|
|
321
321
|
<div>
|
|
322
322
|
${flowName === 'authorizationCode'
|
|
323
323
|
? html`
|
|
324
324
|
<div style="margin: 16px 0 4px">
|
|
325
|
-
<input type="checkbox" part="checkbox checkbox-auth-scope" id="${securitySchemeId}-pkce" checked>
|
|
325
|
+
<input type="checkbox" part="checkbox checkbox-auth-scope" id="${securitySchemeId}-pkce" checked>
|
|
326
326
|
<label for="${securitySchemeId}-pkce" style="margin:0 16px 0 4px; line-height:24px; cursor:pointer">
|
|
327
327
|
Send Proof Key for Code Exchange (PKCE)
|
|
328
328
|
</label>
|
|
329
|
-
</div>
|
|
329
|
+
</div>
|
|
330
330
|
`
|
|
331
331
|
: ''
|
|
332
332
|
}
|
|
@@ -337,8 +337,8 @@ function oAuthFlowTemplate(flowName, clientId, clientSecret, securitySchemeId, a
|
|
|
337
337
|
${flowName === 'authorizationCode' || flowName === 'clientCredentials' || flowName === 'password'
|
|
338
338
|
? html`
|
|
339
339
|
<select style="margin-right:5px;" class="${flowName} ${securitySchemeId} oauth-send-client-secret-in">
|
|
340
|
-
<option value = 'header' selected> Authorization Header </option>
|
|
341
|
-
<option value = 'request-body'> Request Body </option>
|
|
340
|
+
<option value = 'header' .selected = ${receiveTokenIn === 'header'} > Authorization Header </option>
|
|
341
|
+
<option value = 'request-body' .selected = ${receiveTokenIn === 'request-body'}> Request Body </option>
|
|
342
342
|
</select>`
|
|
343
343
|
: ''
|
|
344
344
|
}`
|
|
@@ -356,7 +356,7 @@ function oAuthFlowTemplate(flowName, clientId, clientSecret, securitySchemeId, a
|
|
|
356
356
|
`
|
|
357
357
|
: ''
|
|
358
358
|
}
|
|
359
|
-
</div>
|
|
359
|
+
</div>
|
|
360
360
|
`;
|
|
361
361
|
}
|
|
362
362
|
|
|
@@ -424,14 +424,14 @@ export default function securitySchemeTemplate() {
|
|
|
424
424
|
? html`Send <code>${v.name}</code> in <code>${v.in}</code>`
|
|
425
425
|
: html`Send <code>Authorization</code> in <code>header</code> containing the word <code>Bearer</code> followed by a space and a Token String.`
|
|
426
426
|
}
|
|
427
|
-
</div>
|
|
427
|
+
</div>
|
|
428
428
|
<div style="max-height:28px;">
|
|
429
429
|
${v.in !== 'cookie'
|
|
430
430
|
? html`
|
|
431
431
|
<input type = "text" value = "${v.value}" class="${v.type} ${v.securitySchemeId} api-key-input" placeholder = "api-token" spellcheck = "false">
|
|
432
432
|
<button class="m-btn thin-border" style = "margin-left:5px;"
|
|
433
433
|
part = "btn btn-outline"
|
|
434
|
-
@click="${(e) => { onApiKeyChange.call(this, v.securitySchemeId, e); }}">
|
|
434
|
+
@click="${(e) => { onApiKeyChange.call(this, v.securitySchemeId, e); }}">
|
|
435
435
|
${v.finalKeyValue ? 'UPDATE' : 'SET'}
|
|
436
436
|
</button>`
|
|
437
437
|
: html`<span class="gray-text" style="font-size::var(--font-size-small)"> cookies cannot be set from here</span>`
|
|
@@ -443,14 +443,14 @@ export default function securitySchemeTemplate() {
|
|
|
443
443
|
? html`
|
|
444
444
|
<div style="margin-bottom:5px">
|
|
445
445
|
Send <code>Authorization</code> in <code>header</code> containing the word <code>Basic</code> followed by a space and a base64 encoded string of <code>username:password</code>.
|
|
446
|
-
</div>
|
|
446
|
+
</div>
|
|
447
447
|
<div>
|
|
448
448
|
<input type="text" value = "${v.user}" placeholder="username" spellcheck="false" class="${v.type} ${v.securitySchemeId} api-key-user" style="width:100px">
|
|
449
449
|
<input type="password" value = "${v.password}" placeholder="password" spellcheck="false" class="${v.type} ${v.securitySchemeId} api-key-password" style = "width:100px; margin:0 5px;">
|
|
450
450
|
<button class="m-btn thin-border"
|
|
451
451
|
@click="${(e) => { onApiKeyChange.call(this, v.securitySchemeId, e); }}"
|
|
452
452
|
part = "btn btn-outline"
|
|
453
|
-
>
|
|
453
|
+
>
|
|
454
454
|
${v.finalKeyValue ? 'UPDATE' : 'SET'}
|
|
455
455
|
</button>
|
|
456
456
|
</div>`
|
|
@@ -462,12 +462,12 @@ export default function securitySchemeTemplate() {
|
|
|
462
462
|
? html`
|
|
463
463
|
<tr>
|
|
464
464
|
<td style="border:none; padding-left:48px">
|
|
465
|
-
${Object.keys(v.flows).map((f) => oAuthFlowTemplate.call(this, f, v['x-client-id'], v['x-client-secret'], v.securitySchemeId, v.flows[f]))}
|
|
465
|
+
${Object.keys(v.flows).map((f) => oAuthFlowTemplate.call(this, f, v['x-client-id'], v['x-client-secret'], v.securitySchemeId, v.flows[f], v['x-default-scopes'], v['x-receive-token-in']))}
|
|
466
466
|
</td>
|
|
467
|
-
</tr>
|
|
467
|
+
</tr>
|
|
468
468
|
`
|
|
469
469
|
: ''
|
|
470
|
-
}
|
|
470
|
+
}
|
|
471
471
|
`)}
|
|
472
472
|
</table>`
|
|
473
473
|
: ''
|
|
@@ -483,21 +483,28 @@ export function pathSecurityTemplate(pathSecurity) {
|
|
|
483
483
|
pathSecurity.forEach((pSecurity) => {
|
|
484
484
|
const andSecurityKeys1 = [];
|
|
485
485
|
const andKeyTypes = [];
|
|
486
|
-
Object.keys(pSecurity).
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
486
|
+
if (Object.keys(pSecurity).length === 0) {
|
|
487
|
+
orSecurityKeys1.push({
|
|
488
|
+
securityTypes: 'None',
|
|
489
|
+
securityDefs: [],
|
|
490
|
+
});
|
|
491
|
+
} else {
|
|
492
|
+
Object.keys(pSecurity).forEach((pathSecurityKey) => {
|
|
493
|
+
let pathScopes = '';
|
|
494
|
+
const s = this.resolvedSpec.securitySchemes.find((ss) => ss.securitySchemeId === pathSecurityKey);
|
|
495
|
+
if (pSecurity[pathSecurityKey] && Array.isArray(pSecurity[pathSecurityKey])) {
|
|
496
|
+
pathScopes = pSecurity[pathSecurityKey].join(', ');
|
|
497
|
+
}
|
|
498
|
+
if (s) {
|
|
499
|
+
andKeyTypes.push(s.typeDisplay);
|
|
500
|
+
andSecurityKeys1.push({ ...s, ...({ scopes: pathScopes }) });
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
orSecurityKeys1.push({
|
|
504
|
+
securityTypes: andKeyTypes.length > 1 ? `${andKeyTypes[0]} + ${andKeyTypes.length - 1} more` : andKeyTypes[0],
|
|
505
|
+
securityDefs: andSecurityKeys1,
|
|
506
|
+
});
|
|
507
|
+
}
|
|
501
508
|
});
|
|
502
509
|
return html`<div style="position:absolute; top:3px; right:2px; font-size:var(--font-size-small); line-height: 1.5;">
|
|
503
510
|
<div style="position:relative; display:flex; min-width:350px; max-width:700px; justify-content: flex-end;">
|
|
@@ -507,13 +514,16 @@ export function pathSecurityTemplate(pathSecurity) {
|
|
|
507
514
|
</g>
|
|
508
515
|
</svg>
|
|
509
516
|
${orSecurityKeys1.map((orSecurityItem1, i) => html`
|
|
510
|
-
|
|
517
|
+
|
|
511
518
|
${orSecurityItem1.securityTypes
|
|
512
519
|
? html`
|
|
513
520
|
${i !== 0 ? html`<div style="padding:3px 4px;"> OR </div>` : ''}
|
|
514
521
|
<div class="tooltip">
|
|
515
522
|
<div style = "padding:2px 4px; white-space:nowrap; text-overflow:ellipsis;max-width:150px; overflow:hidden;">
|
|
516
|
-
|
|
523
|
+
${this.updateRoute === 'true' && this.allowAuthentication === 'true'
|
|
524
|
+
? html`<a part="anchor anchor-operation-security" href="#auth"> ${orSecurityItem1.securityTypes} </a>`
|
|
525
|
+
: html`${orSecurityItem1.securityTypes}`
|
|
526
|
+
}
|
|
517
527
|
</div>
|
|
518
528
|
<div class="tooltip-text" style="position:absolute; color: var(--fg); top:26px; right:0; border:1px solid var(--border-color);padding:2px 4px; display:block;">
|
|
519
529
|
${orSecurityItem1.securityDefs.length > 1 ? html`<div>Requires <b>all</b> of the following </div>` : ''}
|
|
@@ -522,11 +532,11 @@ export function pathSecurityTemplate(pathSecurity) {
|
|
|
522
532
|
const scopeHtml = html`${andSecurityItem.scopes !== ''
|
|
523
533
|
? html`
|
|
524
534
|
<div>
|
|
525
|
-
<b>Required scopes:</b>
|
|
526
|
-
<br/>
|
|
527
|
-
<div style="margin-left:8px">
|
|
535
|
+
<b>Required scopes:</b>
|
|
536
|
+
<br/>
|
|
537
|
+
<div style="margin-left:8px">
|
|
528
538
|
${andSecurityItem.scopes.split(',').map((scope, cnt) => html`${cnt === 0 ? '' : '┃'}<span>${scope}</span>`)}
|
|
529
|
-
</div>
|
|
539
|
+
</div>
|
|
530
540
|
</div>`
|
|
531
541
|
: ''
|
|
532
542
|
}`;
|
|
@@ -545,19 +555,19 @@ export function pathSecurityTemplate(pathSecurity) {
|
|
|
545
555
|
: andSecurityItem.type === 'http'
|
|
546
556
|
? html`
|
|
547
557
|
<div>
|
|
548
|
-
${orSecurityItem1.securityDefs.length > 1 ? html`<b>${j + 1}.</b> ` : html`Requires`}
|
|
558
|
+
${orSecurityItem1.securityDefs.length > 1 ? html`<b>${j + 1}.</b> ` : html`Requires`}
|
|
549
559
|
${andSecurityItem.scheme === 'basic' ? 'Base 64 encoded username:password' : 'Bearer Token'} in <b>Authorization header</b>
|
|
550
560
|
${scopeHtml}
|
|
551
561
|
</div>`
|
|
552
562
|
: html`
|
|
553
563
|
<div>
|
|
554
|
-
${orSecurityItem1.securityDefs.length > 1 ? html`<b>${j + 1}.</b> ` : html`Requires`}
|
|
564
|
+
${orSecurityItem1.securityDefs.length > 1 ? html`<b>${j + 1}.</b> ` : html`Requires`}
|
|
555
565
|
Token in <b>${andSecurityItem.name} ${andSecurityItem.in}</b>
|
|
556
566
|
${scopeHtml}
|
|
557
567
|
</div>`
|
|
558
568
|
}`;
|
|
559
569
|
})}
|
|
560
|
-
</div>
|
|
570
|
+
</div>
|
|
561
571
|
</div>
|
|
562
572
|
</div>
|
|
563
573
|
`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { html } from 'lit
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
import { unsafeHTML } from 'lit/directives/unsafe-html.js'; // eslint-disable-line import/extensions
|
|
2
3
|
import { marked } from 'marked';
|
|
3
|
-
import { unsafeHTML } from 'lit-html/directives/unsafe-html';
|
|
4
4
|
|
|
5
5
|
export function setApiServer(serverUrl) {
|
|
6
6
|
const serverObj = this.resolvedSpec?.servers.find((s) => s.url === serverUrl);
|
|
@@ -35,7 +35,7 @@ function serverVarsTemplate() {
|
|
|
35
35
|
// const selectedServerObj = this.resolvedSpec.servers.find((v) => (v.url === this.selectedServer));
|
|
36
36
|
return this.selectedServer && this.selectedServer.variables
|
|
37
37
|
? html`
|
|
38
|
-
<div class="table-title">
|
|
38
|
+
<div class="table-title">SERVER VARIABLES</div>
|
|
39
39
|
<table class='m-table'>
|
|
40
40
|
${Object.entries(this.selectedServer.variables).map((kv) => html`
|
|
41
41
|
<tr>
|
|
@@ -86,7 +86,7 @@ export default function serverTemplate() {
|
|
|
86
86
|
if (!this.resolvedSpec || this.resolvedSpec.specLoadError) { return ''; }
|
|
87
87
|
return html`
|
|
88
88
|
<section id = 'servers' part="section-servers" style="text-align:left; direction:ltr; margin-top:24px; margin-bottom:24px;" class='regular-font observe-me ${'read focused'.includes(this.renderStyle) ? 'section-gap--read-mode' : 'section-gap'}'>
|
|
89
|
-
<div class =
|
|
89
|
+
<div part = "section-servers-title" class = "sub-title">API SERVER</div>
|
|
90
90
|
<div class = 'mono-font' style='margin: 12px 0; font-size:calc(var(--font-size-small) + 1px);'>
|
|
91
91
|
${!this.resolvedSpec.servers || this.resolvedSpec.servers?.length === 0
|
|
92
92
|
? ''
|
|
@@ -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
|
}
|
|
@@ -32,7 +32,7 @@ export function getTypeInfo(schema) {
|
|
|
32
32
|
readOrWriteOnly: (schema.readOnly ? '🆁' : schema.writeOnly ? '🆆' : ''),
|
|
33
33
|
deprecated: schema.deprecated ? '❌' : '',
|
|
34
34
|
examples: schema.examples || schema.example,
|
|
35
|
-
default: schema.default
|
|
35
|
+
default: schema.default != null ? `${schema.default}` : '',
|
|
36
36
|
description: schema.description || '',
|
|
37
37
|
constrain: '',
|
|
38
38
|
allowedValues: '',
|
|
@@ -389,12 +389,20 @@ export function schemaToSampleObj(schema, config = { }) {
|
|
|
389
389
|
const oneOfSamples = schemaToSampleObj(schema.oneOf[key], config);
|
|
390
390
|
for (const sampleKey in oneOfSamples) {
|
|
391
391
|
// 2. In the final example include a one-of item along with properties
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
392
|
+
let finalExample;
|
|
393
|
+
if (Object.keys(objWithSchemaProps).length > 0) {
|
|
394
|
+
if (oneOfSamples[sampleKey] === null || typeof oneOfSamples[sampleKey] !== 'object') {
|
|
395
|
+
// This doesn't really make sense since every oneOf schema _should_ be an object if there are common properties, so we'll skip this
|
|
396
|
+
continue;
|
|
397
|
+
} else {
|
|
398
|
+
finalExample = Object.assign(oneOfSamples[sampleKey], objWithSchemaProps);
|
|
399
|
+
}
|
|
400
|
+
} else {
|
|
401
|
+
finalExample = oneOfSamples[sampleKey];
|
|
397
402
|
}
|
|
403
|
+
obj[`example-${i}`] = finalExample;
|
|
404
|
+
addSchemaInfoToExample(schema.oneOf[key], obj[`example-${i}`]);
|
|
405
|
+
i++;
|
|
398
406
|
}
|
|
399
407
|
}
|
|
400
408
|
}
|
|
@@ -460,18 +468,22 @@ export function schemaToSampleObj(schema, config = { }) {
|
|
|
460
468
|
}
|
|
461
469
|
}
|
|
462
470
|
} else if (schema.type === 'array' || schema.items) {
|
|
463
|
-
if (schema.example) {
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
471
|
+
if (schema.items || schema.example) {
|
|
472
|
+
if (schema.example) {
|
|
473
|
+
obj['example-0'] = schema.example;
|
|
474
|
+
} else if (schema.items?.example) { // schemas and properties support single example but not multiple examples.
|
|
475
|
+
obj['example-0'] = [schema.items.example];
|
|
476
|
+
} else {
|
|
477
|
+
const samples = schemaToSampleObj(schema.items, config);
|
|
478
|
+
let i = 0;
|
|
479
|
+
for (const key in samples) {
|
|
480
|
+
obj[`example-${i}`] = [samples[key]];
|
|
481
|
+
addSchemaInfoToExample(schema.items, obj[`example-${i}`]);
|
|
482
|
+
i++;
|
|
483
|
+
}
|
|
474
484
|
}
|
|
485
|
+
} else {
|
|
486
|
+
obj['example-0'] = [];
|
|
475
487
|
}
|
|
476
488
|
} else {
|
|
477
489
|
return { 'example-0': getSampleValueByType(schema) };
|
|
@@ -479,6 +491,32 @@ export function schemaToSampleObj(schema, config = { }) {
|
|
|
479
491
|
return obj;
|
|
480
492
|
}
|
|
481
493
|
|
|
494
|
+
function generateMarkdownForArrayAndObjectDescription(schema, level = 0) {
|
|
495
|
+
let markdown = '';
|
|
496
|
+
if (schema.title) {
|
|
497
|
+
markdown = `**${schema.title}:** `;
|
|
498
|
+
}
|
|
499
|
+
if (schema.description) {
|
|
500
|
+
markdown = `${markdown} ${schema.description} ${schema.minItems || schema.maxItems ? '<span class="more-content">⤵</span><br/>' : ''}`;
|
|
501
|
+
}
|
|
502
|
+
if (schema.minItems) {
|
|
503
|
+
markdown = `${markdown} **Min Items:** ${schema.minItems}`;
|
|
504
|
+
}
|
|
505
|
+
if (schema.maxItems) {
|
|
506
|
+
markdown = `${markdown} **Max Items:** ${schema.maxItems}`;
|
|
507
|
+
}
|
|
508
|
+
if (level > 0 && schema.items?.description) {
|
|
509
|
+
let itemsMarkdown = '';
|
|
510
|
+
if (schema.items.minProperties) {
|
|
511
|
+
itemsMarkdown = `**Min Properties:** ${schema.items.minProperties}`;
|
|
512
|
+
}
|
|
513
|
+
if (schema.items.maxProperties) {
|
|
514
|
+
itemsMarkdown = `${itemsMarkdown} **Max Properties:** ${schema.items.maxProperties}`;
|
|
515
|
+
}
|
|
516
|
+
markdown = `${markdown} ⮕ ${itemsMarkdown} [ ${schema.items.description} ] `;
|
|
517
|
+
}
|
|
518
|
+
return markdown;
|
|
519
|
+
}
|
|
482
520
|
/**
|
|
483
521
|
* For changing OpenAPI-Schema to an Object Notation,
|
|
484
522
|
* This Object would further be an input to UI Components to generate an Object-Tree
|
|
@@ -574,7 +612,7 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
574
612
|
});
|
|
575
613
|
let multiPrimitiveTypes;
|
|
576
614
|
if (primitiveType.length > 0) {
|
|
577
|
-
subSchema.type = primitiveType.join('┃');
|
|
615
|
+
subSchema.type = primitiveType.join(primitiveType.length === 2 ? ' or ' : '┃');
|
|
578
616
|
multiPrimitiveTypes = getTypeInfo(subSchema);
|
|
579
617
|
if (complexTypes.length === 0) {
|
|
580
618
|
return `${multiPrimitiveTypes?.html || ''}`;
|
|
@@ -597,6 +635,7 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
597
635
|
} else if (v === 'object') {
|
|
598
636
|
// If object type iterate all the properties and create an object-type-option
|
|
599
637
|
const objTypeOption = {
|
|
638
|
+
'::title': schema.title || '',
|
|
600
639
|
'::description': schema.description || '',
|
|
601
640
|
'::type': 'object',
|
|
602
641
|
'::deprecated': schema.deprecated || false,
|
|
@@ -611,6 +650,7 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
611
650
|
multiTypeOptions[`::OPTION~${i + 1}`] = objTypeOption;
|
|
612
651
|
} else if (v === 'array') {
|
|
613
652
|
multiTypeOptions[`::OPTION~${i + 1}`] = {
|
|
653
|
+
'::title': schema.title || '',
|
|
614
654
|
'::description': schema.description || '',
|
|
615
655
|
'::type': 'array',
|
|
616
656
|
'::props': schemaInObjectNotation(schema.items, {}, (level + 1)),
|
|
@@ -620,8 +660,9 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
620
660
|
multiTypeOptions[`::OPTION~${complexTypes.length + 1}`] = multiPrimitiveTypes?.html || '';
|
|
621
661
|
obj['::ONE~OF'] = multiTypeOptions;
|
|
622
662
|
}
|
|
623
|
-
} else if (schema.type === 'object' || schema.properties) {
|
|
624
|
-
obj['::
|
|
663
|
+
} else if (schema.type === 'object' || schema.properties) { // If Object
|
|
664
|
+
obj['::title'] = schema.title || '';
|
|
665
|
+
obj['::description'] = generateMarkdownForArrayAndObjectDescription(schema, level);
|
|
625
666
|
obj['::type'] = 'object';
|
|
626
667
|
obj['::deprecated'] = schema.deprecated || false;
|
|
627
668
|
obj['::readwrite'] = schema.readOnly ? 'readonly' : schema.writeOnly ? 'writeonly' : '';
|
|
@@ -636,15 +677,12 @@ export function schemaInObjectNotation(schema, obj, level = 0, suffix = '') {
|
|
|
636
677
|
obj['<any-key>'] = schemaInObjectNotation(schema.additionalProperties, {});
|
|
637
678
|
}
|
|
638
679
|
} else if (schema.type === 'array' || schema.items) { // If Array
|
|
639
|
-
obj['::
|
|
640
|
-
|
|
641
|
-
: schema.items?.description
|
|
642
|
-
? `array<${schema.items.description}>`
|
|
643
|
-
: '';
|
|
680
|
+
obj['::title'] = schema.title || '';
|
|
681
|
+
obj['::description'] = generateMarkdownForArrayAndObjectDescription(schema, level);
|
|
644
682
|
obj['::type'] = 'array';
|
|
645
683
|
obj['::deprecated'] = schema.deprecated || false;
|
|
646
684
|
obj['::readwrite'] = schema.readOnly ? 'readonly' : schema.writeOnly ? 'writeonly' : '';
|
|
647
|
-
if (schema.items
|
|
685
|
+
if (schema.items?.items) {
|
|
648
686
|
obj['::array-type'] = schema.items.items.type;
|
|
649
687
|
}
|
|
650
688
|
obj['::props'] = schemaInObjectNotation(schema.items, {}, (level + 1));
|
|
@@ -787,6 +825,15 @@ export function generateExample(schema, mimeType, examples = '', example = '', i
|
|
|
787
825
|
exampleValue,
|
|
788
826
|
});
|
|
789
827
|
}
|
|
828
|
+
} else if (mimeType?.toLowerCase().includes('jose')) {
|
|
829
|
+
finalExamples.push({
|
|
830
|
+
exampleId: 'Example',
|
|
831
|
+
exampleSummary: 'Base64 Encoded',
|
|
832
|
+
exampleDescription: '',
|
|
833
|
+
exampleType: mimeType,
|
|
834
|
+
exampleValue: schema.pattern || 'bXJpbg==',
|
|
835
|
+
exampleFormat: 'text',
|
|
836
|
+
});
|
|
790
837
|
} else {
|
|
791
838
|
finalExamples.push({
|
|
792
839
|
exampleId: 'Example',
|
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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { html } from 'lit
|
|
1
|
+
import { html } from 'lit';
|
|
2
2
|
import ColorUtils from '~/utils/color-utils';
|
|
3
3
|
/* Generates an schema object containing type and constraint info */
|
|
4
4
|
export default function setTheme(baseTheme, theme = {}) {
|
|
@@ -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);
|
|
@@ -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
|
|