rapidoc 9.3.6 → 9.3.8
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/.eslintrc +9 -1
- package/dist/index.html +1010 -6
- package/dist/index.html.gz +0 -0
- package/dist/rapidoc-min.js +444 -428
- package/dist/rapidoc-min.js.LICENSE.txt +1 -8
- 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 +576 -373
- package/dist/report.html +2 -2
- package/index.html +1006 -209
- package/{index1.html → index_bak.html} +13 -6
- package/jsconfig.json +1 -1
- package/package.json +8 -8
- package/src/components/api-request.js +144 -100
- package/src/components/api-response.js +12 -13
- package/src/components/json-tree.js +1 -1
- package/src/components/schema-table.js +16 -6
- package/src/components/schema-tree.js +15 -10
- package/src/json-schema-viewer.js +7 -2
- package/src/rapidoc-mini.js +22 -4
- package/src/rapidoc.js +35 -19
- package/src/styles/border-styles.js +2 -2
- package/src/styles/endpoint-styles.js +13 -10
- package/src/styles/flex-styles.js +1 -1
- package/src/styles/font-styles.js +13 -13
- package/src/styles/input-styles.js +8 -3
- package/src/styles/nav-styles.js +1 -1
- package/src/styles/schema-styles.js +12 -9
- package/src/templates/advance-search-template.js +2 -1
- package/src/templates/callback-template.js +3 -1
- package/src/templates/code-samples-template.js +3 -3
- package/src/templates/endpoint-template.js +33 -28
- package/src/templates/expanded-endpoint-template.js +7 -3
- 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 +6 -17
- package/src/templates/navbar-template.js +6 -6
- package/src/templates/security-scheme-template.js +14 -10
- package/src/utils/common-utils.js +5 -9
- package/src/utils/schema-utils.js +65 -16
- package/src/utils/spec-parser.js +77 -7
- package/src/utils/theme.js +4 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit';
|
|
2
2
|
import { unsafeHTML } from 'lit/directives/unsafe-html.js'; // eslint-disable-line import/extensions
|
|
3
3
|
import { marked } from 'marked';
|
|
4
|
-
import { schemaInObjectNotation, generateExample } from '~/utils/schema-utils';
|
|
4
|
+
import { schemaInObjectNotation, generateExample, standardizeExample } from '~/utils/schema-utils';
|
|
5
5
|
import FontStyles from '~/styles/font-styles';
|
|
6
6
|
import FlexStyles from '~/styles/flex-styles';
|
|
7
7
|
import TableStyles from '~/styles/table-styles';
|
|
@@ -92,7 +92,7 @@ export default class ApiResponse extends LitElement {
|
|
|
92
92
|
</div>
|
|
93
93
|
<div>
|
|
94
94
|
${this.responseTemplate()}
|
|
95
|
-
|
|
95
|
+
</div>
|
|
96
96
|
</div>
|
|
97
97
|
`;
|
|
98
98
|
}
|
|
@@ -121,8 +121,8 @@ export default class ApiResponse extends LitElement {
|
|
|
121
121
|
const respExamples = generateExample(
|
|
122
122
|
mimeRespObj.schema,
|
|
123
123
|
mimeResp,
|
|
124
|
-
mimeRespObj.examples,
|
|
125
|
-
mimeRespObj.example,
|
|
124
|
+
standardizeExample(mimeRespObj.examples),
|
|
125
|
+
standardizeExample(mimeRespObj.example),
|
|
126
126
|
this.callback === 'true' || this.webhook === 'true' ? false : true, // eslint-disable-line no-unneeded-ternary
|
|
127
127
|
this.callback === 'true' || this.webhook === 'true' ? true : false, // eslint-disable-line no-unneeded-ternary
|
|
128
128
|
mimeResp.includes('json') ? 'json' : 'text',
|
|
@@ -165,10 +165,9 @@ export default class ApiResponse extends LitElement {
|
|
|
165
165
|
${respStatus}
|
|
166
166
|
</button>`
|
|
167
167
|
}`)
|
|
168
|
-
}
|
|
168
|
+
}</div>`
|
|
169
169
|
: html`<span>${Object.keys(this.responses)[0]}</span>`
|
|
170
170
|
}
|
|
171
|
-
</div>
|
|
172
171
|
|
|
173
172
|
${Object.keys(this.responses).map((status) => html`
|
|
174
173
|
<div style = 'display: ${status === this.selectedStatus ? 'block' : 'none'}' >
|
|
@@ -182,10 +181,10 @@ export default class ApiResponse extends LitElement {
|
|
|
182
181
|
${Object.keys(this.mimeResponsesForEachStatus[status]).length === 0
|
|
183
182
|
? ''
|
|
184
183
|
: html`
|
|
185
|
-
<div class="tab-panel col">
|
|
186
|
-
<div class="tab-buttons row" @click="${(e) => { if (e.target.tagName.toLowerCase() === 'button') { this.activeSchemaTab = e.target.dataset.tab; } }}" >
|
|
187
|
-
<button class="tab-btn ${this.activeSchemaTab === 'example' ? 'active' : ''}" data-tab = 'example'>EXAMPLE </button>
|
|
188
|
-
<button class="tab-btn ${this.activeSchemaTab !== 'example' ? 'active' : ''}" data-tab = 'schema' >SCHEMA</button>
|
|
184
|
+
<div part="tab-panel" class="tab-panel col">
|
|
185
|
+
<div part="tab-btn-row" class="tab-buttons row" @click="${(e) => { if (e.target.tagName.toLowerCase() === 'button') { this.activeSchemaTab = e.target.dataset.tab; } }}" >
|
|
186
|
+
<button part="tab-btn" class="tab-btn ${this.activeSchemaTab === 'example' ? 'active' : ''}" data-tab = 'example'>EXAMPLE </button>
|
|
187
|
+
<button part="tab-btn" class="tab-btn ${this.activeSchemaTab !== 'example' ? 'active' : ''}" data-tab = 'schema' >SCHEMA</button>
|
|
189
188
|
<div style="flex:1"></div>
|
|
190
189
|
${Object.keys(this.mimeResponsesForEachStatus[status]).length === 1
|
|
191
190
|
? html`<span class='small-font-size gray-text' style='align-self:center; margin-top:8px;'> ${Object.keys(this.mimeResponsesForEachStatus[status])[0]} </span>`
|
|
@@ -193,16 +192,16 @@ export default class ApiResponse extends LitElement {
|
|
|
193
192
|
}
|
|
194
193
|
</div>
|
|
195
194
|
${this.activeSchemaTab === 'example'
|
|
196
|
-
? html`<div class ='tab-content col' style = 'flex:1;'>
|
|
195
|
+
? html`<div part="tab-content" class ='tab-content col' style = 'flex:1;'>
|
|
197
196
|
${this.mimeExampleTemplate(this.mimeResponsesForEachStatus[status][this.selectedMimeType])}
|
|
198
197
|
</div>`
|
|
199
|
-
: html`<div class ='tab-content col' style = 'flex:1;'>
|
|
198
|
+
: html`<div part="tab-content" class ='tab-content col' style = 'flex:1;'>
|
|
200
199
|
${this.mimeSchemaTemplate(this.mimeResponsesForEachStatus[status][this.selectedMimeType])}
|
|
201
200
|
</div>`
|
|
202
201
|
}
|
|
203
202
|
</div>
|
|
204
203
|
`
|
|
205
|
-
}
|
|
204
|
+
}</div>`)
|
|
206
205
|
}
|
|
207
206
|
`;
|
|
208
207
|
}
|
|
@@ -102,7 +102,7 @@ export default class JsonTree extends LitElement {
|
|
|
102
102
|
|
|
103
103
|
generateTree(data, isLast = false) {
|
|
104
104
|
if (data === null) {
|
|
105
|
-
return html`<
|
|
105
|
+
return html`<span class="null">null</span>${isLast ? '' : ','}`;
|
|
106
106
|
}
|
|
107
107
|
if (typeof data === 'object' && (data instanceof Date === false)) {
|
|
108
108
|
const detailType = Array.isArray(data) ? 'array' : 'pure_object';
|
|
@@ -199,7 +199,7 @@ export default class SchemaTable extends LitElement {
|
|
|
199
199
|
${newSchemaLevel >= 0 && key
|
|
200
200
|
? html`
|
|
201
201
|
<div class='tr ${newSchemaLevel <= this.schemaExpandLevel ? 'expanded' : 'collapsed'} ${data['::type']}' data-obj='${keyLabel}' title="${isDeprecated || data['::deprecated'] ? 'Deprecated' : ''}">
|
|
202
|
-
<div class="td key ${isDeprecated || data['::deprecated'] ? 'deprecated' : ''}" style='padding-left:${leftPadding}px'>
|
|
202
|
+
<div class="td key ${(isDeprecated || data['::deprecated']) ? 'deprecated' : ''}" style='padding-left:${leftPadding}px'>
|
|
203
203
|
${(keyLabel || keyDescr)
|
|
204
204
|
? html`
|
|
205
205
|
<span class='obj-toggle ${newSchemaLevel < this.schemaExpandLevel ? 'expanded' : 'collapsed'}' data-obj='${keyLabel}'>
|
|
@@ -210,8 +210,14 @@ export default class SchemaTable extends LitElement {
|
|
|
210
210
|
${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION')
|
|
211
211
|
? html`<span class="xxx-of-key" style="margin-left:-6px">${keyLabel}</span><span class="${isOneOfLabel ? 'xxx-of-key' : 'xxx-of-descr'}">${keyDescr}</span>`
|
|
212
212
|
: keyLabel.endsWith('*')
|
|
213
|
-
? html`<span class="key-label" style="display:inline-block; margin-left:-6px;">${isDeprecated || data['::deprecated']
|
|
214
|
-
|
|
213
|
+
? html`<span class="key-label" style="display:inline-block; margin-left:-6px;">${(isDeprecated || data['::deprecated'])
|
|
214
|
+
? html`<svg viewBox="0 0 10 10" width="10" height="10" style="stroke:var(--red); margin-right:-6px"><path d="M2 2L8 8M2 8L8 2"/></svg>`
|
|
215
|
+
: ''
|
|
216
|
+
} ${keyLabel.substring(0, keyLabel.length - 1)}</span><span style='color:var(--red);'>*</span>`
|
|
217
|
+
: html`<span class="key-label" style="display:inline-block; margin-left:-6px;">${(isDeprecated || data['::deprecated'])
|
|
218
|
+
? html`<svg viewBox="0 0 10 10" width="10" height="10" style="stroke:var(--red); margin-right:-6px"><path d="M2 2L8 8M2 8L8 2"/></svg>`
|
|
219
|
+
: ''
|
|
220
|
+
} ${keyLabel === '::props' ? '' : keyLabel}</span>`
|
|
215
221
|
}
|
|
216
222
|
${data['::type'] === 'xxx-of' && dataType === 'array' ? html`<span style="color:var(--primary-color)">ARRAY</span>` : ''}
|
|
217
223
|
</div>
|
|
@@ -250,6 +256,7 @@ export default class SchemaTable extends LitElement {
|
|
|
250
256
|
newSchemaLevel,
|
|
251
257
|
newIndentLevel,
|
|
252
258
|
data[dataKey]['::readwrite'] ? data[dataKey]['::readwrite'] : '',
|
|
259
|
+
(isDeprecated || data[dataKey]['::deprecated']),
|
|
253
260
|
)}`
|
|
254
261
|
: ''
|
|
255
262
|
: html`${this.generateTree(
|
|
@@ -261,13 +268,13 @@ export default class SchemaTable extends LitElement {
|
|
|
261
268
|
newSchemaLevel,
|
|
262
269
|
newIndentLevel,
|
|
263
270
|
data[dataKey]['::readwrite'] ? data[dataKey]['::readwrite'] : '',
|
|
264
|
-
isDeprecated || data[dataKey]['::deprecated'],
|
|
271
|
+
(isDeprecated || data[dataKey]['::deprecated']),
|
|
265
272
|
)}`
|
|
266
273
|
}
|
|
267
274
|
`)}
|
|
268
275
|
`
|
|
269
276
|
}
|
|
270
|
-
|
|
277
|
+
</div>
|
|
271
278
|
`;
|
|
272
279
|
}
|
|
273
280
|
|
|
@@ -297,7 +304,10 @@ export default class SchemaTable extends LitElement {
|
|
|
297
304
|
return html`
|
|
298
305
|
<div class = "tr primitive" title="${isDeprecated || deprecated ? 'Deprecated' : ''}">
|
|
299
306
|
<div class="td key ${isDeprecated || deprecated ? 'deprecated' : ''}" style='padding-left:${leftPadding}px'>
|
|
300
|
-
${isDeprecated || deprecated
|
|
307
|
+
${isDeprecated || deprecated
|
|
308
|
+
? html`<svg viewBox="0 0 10 10" width="10" height="10" style="stroke:var(--red); margin-right:-6px"><path d="M2 2L8 8M2 8L8 2"/></svg>`
|
|
309
|
+
: ''
|
|
310
|
+
}
|
|
301
311
|
${keyLabel?.endsWith('*')
|
|
302
312
|
? html`
|
|
303
313
|
<span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span>
|
|
@@ -48,9 +48,6 @@ export default class SchemaTree extends LitElement {
|
|
|
48
48
|
.tree .key {
|
|
49
49
|
max-width: 300px;
|
|
50
50
|
}
|
|
51
|
-
.key.deprecated .key-label {
|
|
52
|
-
color: var(--red);
|
|
53
|
-
}
|
|
54
51
|
.tr.expanded:hover > .td.key > .open-bracket {
|
|
55
52
|
color: var(--primary-color);
|
|
56
53
|
}
|
|
@@ -121,7 +118,7 @@ export default class SchemaTree extends LitElement {
|
|
|
121
118
|
`;
|
|
122
119
|
}
|
|
123
120
|
|
|
124
|
-
generateTree(data, dataType = 'object', arrayType = '', key = '', description = '', schemaLevel = 0, indentLevel = 0, readOrWrite = '') {
|
|
121
|
+
generateTree(data, dataType = 'object', arrayType = '', key = '', description = '', schemaLevel = 0, indentLevel = 0, readOrWrite = '', isDeprecated = false) {
|
|
125
122
|
if (this.schemaHideReadOnly === 'true') {
|
|
126
123
|
if (dataType === 'array') {
|
|
127
124
|
if (readOrWrite === 'readonly') {
|
|
@@ -212,15 +209,18 @@ export default class SchemaTree extends LitElement {
|
|
|
212
209
|
}
|
|
213
210
|
if (typeof data === 'object') {
|
|
214
211
|
return html`
|
|
215
|
-
<div class="tr ${schemaLevel < this.schemaExpandLevel || data['::type']?.startsWith('xxx-of') ? 'expanded' : 'collapsed'} ${data['::type'] || 'no-type-info'}${data['::nullable'] ? ' nullable' : ''}" title="${data['::deprecated'] ? 'Deprecated' : ''}">
|
|
216
|
-
<div class="td key ${data['::deprecated'] ? 'deprecated' : ''}" style='min-width:${minFieldColWidth}px'>
|
|
212
|
+
<div class="tr ${schemaLevel < this.schemaExpandLevel || data['::type']?.startsWith('xxx-of') ? 'expanded' : 'collapsed'} ${data['::type'] || 'no-type-info'}${data['::nullable'] ? ' nullable' : ''}" title="${(isDeprecated || data['::deprecated']) ? 'Deprecated' : ''}">
|
|
213
|
+
<div class="td key ${(isDeprecated || data['::deprecated']) ? 'deprecated' : ''}" style='min-width:${minFieldColWidth}px'>
|
|
217
214
|
${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION')
|
|
218
215
|
? html`<span class='key-label xxx-of-key'> ${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>`
|
|
219
216
|
: keyLabel === '::props' || keyLabel === '::ARRAY~OF'
|
|
220
217
|
? ''
|
|
221
218
|
: schemaLevel > 0
|
|
222
219
|
? html`<span class="key-label" title="${readOrWrite === 'readonly' ? 'Read-Only' : readOrWrite === 'writeonly' ? 'Write-Only' : ''}">
|
|
223
|
-
${data['::deprecated']
|
|
220
|
+
${(isDeprecated || data['::deprecated'])
|
|
221
|
+
? html`<svg viewBox="0 0 10 10" width="10" height="10" style="stroke:var(--red); margin-right:-6px"><path d="M2 2L8 8M2 8L8 2"/></svg>`
|
|
222
|
+
: ''
|
|
223
|
+
}
|
|
224
224
|
${keyLabel.replace(/\*$/, '')}${keyLabel.endsWith('*') ? html`<span style="color:var(--red)">*</span>` : ''}${readOrWrite === 'readonly' ? html` 🆁` : readOrWrite === 'writeonly' ? html` 🆆` : readOrWrite}:
|
|
225
225
|
</span>`
|
|
226
226
|
: ''
|
|
@@ -231,7 +231,7 @@ export default class SchemaTree extends LitElement {
|
|
|
231
231
|
</div>
|
|
232
232
|
<div class='inside-bracket ${data['::type'] || 'no-type-info'}' style='padding-left:${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' ? 0 : leftPadding}px;'>
|
|
233
233
|
${Array.isArray(data) && data[0]
|
|
234
|
-
? html`${this.generateTree(data[0], 'xxx-of-option', '', '::ARRAY~OF', '', newSchemaLevel, newIndentLevel, data[0]['::readwrite'])}`
|
|
234
|
+
? html`${this.generateTree(data[0], 'xxx-of-option', '', '::ARRAY~OF', '', newSchemaLevel, newIndentLevel, data[0]['::readwrite'], (isDeprecated || data[0]['::deprecated']))}`
|
|
235
235
|
: html`
|
|
236
236
|
${Object.keys(data).map((dataKey) => html`
|
|
237
237
|
${['::title', '::description', '::type', '::props', '::deprecated', '::array-type', '::readwrite', '::dataTypeLabel', '::nullable'].includes(dataKey)
|
|
@@ -245,6 +245,7 @@ export default class SchemaTree extends LitElement {
|
|
|
245
245
|
newSchemaLevel,
|
|
246
246
|
newIndentLevel,
|
|
247
247
|
data[dataKey]['::readwrite'] ? data[dataKey]['::readwrite'] : '',
|
|
248
|
+
(isDeprecated || data[dataKey]['::deprecated']),
|
|
248
249
|
)}`
|
|
249
250
|
: ''
|
|
250
251
|
: html`${this.generateTree(
|
|
@@ -256,6 +257,7 @@ export default class SchemaTree extends LitElement {
|
|
|
256
257
|
newSchemaLevel,
|
|
257
258
|
newIndentLevel,
|
|
258
259
|
data[dataKey]['::readwrite'] ? data[dataKey]['::readwrite'] : '',
|
|
260
|
+
(isDeprecated || data[dataKey]['::deprecated']),
|
|
259
261
|
)}`
|
|
260
262
|
}
|
|
261
263
|
`)}
|
|
@@ -300,8 +302,11 @@ export default class SchemaTree extends LitElement {
|
|
|
300
302
|
|
|
301
303
|
return html`
|
|
302
304
|
<div class = "tr primitive" title="${deprecated ? 'Deprecated' : ''}">
|
|
303
|
-
<div class="td key ${deprecated}" style='min-width:${minFieldColWidth}px'>
|
|
304
|
-
${
|
|
305
|
+
<div class="td key ${isDeprecated || deprecated}" style='min-width:${minFieldColWidth}px'>
|
|
306
|
+
${isDeprecated || deprecated
|
|
307
|
+
? html`<svg viewBox="0 0 10 10" width="10" height="10" style="stroke:var(--red); margin-right:-6px"><path d="M2 2L8 8M2 8L8 2"/></svg>`
|
|
308
|
+
: ''
|
|
309
|
+
}
|
|
305
310
|
${keyLabel.endsWith('*')
|
|
306
311
|
? html`<span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span><span style='color:var(--red);'>*</span>:`
|
|
307
312
|
: key.startsWith('::OPTION')
|
|
@@ -86,6 +86,7 @@ export default class JsonSchemaViewer extends LitElement {
|
|
|
86
86
|
InfoStyles,
|
|
87
87
|
css`
|
|
88
88
|
:host {
|
|
89
|
+
all: initial;
|
|
89
90
|
display:flex;
|
|
90
91
|
flex-direction: column;
|
|
91
92
|
min-width:360px;
|
|
@@ -98,6 +99,7 @@ export default class JsonSchemaViewer extends LitElement {
|
|
|
98
99
|
color:var(--fg);
|
|
99
100
|
background-color:var(--bg);
|
|
100
101
|
font-family:var(--font-regular);
|
|
102
|
+
container-type: inline-size;
|
|
101
103
|
}
|
|
102
104
|
.body {
|
|
103
105
|
display:flex;
|
|
@@ -163,11 +165,11 @@ export default class JsonSchemaViewer extends LitElement {
|
|
|
163
165
|
height: 36px;
|
|
164
166
|
animation: spin 2s linear infinite;
|
|
165
167
|
}
|
|
166
|
-
@
|
|
168
|
+
@container (min-width: 768px) {
|
|
167
169
|
.only-large-screen{
|
|
168
170
|
display:block;
|
|
169
171
|
}
|
|
170
|
-
.only-large-screen-flex{
|
|
172
|
+
.only-large-screen-flex {
|
|
171
173
|
display:flex;
|
|
172
174
|
}
|
|
173
175
|
}`,
|
|
@@ -289,6 +291,9 @@ export default class JsonSchemaViewer extends LitElement {
|
|
|
289
291
|
this.sortTags === 'true',
|
|
290
292
|
this.sortSchemas === 'true',
|
|
291
293
|
this.getAttribute('sort-endpoints-by'),
|
|
294
|
+
this.getAttribute('match-paths'),
|
|
295
|
+
this.getAttribute('match-type'),
|
|
296
|
+
this.getAttribute('remove-endpoints-with-badge-label-as'),
|
|
292
297
|
);
|
|
293
298
|
this.loading = false;
|
|
294
299
|
this.afterSpecParsedAndValidated(spec);
|
package/src/rapidoc-mini.js
CHANGED
|
@@ -67,6 +67,7 @@ export default class RapiDocMini extends LitElement {
|
|
|
67
67
|
oauthReceiver: { type: String, attribute: 'oauth-receiver' },
|
|
68
68
|
|
|
69
69
|
allowTry: { type: String, attribute: 'allow-try' },
|
|
70
|
+
showCurlBeforeTry: { type: String, attribute: 'show-curl-before-try' },
|
|
70
71
|
|
|
71
72
|
// Main Colors and Font
|
|
72
73
|
theme: { type: String },
|
|
@@ -84,6 +85,7 @@ export default class RapiDocMini extends LitElement {
|
|
|
84
85
|
// Filters
|
|
85
86
|
matchPaths: { type: String, attribute: 'match-paths' },
|
|
86
87
|
matchType: { type: String, attribute: 'match-type' },
|
|
88
|
+
removeEndpointsWithBadgeLabelAs: { type: String, attribute: 'remove-endpoints-with-badge-label-as' },
|
|
87
89
|
|
|
88
90
|
// Internal Properties
|
|
89
91
|
loading: { type: Boolean }, // indicates spec is being loaded
|
|
@@ -103,6 +105,7 @@ export default class RapiDocMini extends LitElement {
|
|
|
103
105
|
InfoStyles,
|
|
104
106
|
css`
|
|
105
107
|
:host {
|
|
108
|
+
all: initial;
|
|
106
109
|
display:flex;
|
|
107
110
|
flex-direction: column;
|
|
108
111
|
min-width:360px;
|
|
@@ -115,13 +118,14 @@ export default class RapiDocMini extends LitElement {
|
|
|
115
118
|
color:var(--fg);
|
|
116
119
|
background-color:var(--bg);
|
|
117
120
|
font-family:var(--font-regular);
|
|
121
|
+
container-type: inline-size;
|
|
118
122
|
}
|
|
119
123
|
|
|
120
|
-
@
|
|
121
|
-
.only-large-screen{
|
|
124
|
+
@container (min-width: 768px) {
|
|
125
|
+
.only-large-screen {
|
|
122
126
|
display:block;
|
|
123
127
|
}
|
|
124
|
-
.only-large-screen-flex{
|
|
128
|
+
.only-large-screen-flex {
|
|
125
129
|
display:flex;
|
|
126
130
|
}
|
|
127
131
|
}`,
|
|
@@ -181,7 +185,10 @@ export default class RapiDocMini extends LitElement {
|
|
|
181
185
|
if (!this.sortTags || !'true, false,'.includes(`${this.sortTags},`)) { this.sortTags = 'false'; }
|
|
182
186
|
if (!this.sortEndpointsBy || !'method, path, summary,'.includes(`${this.sortEndpointsBy},`)) { this.sortEndpointsBy = 'path'; }
|
|
183
187
|
if (!this.fontSize || !'default, large, largest,'.includes(`${this.fontSize},`)) { this.fontSize = 'default'; }
|
|
188
|
+
|
|
184
189
|
if (!this.matchType || !'includes regex'.includes(this.matchType)) { this.matchType = 'includes'; }
|
|
190
|
+
if (!this.matchPaths) { this.matchPaths = ''; }
|
|
191
|
+
if (!this.removeEndpointsWithBadgeLabelAs) { this.removeEndpointsWithBadgeLabelAs = ''; }
|
|
185
192
|
|
|
186
193
|
if (!this.allowSchemaDescriptionExpandToggle || !'true, false,'.includes(`${this.allowSchemaDescriptionExpandToggle},`)) { this.allowSchemaDescriptionExpandToggle = 'true'; }
|
|
187
194
|
if (!this.fetchCredentials || !'omit, same-origin, include,'.includes(`${this.fetchCredentials},`)) { this.fetchCredentials = ''; }
|
|
@@ -197,7 +204,7 @@ export default class RapiDocMini extends LitElement {
|
|
|
197
204
|
}
|
|
198
205
|
|
|
199
206
|
render() {
|
|
200
|
-
return mainBodyTemplate.call(this, true,
|
|
207
|
+
return mainBodyTemplate.call(this, true, this.pathsExpanded);
|
|
201
208
|
}
|
|
202
209
|
|
|
203
210
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
@@ -209,6 +216,13 @@ export default class RapiDocMini extends LitElement {
|
|
|
209
216
|
}, 0);
|
|
210
217
|
}
|
|
211
218
|
}
|
|
219
|
+
if (name === 'match-paths' || name === 'match-type' || name === 'remove-endpoints-with-badge-label-as') {
|
|
220
|
+
if (oldVal !== newVal) {
|
|
221
|
+
window.setTimeout(async () => {
|
|
222
|
+
await this.loadSpec(this.specUrl);
|
|
223
|
+
}, 0);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
212
226
|
if (name === 'api-key-name' || name === 'api-key-location' || name === 'api-key-value') {
|
|
213
227
|
let updateSelectedApiKey = false;
|
|
214
228
|
let apiKeyName = '';
|
|
@@ -287,11 +301,15 @@ export default class RapiDocMini extends LitElement {
|
|
|
287
301
|
specUrl,
|
|
288
302
|
this.generateMissingTags === 'true',
|
|
289
303
|
this.sortTags === 'true',
|
|
304
|
+
this.sortSchemas === 'true',
|
|
290
305
|
this.getAttribute('sort-endpoints-by'),
|
|
291
306
|
this.getAttribute('api-key-name'),
|
|
292
307
|
this.getAttribute('api-key-location'),
|
|
293
308
|
this.getAttribute('api-key-value'),
|
|
294
309
|
this.getAttribute('server-url'),
|
|
310
|
+
this.matchPaths,
|
|
311
|
+
this.matchType,
|
|
312
|
+
this.removeEndpointsWithBadgeLabelAs,
|
|
295
313
|
);
|
|
296
314
|
this.loading = false;
|
|
297
315
|
this.afterSpecParsedAndValidated(spec);
|
package/src/rapidoc.js
CHANGED
|
@@ -23,7 +23,7 @@ import NavStyles from '~/styles/nav-styles';
|
|
|
23
23
|
import InfoStyles from '~/styles/info-styles';
|
|
24
24
|
import CustomStyles from '~/styles/custom-styles';
|
|
25
25
|
// import { expandCollapseNavBarTag } from '@/templates/navbar-template';
|
|
26
|
-
import { advancedSearch,
|
|
26
|
+
import { advancedSearch, getMatchedPaths, getMatchedComponents, rapidocApiKey, sleep } from '~/utils/common-utils';
|
|
27
27
|
import ProcessSpec from '~/utils/spec-parser';
|
|
28
28
|
import mainBodyTemplate from '~/templates/main-body-template';
|
|
29
29
|
import { applyApiKey, onClearAllApiKeys } from '~/templates/security-scheme-template';
|
|
@@ -134,12 +134,14 @@ export default class RapiDoc extends LitElement {
|
|
|
134
134
|
// Filters
|
|
135
135
|
matchPaths: { type: String, attribute: 'match-paths' },
|
|
136
136
|
matchType: { type: String, attribute: 'match-type' },
|
|
137
|
+
removeEndpointsWithBadgeLabelAs: { type: String, attribute: 'remove-endpoints-with-badge-label-as' },
|
|
137
138
|
|
|
138
139
|
// Internal Properties
|
|
139
140
|
loading: { type: Boolean }, // indicates spec is being loaded
|
|
140
141
|
focusedElementId: { type: String }, // updating the focusedElementId will automatically render appropriate section in focused mode
|
|
141
142
|
showAdvancedSearchDialog: { type: Boolean },
|
|
142
143
|
advancedSearchMatches: { type: Object },
|
|
144
|
+
searchVal: { type: String },
|
|
143
145
|
};
|
|
144
146
|
}
|
|
145
147
|
|
|
@@ -156,6 +158,7 @@ export default class RapiDoc extends LitElement {
|
|
|
156
158
|
InfoStyles,
|
|
157
159
|
css`
|
|
158
160
|
:host {
|
|
161
|
+
all: initial;
|
|
159
162
|
display:flex;
|
|
160
163
|
flex-direction: column;
|
|
161
164
|
min-width:360px;
|
|
@@ -168,10 +171,11 @@ export default class RapiDoc extends LitElement {
|
|
|
168
171
|
color:var(--fg);
|
|
169
172
|
background-color:var(--bg);
|
|
170
173
|
font-family:var(--font-regular);
|
|
174
|
+
container-type: inline-size;
|
|
171
175
|
}
|
|
172
176
|
:where(button, input[type="checkbox"], [tabindex="0"]):focus-visible { box-shadow: var(--focus-shadow); }
|
|
173
177
|
:where(input[type="text"], input[type="password"], select, textarea):focus-visible { border-color: var(--primary-color); }
|
|
174
|
-
|
|
178
|
+
.body {
|
|
175
179
|
display:flex;
|
|
176
180
|
height:100%;
|
|
177
181
|
width:100%;
|
|
@@ -216,11 +220,11 @@ export default class RapiDoc extends LitElement {
|
|
|
216
220
|
cursor: n-resize;
|
|
217
221
|
padding: 12px 0;
|
|
218
222
|
}
|
|
219
|
-
.collapsed .section-tag-header:hover{
|
|
223
|
+
.collapsed .section-tag-header:hover {
|
|
220
224
|
cursor: s-resize;
|
|
221
225
|
}
|
|
222
226
|
|
|
223
|
-
.section-tag-header:hover{
|
|
227
|
+
.section-tag-header:hover {
|
|
224
228
|
background-image: linear-gradient(to right, rgba(0,0,0,0), var(--border-color), rgba(0,0,0,0));
|
|
225
229
|
}
|
|
226
230
|
|
|
@@ -255,7 +259,7 @@ export default class RapiDoc extends LitElement {
|
|
|
255
259
|
margin-left:5px;
|
|
256
260
|
}
|
|
257
261
|
.only-large-screen-flex,
|
|
258
|
-
.only-large-screen{
|
|
262
|
+
.only-large-screen {
|
|
259
263
|
display:none;
|
|
260
264
|
}
|
|
261
265
|
.tag.title {
|
|
@@ -375,15 +379,15 @@ export default class RapiDoc extends LitElement {
|
|
|
375
379
|
background-color: var(--yellow);
|
|
376
380
|
}
|
|
377
381
|
|
|
378
|
-
@
|
|
382
|
+
@container (min-width: 768px) {
|
|
379
383
|
.nav-bar {
|
|
380
384
|
width: 260px;
|
|
381
385
|
display:flex;
|
|
382
386
|
}
|
|
383
|
-
.only-large-screen{
|
|
387
|
+
.only-large-screen {
|
|
384
388
|
display:block;
|
|
385
389
|
}
|
|
386
|
-
.only-large-screen-flex{
|
|
390
|
+
.only-large-screen-flex {
|
|
387
391
|
display:flex;
|
|
388
392
|
}
|
|
389
393
|
.section-gap {
|
|
@@ -401,7 +405,7 @@ export default class RapiDoc extends LitElement {
|
|
|
401
405
|
}
|
|
402
406
|
}
|
|
403
407
|
|
|
404
|
-
@
|
|
408
|
+
@container (min-width: 1024px) {
|
|
405
409
|
.nav-bar {
|
|
406
410
|
width: ${unsafeCSS(this.fontSize === 'default' ? '300px' : this.fontSize === 'large' ? '315px' : '330px')};
|
|
407
411
|
display:flex;
|
|
@@ -513,9 +517,11 @@ export default class RapiDoc extends LitElement {
|
|
|
513
517
|
if (!this.showComponents || !'true false'.includes(this.showComponents)) { this.showComponents = 'false'; }
|
|
514
518
|
if (!this.infoDescriptionHeadingsInNavBar || !'true, false,'.includes(`${this.infoDescriptionHeadingsInNavBar},`)) { this.infoDescriptionHeadingsInNavBar = 'false'; }
|
|
515
519
|
if (!this.fetchCredentials || !'omit, same-origin, include,'.includes(`${this.fetchCredentials},`)) { this.fetchCredentials = ''; }
|
|
516
|
-
if (!this.matchType || !'includes regex'.includes(this.matchType)) { this.matchType = 'includes'; }
|
|
517
520
|
if (!this.scrollBehavior || !'smooth, auto,'.includes(`${this.scrollBehavior},`)) { this.scrollBehavior = 'auto'; }
|
|
518
521
|
|
|
522
|
+
if (!this.matchType || !'includes regex'.includes(this.matchType)) { this.matchType = 'includes'; }
|
|
523
|
+
if (!this.matchPaths) { this.matchPaths = ''; }
|
|
524
|
+
if (!this.removeEndpointsWithBadgeLabelAs) { this.removeEndpointsWithBadgeLabelAs = ''; }
|
|
519
525
|
if (!this.showAdvancedSearchDialog) { this.showAdvancedSearchDialog = false; }
|
|
520
526
|
|
|
521
527
|
if (!this.cssFile) { this.cssFile = null; }
|
|
@@ -580,6 +586,13 @@ export default class RapiDoc extends LitElement {
|
|
|
580
586
|
}, 0);
|
|
581
587
|
}
|
|
582
588
|
}
|
|
589
|
+
if (name === 'match-paths' || name === 'match-type' || name === 'remove-endpoints-with-badge-label-as') {
|
|
590
|
+
if (oldVal !== newVal) {
|
|
591
|
+
window.setTimeout(async () => {
|
|
592
|
+
await this.loadSpec(this.specUrl);
|
|
593
|
+
}, 0);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
583
596
|
if (name === 'render-style') {
|
|
584
597
|
if (newVal === 'read') {
|
|
585
598
|
window.setTimeout(() => {
|
|
@@ -657,7 +670,7 @@ export default class RapiDoc extends LitElement {
|
|
|
657
670
|
const specObj = JSON.parse(reader.result);
|
|
658
671
|
this.loadSpec(specObj);
|
|
659
672
|
this.shadowRoot.getElementById('spec-url').value = '';
|
|
660
|
-
} catch
|
|
673
|
+
} catch {
|
|
661
674
|
console.error('RapiDoc: Unable to read or parse json'); // eslint-disable-line no-console
|
|
662
675
|
}
|
|
663
676
|
};
|
|
@@ -670,18 +683,18 @@ export default class RapiDoc extends LitElement {
|
|
|
670
683
|
}
|
|
671
684
|
|
|
672
685
|
onSearchChange(e) {
|
|
673
|
-
this.matchPaths = e.target.value;
|
|
674
|
-
this.
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
if (
|
|
686
|
+
// this.matchPaths = e.target.value;
|
|
687
|
+
this.searchVal = e.target.value;
|
|
688
|
+
this.resolvedSpec.tags.forEach((tag) => tag.paths.filter((path) => {
|
|
689
|
+
if (this.searchVal) {
|
|
690
|
+
if (getMatchedPaths(this.searchVal, path, tag.name)) {
|
|
678
691
|
tag.expanded = true;
|
|
679
692
|
}
|
|
680
693
|
}
|
|
681
694
|
}));
|
|
682
695
|
this.resolvedSpec.components.forEach((component) => component.subComponents.filter((v) => {
|
|
683
696
|
v.expanded = false;
|
|
684
|
-
if (
|
|
697
|
+
if (getMatchedComponents(this.searchVal, v)) {
|
|
685
698
|
v.expanded = true;
|
|
686
699
|
}
|
|
687
700
|
}));
|
|
@@ -691,7 +704,7 @@ export default class RapiDoc extends LitElement {
|
|
|
691
704
|
onClearSearch() {
|
|
692
705
|
const searchEl = this.shadowRoot.getElementById('nav-bar-search');
|
|
693
706
|
searchEl.value = '';
|
|
694
|
-
this.
|
|
707
|
+
this.searchVal = '';
|
|
695
708
|
this.resolvedSpec.components.forEach((component) => component.subComponents.filter((v) => {
|
|
696
709
|
v.expanded = true;
|
|
697
710
|
}));
|
|
@@ -716,7 +729,7 @@ export default class RapiDoc extends LitElement {
|
|
|
716
729
|
if (!specUrl) {
|
|
717
730
|
return;
|
|
718
731
|
}
|
|
719
|
-
this.
|
|
732
|
+
this.searchVal = '';
|
|
720
733
|
try {
|
|
721
734
|
this.resolvedSpec = {
|
|
722
735
|
specLoadError: false,
|
|
@@ -736,6 +749,9 @@ export default class RapiDoc extends LitElement {
|
|
|
736
749
|
this.getAttribute('api-key-location'),
|
|
737
750
|
this.getAttribute('api-key-value'),
|
|
738
751
|
this.getAttribute('server-url'),
|
|
752
|
+
this.matchPaths,
|
|
753
|
+
this.matchType,
|
|
754
|
+
this.removeEndpointsWithBadgeLabelAs,
|
|
739
755
|
);
|
|
740
756
|
this.loading = false;
|
|
741
757
|
this.afterSpecParsedAndValidated(spec);
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { css } from 'lit';
|
|
2
2
|
|
|
3
3
|
export default css`
|
|
4
|
+
:host {
|
|
5
|
+
container-type: inline-size;
|
|
6
|
+
}
|
|
4
7
|
.only-large-screen { display:none; }
|
|
5
|
-
.endpoint-head .path{
|
|
8
|
+
.endpoint-head .path {
|
|
6
9
|
display: flex;
|
|
7
10
|
font-family:var(--font-mono);
|
|
8
11
|
font-size: var(--font-size-small);
|
|
@@ -21,7 +24,7 @@ export default css`
|
|
|
21
24
|
display:none;
|
|
22
25
|
}
|
|
23
26
|
|
|
24
|
-
.m-endpoint.expanded{margin-bottom:16px; }
|
|
27
|
+
.m-endpoint.expanded { margin-bottom:16px; }
|
|
25
28
|
.m-endpoint > .endpoint-head{
|
|
26
29
|
border-width:1px 1px 1px 5px;
|
|
27
30
|
border-style:solid;
|
|
@@ -33,7 +36,7 @@ export default css`
|
|
|
33
36
|
cursor: pointer;
|
|
34
37
|
}
|
|
35
38
|
.m-endpoint > .endpoint-head.put:hover,
|
|
36
|
-
.m-endpoint > .endpoint-head.put.expanded{
|
|
39
|
+
.m-endpoint > .endpoint-head.put.expanded {
|
|
37
40
|
border-color:var(--orange);
|
|
38
41
|
background-color:var(--light-orange);
|
|
39
42
|
}
|
|
@@ -78,20 +81,20 @@ export default css`
|
|
|
78
81
|
}
|
|
79
82
|
.m-endpoint .endpoint-body.delete{ border-color:var(--red); }
|
|
80
83
|
.m-endpoint .endpoint-body.put{ border-color:var(--orange); }
|
|
81
|
-
.m-endpoint .endpoint-body.post{border-color:var(--green);}
|
|
82
|
-
.m-endpoint .endpoint-body.get{ border-color:var(--blue); }
|
|
84
|
+
.m-endpoint .endpoint-body.post { border-color:var(--green); }
|
|
85
|
+
.m-endpoint .endpoint-body.get { border-color:var(--blue); }
|
|
83
86
|
.m-endpoint .endpoint-body.head,
|
|
84
87
|
.m-endpoint .endpoint-body.patch,
|
|
85
88
|
.m-endpoint .endpoint-body.options {
|
|
86
89
|
border-color:var(--yellow);
|
|
87
90
|
}
|
|
88
91
|
|
|
89
|
-
.m-endpoint .endpoint-body.deprecated{
|
|
92
|
+
.m-endpoint .endpoint-body.deprecated {
|
|
90
93
|
border-color:var(--border-color);
|
|
91
94
|
filter:opacity(0.6);
|
|
92
95
|
}
|
|
93
96
|
|
|
94
|
-
.endpoint-head .deprecated{
|
|
97
|
+
.endpoint-head .deprecated {
|
|
95
98
|
color: var(--light-fg);
|
|
96
99
|
filter:opacity(0.6);
|
|
97
100
|
}
|
|
@@ -99,13 +102,13 @@ export default css`
|
|
|
99
102
|
.summary{
|
|
100
103
|
padding:8px 8px;
|
|
101
104
|
}
|
|
102
|
-
.summary .title{
|
|
105
|
+
.summary .title {
|
|
103
106
|
font-size:calc(var(--font-size-regular) + 2px);
|
|
104
107
|
margin-bottom: 6px;
|
|
105
108
|
word-break: break-all;
|
|
106
109
|
}
|
|
107
110
|
|
|
108
|
-
.endpoint-head .method{
|
|
111
|
+
.endpoint-head .method {
|
|
109
112
|
padding:2px 5px;
|
|
110
113
|
vertical-align: middle;
|
|
111
114
|
font-size:var(--font-size-small);
|
|
@@ -169,7 +172,7 @@ api-response.view-mode {
|
|
|
169
172
|
border-color:var(--red);
|
|
170
173
|
}
|
|
171
174
|
|
|
172
|
-
@
|
|
175
|
+
@container (min-width: 1024px) {
|
|
173
176
|
.only-large-screen { display:block; }
|
|
174
177
|
.endpoint-head .path{
|
|
175
178
|
font-size: var(--font-size-regular);
|