rapidoc 9.3.7 → 10.0.0
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/README.md +193 -61
- package/dist/rapidoc-min.js +279 -3912
- package/package.json +24 -47
- package/.babelrc.json +0 -42
- package/.eslintrc +0 -53
- package/.github/FUNDING.yml +0 -13
- package/.github/workflow/words.yaml +0 -22
- package/CONTRIBUTING.md +0 -35
- package/dist/index.html +0 -6
- package/dist/index.html.gz +0 -0
- package/dist/rapidoc-min.js.LICENSE.txt +0 -64
- package/dist/rapidoc-min.js.LICENSE.txt.gz +0 -0
- package/dist/rapidoc-min.js.gz +0 -0
- package/dist/rapidoc-min.js.map +0 -1
- package/dist/rapidoc-min.js.map.gz +0 -0
- package/dist/rapidoc.js +0 -21594
- package/dist/report.html +0 -39
- package/index-hashroute.html +0 -65
- package/index.html +0 -249
- package/index1.html +0 -244
- package/jsconfig.json +0 -11
- package/logo.png +0 -0
- package/performance.html +0 -31
- package/src/components/api-request.js +0 -1787
- package/src/components/api-response.js +0 -335
- package/src/components/dialog-box.js +0 -73
- package/src/components/json-tree.js +0 -145
- package/src/components/schema-table.js +0 -358
- package/src/components/schema-tree.js +0 -378
- package/src/components/tag-input.js +0 -135
- package/src/index.js +0 -7
- package/src/json-schema-viewer.js +0 -345
- package/src/oauth-receiver.js +0 -56
- package/src/rapidoc-mini.js +0 -380
- package/src/rapidoc.js +0 -1082
- package/src/styles/border-styles.js +0 -24
- package/src/styles/custom-styles.js +0 -10
- package/src/styles/dialog-box-styles.js +0 -75
- package/src/styles/endpoint-styles.js +0 -202
- package/src/styles/flex-styles.js +0 -15
- package/src/styles/font-styles.js +0 -268
- package/src/styles/info-styles.js +0 -21
- package/src/styles/input-styles.js +0 -202
- package/src/styles/nav-styles.js +0 -198
- package/src/styles/prism-styles.js +0 -105
- package/src/styles/schema-styles.js +0 -121
- package/src/styles/tab-styles.js +0 -47
- package/src/styles/table-styles.js +0 -58
- package/src/templates/advance-search-template.js +0 -72
- package/src/templates/callback-template.js +0 -73
- package/src/templates/code-samples-template.js +0 -34
- package/src/templates/components-template.js +0 -76
- package/src/templates/endpoint-template.js +0 -249
- package/src/templates/expanded-endpoint-template.js +0 -197
- package/src/templates/focused-endpoint-template.js +0 -110
- package/src/templates/header-template.js +0 -66
- package/src/templates/json-schema-viewer-template.js +0 -185
- package/src/templates/logo-template.js +0 -18
- package/src/templates/main-body-template.js +0 -121
- package/src/templates/navbar-template.js +0 -272
- package/src/templates/overview-template.js +0 -79
- package/src/templates/security-scheme-template.js +0 -610
- package/src/templates/server-template.js +0 -115
- package/src/utils/color-utils.js +0 -59
- package/src/utils/common-utils.js +0 -168
- package/src/utils/schema-utils.js +0 -1086
- package/src/utils/spec-parser.js +0 -462
- package/src/utils/theme.js +0 -288
- package/webpack.config.js +0 -142
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { html } from 'lit';
|
|
2
|
-
import { unsafeHTML } from 'lit/directives/unsafe-html.js'; // eslint-disable-line import/extensions
|
|
3
|
-
import { marked } from 'marked';
|
|
4
|
-
|
|
5
|
-
export function setApiServer(serverUrl) {
|
|
6
|
-
const serverObj = this.resolvedSpec?.servers.find((s) => s.url === serverUrl);
|
|
7
|
-
if (!serverObj) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
this.selectedServer = serverObj;
|
|
11
|
-
this.requestUpdate();
|
|
12
|
-
this.dispatchEvent(new CustomEvent('api-server-change', {
|
|
13
|
-
bubbles: true,
|
|
14
|
-
composed: true,
|
|
15
|
-
detail: {
|
|
16
|
-
selectedServer: serverObj,
|
|
17
|
-
},
|
|
18
|
-
}));
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function onApiServerVarChange(e, serverObj) {
|
|
23
|
-
const inputEls = [...e.currentTarget.closest('table').querySelectorAll('input, select')];
|
|
24
|
-
let tempUrl = serverObj.url;
|
|
25
|
-
inputEls.forEach((v) => {
|
|
26
|
-
const regex = new RegExp(`{${v.dataset.var}}`, 'g');
|
|
27
|
-
tempUrl = tempUrl.replace(regex, v.value);
|
|
28
|
-
});
|
|
29
|
-
serverObj.computedUrl = tempUrl;
|
|
30
|
-
this.requestUpdate();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/* eslint-disable indent */
|
|
34
|
-
function serverVarsTemplate() {
|
|
35
|
-
// const selectedServerObj = this.resolvedSpec.servers.find((v) => (v.url === this.selectedServer));
|
|
36
|
-
return this.selectedServer && this.selectedServer.variables
|
|
37
|
-
? html`
|
|
38
|
-
<div class="table-title">SERVER VARIABLES</div>
|
|
39
|
-
<table class='m-table' role='presentation'>
|
|
40
|
-
${Object.entries(this.selectedServer.variables).map((kv) => html`
|
|
41
|
-
<tr>
|
|
42
|
-
<td style="vertical-align: middle;" >${kv[0]}</td>
|
|
43
|
-
<td>
|
|
44
|
-
${kv[1].enum
|
|
45
|
-
? html`
|
|
46
|
-
<select
|
|
47
|
-
data-var = "${kv[0]}"
|
|
48
|
-
@input = ${(e) => { onApiServerVarChange.call(this, e, this.selectedServer); }}
|
|
49
|
-
>
|
|
50
|
-
${Object.entries(kv[1].enum).map((e) => (kv[1].default === e[1]
|
|
51
|
-
? html`
|
|
52
|
-
<option
|
|
53
|
-
selected
|
|
54
|
-
label = ${e[1]}
|
|
55
|
-
value = ${e[1]}
|
|
56
|
-
/>`
|
|
57
|
-
: html`
|
|
58
|
-
<option
|
|
59
|
-
label = ${e[1]}
|
|
60
|
-
value = ${e[1]}
|
|
61
|
-
/>`
|
|
62
|
-
))}
|
|
63
|
-
</select>`
|
|
64
|
-
: html`
|
|
65
|
-
<input
|
|
66
|
-
type = "text"
|
|
67
|
-
part="textbox textbox-server-var"
|
|
68
|
-
spellcheck = "false"
|
|
69
|
-
data-var = "${kv[0]}"
|
|
70
|
-
value = "${kv[1].default}"
|
|
71
|
-
@input = ${(e) => { onApiServerVarChange.call(this, e, this.selectedServer); }}
|
|
72
|
-
/>`}
|
|
73
|
-
</td>
|
|
74
|
-
</tr>
|
|
75
|
-
${kv[1].description
|
|
76
|
-
? html`<tr><td colspan="2" style="border:none"><span class="m-markdown-small"> ${unsafeHTML(marked(kv[1].description))} </span></td></tr>`
|
|
77
|
-
: ''
|
|
78
|
-
}
|
|
79
|
-
`)}
|
|
80
|
-
</table>
|
|
81
|
-
`
|
|
82
|
-
: '';
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export default function serverTemplate() {
|
|
86
|
-
if (!this.resolvedSpec || this.resolvedSpec.specLoadError) { return ''; }
|
|
87
|
-
return html`
|
|
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 part = "section-servers-title" class = "sub-title">API SERVER</div>
|
|
90
|
-
<div class = 'mono-font' style='margin: 12px 0; font-size:calc(var(--font-size-small) + 1px);'>
|
|
91
|
-
${!this.resolvedSpec.servers || this.resolvedSpec.servers?.length === 0
|
|
92
|
-
? ''
|
|
93
|
-
: html`
|
|
94
|
-
${this.resolvedSpec?.servers.map((server, i) => html`
|
|
95
|
-
<input type = 'radio'
|
|
96
|
-
name = 'api_server'
|
|
97
|
-
id = 'srvr-opt-${i}'
|
|
98
|
-
value = '${server.url}'
|
|
99
|
-
@change = ${() => { setApiServer.call(this, server.url); }}
|
|
100
|
-
.checked = '${this.selectedServer.url === server.url}'
|
|
101
|
-
style = 'margin:4px 0; cursor:pointer'
|
|
102
|
-
/>
|
|
103
|
-
<label style='cursor:pointer' for='srvr-opt-${i}'>
|
|
104
|
-
${server.url} ${server.description ? html`- <span class='regular-font'>${server.description} </span>` : ''}
|
|
105
|
-
</label>
|
|
106
|
-
<br/>
|
|
107
|
-
`)}
|
|
108
|
-
`}
|
|
109
|
-
<div class="table-title primary-text" part="label-selected-server"> SELECTED: ${this.selectedServer?.computedUrl || 'none'}</div>
|
|
110
|
-
</div>
|
|
111
|
-
<slot name="servers"></slot>
|
|
112
|
-
${serverVarsTemplate.call(this)}
|
|
113
|
-
</section>`;
|
|
114
|
-
}
|
|
115
|
-
/* eslint-enable indent */
|
package/src/utils/color-utils.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
color: {
|
|
3
|
-
inputReverseFg: '#fff',
|
|
4
|
-
inputReverseBg: '#333',
|
|
5
|
-
headerBg: '#444',
|
|
6
|
-
getRgb(hex) {
|
|
7
|
-
if (hex.indexOf('#') === 0) {
|
|
8
|
-
hex = hex.slice(1, 7);
|
|
9
|
-
}
|
|
10
|
-
// convert 3-digit hex to 6-digits.
|
|
11
|
-
if (hex.length === 3 || hex.length === 4) {
|
|
12
|
-
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
13
|
-
}
|
|
14
|
-
if (hex.length !== 6) {
|
|
15
|
-
throw new Error('Invalid HEX color.');
|
|
16
|
-
}
|
|
17
|
-
return {
|
|
18
|
-
r: parseInt(hex.slice(0, 2), 16),
|
|
19
|
-
g: parseInt(hex.slice(2, 4), 16),
|
|
20
|
-
b: parseInt(hex.slice(4, 6), 16),
|
|
21
|
-
};
|
|
22
|
-
},
|
|
23
|
-
luminanace(hexColorCode) {
|
|
24
|
-
const rgb = this.getRgb(hexColorCode);
|
|
25
|
-
return (rgb.r * 0.299 + rgb.g * 0.587 + rgb.b * 0.114);
|
|
26
|
-
},
|
|
27
|
-
invert(hexColorCode) {
|
|
28
|
-
return this.luminanace(hexColorCode) > 135 ? '#000' : '#fff'; // compare with `>=128`, but giving little more preference to white over black
|
|
29
|
-
},
|
|
30
|
-
opacity(hex, opacity) {
|
|
31
|
-
const rgb = this.getRgb(hex);
|
|
32
|
-
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${opacity})`;
|
|
33
|
-
},
|
|
34
|
-
brightness(hex, amt) {
|
|
35
|
-
const rgb = this.getRgb(hex);
|
|
36
|
-
rgb.r += amt;
|
|
37
|
-
rgb.g += amt;
|
|
38
|
-
rgb.b += amt;
|
|
39
|
-
if (rgb.r > 255) rgb.r = 255;
|
|
40
|
-
else if (rgb.r < 0) rgb.r = 0;
|
|
41
|
-
|
|
42
|
-
if (rgb.g > 255) rgb.g = 255;
|
|
43
|
-
else if (rgb.g < 0) rgb.g = 0;
|
|
44
|
-
|
|
45
|
-
if (rgb.b > 255) rgb.b = 255;
|
|
46
|
-
else if (rgb.b < 0) rgb.b = 0;
|
|
47
|
-
return `#${rgb.r.toString(16).padStart(2, '0')}${rgb.g.toString(16).padStart(2, '0')}${rgb.b.toString(16).padStart(2, '0')}`;
|
|
48
|
-
},
|
|
49
|
-
hasGoodContrast(hexColorCode1, hexColorCode2) {
|
|
50
|
-
const lum1 = this.luminanace(hexColorCode1);
|
|
51
|
-
const lum2 = this.luminanace(hexColorCode2);
|
|
52
|
-
return (lum1 - lum2);
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export function isValidHexColor(colorCode) {
|
|
58
|
-
return /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}|[A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/i.test(colorCode);
|
|
59
|
-
}
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
/* For Delayed Event Handler Execution */
|
|
2
|
-
export function debounce(fn, delay) {
|
|
3
|
-
let timeoutID = null;
|
|
4
|
-
return (...args) => {
|
|
5
|
-
clearTimeout(timeoutID);
|
|
6
|
-
const that = this;
|
|
7
|
-
timeoutID = setTimeout(() => {
|
|
8
|
-
fn.apply(that, args);
|
|
9
|
-
}, delay);
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const invalidCharsRegEx = /[\s#:?&={}]/g; // used for generating valid html element ids by replacing the invalid chars with hyphen (-)
|
|
14
|
-
export const rapidocApiKey = '_rapidoc_api_key';
|
|
15
|
-
|
|
16
|
-
export function sleep(ms) {
|
|
17
|
-
// eslint-disable-next-line no-promise-executor-return
|
|
18
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function copyToClipboard(data, e) {
|
|
22
|
-
const btnEl = e.target;
|
|
23
|
-
const textArea = document.createElement('textarea');
|
|
24
|
-
textArea.value = data;
|
|
25
|
-
textArea.style.position = 'fixed'; // avoid scrolling to bottom
|
|
26
|
-
document.body.appendChild(textArea);
|
|
27
|
-
textArea.focus();
|
|
28
|
-
textArea.select();
|
|
29
|
-
try {
|
|
30
|
-
document.execCommand('copy');
|
|
31
|
-
btnEl.innerText = 'Copied';
|
|
32
|
-
setTimeout(() => {
|
|
33
|
-
btnEl.innerText = 'Copy';
|
|
34
|
-
}, 5000);
|
|
35
|
-
} catch (err) {
|
|
36
|
-
console.error('Unable to copy', err); // eslint-disable-line no-console
|
|
37
|
-
}
|
|
38
|
-
document.body.removeChild(textArea);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function getBaseUrlFromUrl(url) {
|
|
42
|
-
const pathArray = url.split('/');
|
|
43
|
-
return `${pathArray[0]}//${pathArray[2]}`;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export async function wait(ms) {
|
|
47
|
-
return new Promise((resolve) => {
|
|
48
|
-
setTimeout(resolve, ms);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function getMatchedComponents(searchVal, component) {
|
|
53
|
-
return component.name.toLowerCase().includes(searchVal.toLowerCase());
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function getMatchedPaths(searchVal, path, tagName = '') {
|
|
57
|
-
const stringToSearch = `${path.method} ${path.path} ${path.summary || ''} ${path.description || ''} ${path.operationId || ''} ${tagName}`.toLowerCase();
|
|
58
|
-
return stringToSearch.includes(searchVal.toLowerCase());
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function schemaKeys(schemaProps, result = new Set()) {
|
|
62
|
-
if (!schemaProps) {
|
|
63
|
-
return result;
|
|
64
|
-
}
|
|
65
|
-
Object.keys(schemaProps).forEach((key) => {
|
|
66
|
-
result.add(key);
|
|
67
|
-
if (schemaProps[key].properties) {
|
|
68
|
-
schemaKeys(schemaProps[key].properties, result);
|
|
69
|
-
} else if (schemaProps[key].items?.properties) {
|
|
70
|
-
schemaKeys(schemaProps[key].items?.properties, result);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
return result;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function advancedSearch(searchVal, allSpecTags, searchOptions = []) {
|
|
77
|
-
if (!searchVal.trim() || searchOptions.length === 0) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const pathsMatched = [];
|
|
82
|
-
allSpecTags.forEach((tag) => {
|
|
83
|
-
tag.paths.forEach((path) => {
|
|
84
|
-
let stringToSearch = '';
|
|
85
|
-
if (searchOptions.includes('search-api-path')) {
|
|
86
|
-
stringToSearch = path.path;
|
|
87
|
-
}
|
|
88
|
-
if (searchOptions.includes('search-api-descr')) {
|
|
89
|
-
stringToSearch = `${stringToSearch} ${(path.summary || '') + (path.description || '')}`;
|
|
90
|
-
}
|
|
91
|
-
if (searchOptions.includes('search-api-params')) {
|
|
92
|
-
stringToSearch = `${stringToSearch} ${path.parameters?.map((v) => v.name).join(' ') || ''}`;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (searchOptions.includes('search-api-request-body') && path.requestBody) {
|
|
96
|
-
let schemaKeySet = new Set();
|
|
97
|
-
for (const contentType in path.requestBody?.content) {
|
|
98
|
-
if (path.requestBody.content[contentType].schema?.properties) {
|
|
99
|
-
schemaKeySet = schemaKeys(path.requestBody.content[contentType].schema?.properties);
|
|
100
|
-
}
|
|
101
|
-
stringToSearch = `${stringToSearch} ${[...schemaKeySet].join(' ')}`;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (searchOptions.includes('search-api-resp-descr')) {
|
|
106
|
-
stringToSearch = `${stringToSearch} ${Object.values(path.responses).map((v) => v.description || '').join(' ')}`;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (stringToSearch.toLowerCase().includes(searchVal.trim().toLowerCase())) {
|
|
110
|
-
pathsMatched.push({
|
|
111
|
-
elementId: path.elementId,
|
|
112
|
-
method: path.method,
|
|
113
|
-
path: path.path,
|
|
114
|
-
summary: path.summary || path.description || '',
|
|
115
|
-
deprecated: path.deprecated,
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
return pathsMatched;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/*
|
|
124
|
-
export function prettyXml(sourceXmlString) {
|
|
125
|
-
const xmlDoc = new DOMParser().parseFromString(sourceXmlString, 'text/xml');
|
|
126
|
-
const xsltDoc = new DOMParser().parseFromString([
|
|
127
|
-
// describes how we want to modify the XML - indent everything
|
|
128
|
-
`<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
|
129
|
-
<xsl:strip-space elements="*"/>
|
|
130
|
-
<xsl:template match="para[content-style][not(text())]">
|
|
131
|
-
<xsl:value-of select="normalize-space(.)"/>
|
|
132
|
-
</xsl:template>
|
|
133
|
-
<xsl:template match="node()|@*">
|
|
134
|
-
<xsl:copy><xsl:apply-templates select="node()|@*"/></xsl:copy>
|
|
135
|
-
</xsl:template>
|
|
136
|
-
<xsl:output indent="yes"/>
|
|
137
|
-
</xsl:stylesheet>`,
|
|
138
|
-
].join('\n'), 'application/xml');
|
|
139
|
-
const xsltProcessor = new XSLTProcessor();
|
|
140
|
-
xsltProcessor.importStylesheet(xsltDoc);
|
|
141
|
-
const resultDoc = xsltProcessor.transformToDocument(xmlDoc);
|
|
142
|
-
return new XMLSerializer().serializeToString(resultDoc);
|
|
143
|
-
}
|
|
144
|
-
*/
|
|
145
|
-
|
|
146
|
-
export function downloadResource(url, fileName) {
|
|
147
|
-
if (url) {
|
|
148
|
-
const a = document.createElement('a');
|
|
149
|
-
document.body.appendChild(a);
|
|
150
|
-
a.style = 'display: none';
|
|
151
|
-
a.href = url;
|
|
152
|
-
a.download = fileName;
|
|
153
|
-
a.click();
|
|
154
|
-
a.remove();
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export function viewResource(url) {
|
|
159
|
-
if (url) {
|
|
160
|
-
const a = document.createElement('a');
|
|
161
|
-
document.body.appendChild(a);
|
|
162
|
-
a.style = 'display: none';
|
|
163
|
-
a.href = url;
|
|
164
|
-
a.target = '_blank';
|
|
165
|
-
a.click();
|
|
166
|
-
a.remove();
|
|
167
|
-
}
|
|
168
|
-
}
|