rapidoc 9.2.0 → 9.3.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/.github/FUNDING.yml +13 -0
- package/CONTRIBUTING.md +1 -1
- package/README.md +13 -6
- package/index.html +6 -4
- package/package.json +15 -14
- package/src/components/api-request.js +44 -29
- package/src/components/api-response.js +5 -4
- package/src/components/json-tree.js +13 -2
- package/src/components/schema-table.js +37 -15
- package/src/components/schema-tree.js +40 -11
- package/src/json-schema-viewer.js +1 -1
- package/src/rapidoc-mini.js +25 -0
- package/src/rapidoc.js +39 -1
- package/src/styles/endpoint-styles.js +9 -9
- package/src/styles/nav-styles.js +3 -1
- package/src/styles/schema-styles.js +3 -1
- package/src/styles/tab-styles.js +1 -0
- package/src/templates/callback-template.js +8 -3
- package/src/templates/components-template.js +2 -0
- package/src/templates/endpoint-template.js +19 -15
- package/src/templates/expanded-endpoint-template.js +75 -71
- package/src/templates/header-template.js +1 -1
- package/src/templates/json-schema-viewer-template.js +1 -1
- package/src/templates/main-body-template.js +1 -1
- package/src/templates/navbar-template.js +21 -8
- package/src/templates/overview-template.js +1 -1
- package/src/templates/security-scheme-template.js +30 -20
- package/src/templates/server-template.js +2 -2
- package/src/utils/schema-utils.js +34 -22
- package/src/utils/spec-parser.js +1 -1
- package/src/utils/theme.js +11 -4
- package/webpack.config.js +1 -1
- package/.vscode/settings.json +0 -12
- package/dist/index.html +0 -6
- package/dist/index.html.gz +0 -0
- package/dist/rapidoc-min.js +0 -3670
- package/dist/rapidoc-min.js.LICENSE.txt +0 -68
- 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 -43041
- package/dist/report.html +0 -38
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# These are supported funding model platforms
|
|
2
|
+
|
|
3
|
+
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
|
4
|
+
patreon: # Replace with a single Patreon username
|
|
5
|
+
open_collective: rapidoc
|
|
6
|
+
ko_fi: # Replace with a single Ko-fi username
|
|
7
|
+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
|
8
|
+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
|
9
|
+
liberapay: # Replace with a single Liberapay username
|
|
10
|
+
issuehunt: # Replace with a single IssueHunt username
|
|
11
|
+
otechie: # Replace with a single Otechie username
|
|
12
|
+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
|
13
|
+
custom: ['paypal.me/mrin'] # Replace with up to 4 custom sponsorship URLs e.g.,
|
package/CONTRIBUTING.md
CHANGED
package/README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
<img alt="MrinDoc logo" src="https://github.com/
|
|
1
|
+
<img alt="MrinDoc logo" src="https://github.com/rapi-doc/RapiDoc/blob/master/logo.png" width="60px" />
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
<p align="center">
|
|
5
5
|
<img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square"/>
|
|
6
|
-
<img src="https://img.shields.io/github/size/
|
|
7
|
-
<img src="https://img.shields.io/github/size/
|
|
6
|
+
<img src="https://img.shields.io/github/size/rapi-doc/rapidoc/dist/rapidoc-min.js.svg?colorB=blue&label=minified&style=flat-square">
|
|
7
|
+
<img src="https://img.shields.io/github/size/rapi-doc/rapidoc/dist/rapidoc-min.js.gz.svg?colorB=blue&label=zip&style=flat-square">
|
|
8
|
+
<a href="https://discord.gg/X9evUeFY" alt="Join us on Discord">
|
|
9
|
+
<img src="https://img.shields.io/discord/848913990360629268?style=flat-square" />
|
|
10
|
+
</a>
|
|
8
11
|
<a href="https://www.webcomponents.org/element/rapidoc" alt="published on webcomponents.org">
|
|
9
12
|
<img src="https://img.shields.io/badge/webcomponents.org-rapidoc-blue.svg?style=social"/>
|
|
10
13
|
</a>
|
|
@@ -13,6 +16,10 @@
|
|
|
13
16
|
# RapiDoc
|
|
14
17
|
Custom Element for Open-API spec viewing
|
|
15
18
|
|
|
19
|
+
Join the [RapiDoc community on Discord](https://discord.gg/X9evUeFY)
|
|
20
|
+
|
|
21
|
+
Sponsored by [Zuplo](https://zuplo.link/rapidoc-2) - Get a Stripe-like API experience for your customers in minutes - documentation, rate-limiting and API-key auth in minutes.
|
|
22
|
+
|
|
16
23
|
## Features
|
|
17
24
|
- Supports Swagger 2.0, OpenAPI 3.x.x
|
|
18
25
|
- Works with any framework or with no framework
|
|
@@ -42,10 +49,10 @@ Custom Element for Open-API spec viewing
|
|
|
42
49
|
|
|
43
50
|
|
|
44
51
|
## Documentation
|
|
45
|
-
[Check out the usage and demos](https://
|
|
52
|
+
[Check out the usage and demos](https://rapi-doc.github.io/RapiDoc/)
|
|
46
53
|
|
|
47
54
|
## Examples
|
|
48
|
-
[Examples and Test cases](https://
|
|
55
|
+
[Examples and Test cases](https://rapi-doc.github.io/RapiDoc/list.html)
|
|
49
56
|
|
|
50
57
|
|
|
51
58
|
## Build Process
|
|
@@ -62,7 +69,7 @@ npm run serve
|
|
|
62
69
|
```
|
|
63
70
|
|
|
64
71
|
## Roadmap
|
|
65
|
-
- Upgrade to use `lit 2`
|
|
72
|
+
- ✅ Upgrade to use `lit 2`
|
|
66
73
|
- Pre Rendering / Server Side Rendering (SSR) of RapiDoc
|
|
67
74
|
- Improve PDF generation of OpenAPI spec Using RapiPDF
|
|
68
75
|
- Create a Command Line interface (CLI) to make it automation friendly
|
package/index.html
CHANGED
|
@@ -28,24 +28,26 @@
|
|
|
28
28
|
https://assets.zuora.com/zuora-documentation/swagger.yaml <<< Large spec with lot of markdown
|
|
29
29
|
./specs/petstore_anyof.yaml <<< contains complex one-of with inline primitives and recursive objects
|
|
30
30
|
./specs/oneof1.yaml <<< nested oneof
|
|
31
|
+
https://cesdev.eng.sonicwall.com/api/q/openapi
|
|
31
32
|
-->
|
|
32
33
|
<rapi-doc
|
|
33
|
-
spec-url = "./specs/
|
|
34
|
+
spec-url = "./specs/data-types.yaml"
|
|
34
35
|
id="thedoc"
|
|
35
36
|
theme = "dark"
|
|
36
37
|
render-style="read"
|
|
37
|
-
schema-style="
|
|
38
|
-
|
|
38
|
+
schema-style="table"
|
|
39
|
+
show-method-in-nav-bar = "true"
|
|
40
|
+
use-path-in-nav-bar = "true"
|
|
39
41
|
show-components = "true"
|
|
40
42
|
show-info = "true"
|
|
41
43
|
show-header = "true"
|
|
42
44
|
allow-search = "false"
|
|
43
45
|
allow-advanced-search = "true"
|
|
44
46
|
allow-spec-url-load="false"
|
|
45
|
-
allow-spec-file-load="false"
|
|
46
47
|
allow-spec-file-download="true"
|
|
47
48
|
allow-server-selection = "true"
|
|
48
49
|
allow-authentication = "true"
|
|
50
|
+
use-summary-to-list-example = "true"
|
|
49
51
|
update-route="false"
|
|
50
52
|
match-type="regex"
|
|
51
53
|
persist-auth="true"
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rapidoc",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.3.0",
|
|
4
4
|
"description": "RapiDoc - Open API spec viewer with built in console",
|
|
5
5
|
"author": "Mrinmoy Majumdar <mrin9@yahoo.com>",
|
|
6
|
+
"homepage": "https://rapidocweb.com",
|
|
6
7
|
"repository": {
|
|
7
8
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/
|
|
9
|
+
"url": "https://github.com/rapi-doc/RapiDoc.git"
|
|
9
10
|
},
|
|
10
11
|
"license": "MIT",
|
|
11
12
|
"keywords": [
|
|
@@ -35,9 +36,9 @@
|
|
|
35
36
|
"@apitools/openapi-parser": "^0.0.24",
|
|
36
37
|
"base64-arraybuffer": "^1.0.2",
|
|
37
38
|
"buffer": "^6.0.3",
|
|
38
|
-
"lit": "^2.2.
|
|
39
|
-
"marked": "^4.0.
|
|
40
|
-
"prismjs": "^1.
|
|
39
|
+
"lit": "^2.2.4",
|
|
40
|
+
"marked": "^4.0.16",
|
|
41
|
+
"prismjs": "^1.28.0"
|
|
41
42
|
},
|
|
42
43
|
"scripts": {
|
|
43
44
|
"build": "NODE_ENV=production webpack --mode=production",
|
|
@@ -49,18 +50,18 @@
|
|
|
49
50
|
"lint-fix": "./node_modules/eslint/bin/eslint.js --fix ./src/**"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
|
-
"@babel/core": "^7.
|
|
53
|
+
"@babel/core": "^7.18.0",
|
|
53
54
|
"@babel/eslint-parser": "^7.17.0",
|
|
54
|
-
"@babel/preset-env": "^7.
|
|
55
|
-
"babel-loader": "^8.2.
|
|
55
|
+
"@babel/preset-env": "^7.18.0",
|
|
56
|
+
"babel-loader": "^8.2.5",
|
|
56
57
|
"babel-plugin-template-html-minifier": "^4.1.0",
|
|
57
58
|
"clean-webpack-plugin": "^4.0.0",
|
|
58
|
-
"compression-webpack-plugin": "^
|
|
59
|
-
"css-loader": "^6.
|
|
60
|
-
"eslint": "^8.
|
|
59
|
+
"compression-webpack-plugin": "^10.0.0",
|
|
60
|
+
"css-loader": "^6.7.1",
|
|
61
|
+
"eslint": "^8.16.0",
|
|
61
62
|
"eslint-config-airbnb": "^19.0.4",
|
|
62
63
|
"eslint-import-resolver-webpack": "^0.13.2",
|
|
63
|
-
"eslint-plugin-import": "^2.
|
|
64
|
+
"eslint-plugin-import": "^2.26.0",
|
|
64
65
|
"eslint-webpack-plugin": "3.1.1",
|
|
65
66
|
"file-loader": "^6.2.0",
|
|
66
67
|
"filemanager-webpack-plugin": "^6.1.7",
|
|
@@ -69,10 +70,10 @@
|
|
|
69
70
|
"style-loader": "^3.3.1",
|
|
70
71
|
"terser-webpack-plugin": "^5.3.1",
|
|
71
72
|
"unminified-webpack-plugin": "^3.0.0",
|
|
72
|
-
"webpack": "^5.
|
|
73
|
+
"webpack": "^5.72.1",
|
|
73
74
|
"webpack-bundle-analyzer": "^4.5.0",
|
|
74
75
|
"webpack-cli": "^4.9.2",
|
|
75
|
-
"webpack-dev-server": "^4.
|
|
76
|
+
"webpack-dev-server": "^4.9.0"
|
|
76
77
|
},
|
|
77
78
|
"engines": {
|
|
78
79
|
"node": ">=10.21.0"
|
|
@@ -52,6 +52,7 @@ export default class ApiRequest extends LitElement {
|
|
|
52
52
|
responseStatus: { type: String, attribute: false },
|
|
53
53
|
responseUrl: { type: String, attribute: false },
|
|
54
54
|
fillRequestFieldsWithExample: { type: String, attribute: 'fill-request-fields-with-example' },
|
|
55
|
+
useSummaryToListExamples: { type: String, attribute: 'use-summary-to-list-example' },
|
|
55
56
|
allowTry: { type: String, attribute: 'allow-try' },
|
|
56
57
|
renderStyle: { type: String, attribute: 'render-style' },
|
|
57
58
|
schemaStyle: { type: String, attribute: 'schema-style' },
|
|
@@ -68,6 +69,7 @@ export default class ApiRequest extends LitElement {
|
|
|
68
69
|
schemaDescriptionExpanded: { type: String, attribute: 'schema-description-expanded' },
|
|
69
70
|
allowSchemaDescriptionExpandToggle: { type: String, attribute: 'allow-schema-description-expand-toggle' },
|
|
70
71
|
schemaHideReadOnly: { type: String, attribute: 'schema-hide-read-only' },
|
|
72
|
+
schemaHideWriteOnly: { type: String, attribute: 'schema-hide-write-only' },
|
|
71
73
|
fetchCredentials: { type: String, attribute: 'fetch-credentials' },
|
|
72
74
|
|
|
73
75
|
// properties for internal tracking
|
|
@@ -98,12 +100,12 @@ export default class ApiRequest extends LitElement {
|
|
|
98
100
|
text-align: right;
|
|
99
101
|
line-height: var(--font-size-small);
|
|
100
102
|
}
|
|
101
|
-
.param-name{
|
|
103
|
+
.param-name {
|
|
102
104
|
color: var(--fg);
|
|
103
105
|
font-family: var(--font-mono);
|
|
104
106
|
}
|
|
105
107
|
.param-name.deprecated {
|
|
106
|
-
|
|
108
|
+
color: var(--red);
|
|
107
109
|
}
|
|
108
110
|
.param-type{
|
|
109
111
|
color: var(--light-fg);
|
|
@@ -245,7 +247,12 @@ export default class ApiRequest extends LitElement {
|
|
|
245
247
|
}
|
|
246
248
|
}
|
|
247
249
|
}"
|
|
248
|
-
|
|
250
|
+
>
|
|
251
|
+
${this.useSummaryToListExamples === 'true'
|
|
252
|
+
? v.description || v.summary || (v.value && Array.isArray(v.value) ? (v.value?.join(', ')) : (v.value || ''))
|
|
253
|
+
: v.value && Array.isArray(v.value) ? (v.value?.join(', ')) : (v.value || '')
|
|
254
|
+
}
|
|
255
|
+
</a>
|
|
249
256
|
${paramType === 'array' ? '] ' : ''}
|
|
250
257
|
`)}
|
|
251
258
|
`
|
|
@@ -316,18 +323,20 @@ export default class ApiRequest extends LitElement {
|
|
|
316
323
|
serializeStyle || 'json',
|
|
317
324
|
'',
|
|
318
325
|
'',
|
|
319
|
-
true,
|
|
320
|
-
true,
|
|
326
|
+
!(this.schemaHideReadOnly && (this.schemaHideReadOnly.includes(this.method) || this.schemaHideReadOnly === 'true')),
|
|
327
|
+
!(this.schemaHideWriteOnly && (this.schemaHideWriteOnly.includes(this.method) || this.schemaHideWriteOnly === 'true')),
|
|
321
328
|
'text',
|
|
322
329
|
false,
|
|
323
330
|
)[0].exampleValue;
|
|
324
331
|
}
|
|
325
332
|
const labelColWidth = 'read focused'.includes(this.renderStyle) ? '200px' : '160px';
|
|
326
333
|
tableRows.push(html`
|
|
327
|
-
<tr>
|
|
334
|
+
<tr title="${param.deprecated ? 'Deprecated' : ''}">
|
|
328
335
|
<td rowspan="${this.allowTry === 'true' ? '1' : '2'}" style="width:${labelColWidth}; min-width:100px;">
|
|
329
|
-
<div class="param-name">
|
|
330
|
-
${param.
|
|
336
|
+
<div class="param-name ${param.deprecated ? 'deprecated' : ''}" >
|
|
337
|
+
${param.deprecated ? html`<span style='color:var(--red);'>✗</span>` : ''}
|
|
338
|
+
${param.required ? html`<span style='color:var(--red)'>*</span>` : ''}
|
|
339
|
+
${param.name}
|
|
331
340
|
</div>
|
|
332
341
|
<div class="param-type">
|
|
333
342
|
${paramSchema.type === 'array'
|
|
@@ -338,7 +347,7 @@ export default class ApiRequest extends LitElement {
|
|
|
338
347
|
</td>
|
|
339
348
|
${this.allowTry === 'true'
|
|
340
349
|
? html`
|
|
341
|
-
<td style="min-width:100px;">
|
|
350
|
+
<td style="min-width:100px;" colspan="${paramSchema.default || paramSchema.constrain || paramSchema.allowedValues || paramSchema.pattern ? '1' : '2'}">
|
|
342
351
|
${paramSchema.type === 'array'
|
|
343
352
|
? html`
|
|
344
353
|
<tag-input class="request-param"
|
|
@@ -393,7 +402,10 @@ export default class ApiRequest extends LitElement {
|
|
|
393
402
|
schema-description-expanded = "${this.schemaDescriptionExpanded}"
|
|
394
403
|
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
|
|
395
404
|
schema-hide-read-only = "${this.schemaHideReadOnly.includes(this.method)}"
|
|
396
|
-
schema-hide-write-only = "
|
|
405
|
+
schema-hide-write-only = "${this.schemaHideWriteOnly.includes(this.method)}"
|
|
406
|
+
exportparts = "btn:btn, btn-fill:btn-fill, btn-outline:btn-outline, btn-try:btn-try, btn-clear:btn-clear, btn-clear-resp:btn-clear-resp,
|
|
407
|
+
file-input:file-input, textbox:textbox, textbox-param:textbox-param, textarea:textarea, textarea-param:textarea-param,
|
|
408
|
+
anchor:anchor, anchor-param-example:anchor-param-example"
|
|
397
409
|
> </schema-tree>
|
|
398
410
|
</div>`
|
|
399
411
|
}
|
|
@@ -406,8 +418,9 @@ export default class ApiRequest extends LitElement {
|
|
|
406
418
|
data-pname="${param.name}"
|
|
407
419
|
data-example="${Array.isArray(example.exampleVal) ? example.exampleVal.join('~|~') : example.exampleVal}"
|
|
408
420
|
data-param-allow-reserved = "${paramAllowReserved}"
|
|
421
|
+
data-x-fill-example = "${param['x-fill-example'] || 'yes'}"
|
|
409
422
|
data-array="false"
|
|
410
|
-
.value="${live(this.fillRequestFieldsWithExample === 'true' ? example.exampleVal : '')}"
|
|
423
|
+
.value="${param['x-fill-example'] === 'no' ? '' : live(this.fillRequestFieldsWithExample === 'true' ? example.exampleVal : '')}"
|
|
411
424
|
/>`
|
|
412
425
|
}
|
|
413
426
|
</td>`
|
|
@@ -440,12 +453,12 @@ export default class ApiRequest extends LitElement {
|
|
|
440
453
|
}`)}
|
|
441
454
|
</div>
|
|
442
455
|
</td>`
|
|
443
|
-
:
|
|
456
|
+
: html`<td></td>`
|
|
444
457
|
}
|
|
445
458
|
</tr>
|
|
446
459
|
<tr>
|
|
447
460
|
${this.allowTry === 'true' ? html`<td style="border:none"> </td>` : ''}
|
|
448
|
-
<td colspan="2" style="border:none
|
|
461
|
+
<td colspan="2" style="border:none">
|
|
449
462
|
<span class="m-markdown-small">${unsafeHTML(marked(param.description || ''))}</span>
|
|
450
463
|
${this.exampleListTemplate.call(this, param.name, paramSchema.type, example.exampleList)}
|
|
451
464
|
</td>
|
|
@@ -546,8 +559,8 @@ export default class ApiRequest extends LitElement {
|
|
|
546
559
|
reqBody.mimeType,
|
|
547
560
|
reqBody.examples,
|
|
548
561
|
reqBody.example,
|
|
549
|
-
|
|
550
|
-
true,
|
|
562
|
+
!(this.schemaHideReadOnly && (this.schemaHideReadOnly.includes(this.method) || this.schemaHideReadOnly === 'true')),
|
|
563
|
+
!(this.schemaHideWriteOnly && (this.schemaHideWriteOnly.includes(this.method) || this.schemaHideWriteOnly === 'true')),
|
|
551
564
|
'text',
|
|
552
565
|
false,
|
|
553
566
|
);
|
|
@@ -605,8 +618,8 @@ export default class ApiRequest extends LitElement {
|
|
|
605
618
|
reqBody.mimeType,
|
|
606
619
|
reqBody.examples,
|
|
607
620
|
reqBody.example,
|
|
608
|
-
|
|
609
|
-
true,
|
|
621
|
+
!(this.schemaHideReadOnly && (this.schemaHideReadOnly.includes(this.method) || this.schemaHideReadOnly === 'true')),
|
|
622
|
+
!(this.schemaHideWriteOnly && (this.schemaHideWriteOnly.includes(this.method) || this.schemaHideWriteOnly === 'true')),
|
|
610
623
|
'text',
|
|
611
624
|
false,
|
|
612
625
|
);
|
|
@@ -637,8 +650,9 @@ export default class ApiRequest extends LitElement {
|
|
|
637
650
|
schema-expand-level = "${this.schemaExpandLevel}"
|
|
638
651
|
schema-description-expanded = "${this.schemaDescriptionExpanded}"
|
|
639
652
|
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
|
|
640
|
-
schema-hide-read-only = "${this.schemaHideReadOnly
|
|
641
|
-
schema-hide-write-only = "
|
|
653
|
+
schema-hide-read-only = "${this.schemaHideReadOnly}"
|
|
654
|
+
schema-hide-write-only = "${this.schemaHideWriteOnly}"
|
|
655
|
+
exportparts = "schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
|
|
642
656
|
> </schema-table>
|
|
643
657
|
`;
|
|
644
658
|
} else if (this.schemaStyle === 'tree') {
|
|
@@ -651,8 +665,9 @@ export default class ApiRequest extends LitElement {
|
|
|
651
665
|
schema-expand-level = "${this.schemaExpandLevel}"
|
|
652
666
|
schema-description-expanded = "${this.schemaDescriptionExpanded}"
|
|
653
667
|
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
|
|
654
|
-
schema-hide-read-only = "
|
|
655
|
-
schema-hide-write-only = "
|
|
668
|
+
schema-hide-read-only = "${this.schemaHideReadOnly}"
|
|
669
|
+
schema-hide-write-only = "${this.schemaHideWriteOnly}"
|
|
670
|
+
exportparts = "schema-description:schema-description, schema-multiline-toggle:schema-multiline-toggle"
|
|
656
671
|
> </schema-tree>
|
|
657
672
|
`;
|
|
658
673
|
}
|
|
@@ -697,8 +712,8 @@ export default class ApiRequest extends LitElement {
|
|
|
697
712
|
'json',
|
|
698
713
|
fieldSchema.examples,
|
|
699
714
|
fieldSchema.example,
|
|
700
|
-
|
|
701
|
-
true,
|
|
715
|
+
!(this.schemaHideReadOnly && (this.schemaHideReadOnly.includes(this.method) || this.schemaHideReadOnly === 'true')),
|
|
716
|
+
!(this.schemaHideWriteOnly && (this.schemaHideWriteOnly.includes(this.method) || this.schemaHideWriteOnly === 'true')),
|
|
702
717
|
'text',
|
|
703
718
|
false,
|
|
704
719
|
);
|
|
@@ -772,7 +787,7 @@ export default class ApiRequest extends LitElement {
|
|
|
772
787
|
const labelColWidth = 'read focused'.includes(this.renderStyle) ? '200px' : '160px';
|
|
773
788
|
const example = normalizeExamples((paramSchema.examples || paramSchema.example), paramSchema.type);
|
|
774
789
|
formDataTableRows.push(html`
|
|
775
|
-
<tr>
|
|
790
|
+
<tr title="${fieldSchema.deprecated ? 'Deprecated' : ''}">
|
|
776
791
|
<td style="width:${labelColWidth}; min-width:100px;">
|
|
777
792
|
<div class="param-name ${fieldSchema.deprecated ? 'deprecated' : ''}">
|
|
778
793
|
${fieldName}${(schema.required?.includes(fieldName) || fieldSchema.required) ? html`<span style='color:var(--red);'>*</span>` : ''}
|
|
@@ -935,19 +950,19 @@ export default class ApiRequest extends LitElement {
|
|
|
935
950
|
}
|
|
936
951
|
</div>`
|
|
937
952
|
: html`
|
|
938
|
-
<div class="tab-content col m-markdown" style="flex:1;display:${this.activeResponseTab === 'response' ? 'flex' : 'none'};" >
|
|
953
|
+
<div class="tab-content col m-markdown" style="flex:1; display:${this.activeResponseTab === 'response' ? 'flex' : 'none'};" >
|
|
939
954
|
<button class="toolbar-btn" style="position:absolute; top:12px; right:8px" @click='${(e) => { copyToClipboard(this.responseText, e); }}' part="btn btn-fill"> Copy </button>
|
|
940
|
-
<pre style="white-space:pre;
|
|
955
|
+
<pre style="white-space:pre; min-height:50px; height:400px; resize:vertical; overflow:auto">${responseFormat
|
|
941
956
|
? html`<code>${unsafeHTML(Prism.highlight(this.responseText, Prism.languages[responseFormat], responseFormat))}</code>`
|
|
942
957
|
: `${this.responseText}`
|
|
943
958
|
}</pre>
|
|
944
959
|
</div>`
|
|
945
960
|
}
|
|
946
|
-
<div class="tab-content col m-markdown" style="flex:1;display:${this.activeResponseTab === 'headers' ? 'flex' : 'none'};" >
|
|
961
|
+
<div class="tab-content col m-markdown" style="flex:1; display:${this.activeResponseTab === 'headers' ? 'flex' : 'none'};" >
|
|
947
962
|
<button class="toolbar-btn" style = "position:absolute; top:12px; right:8px" @click='${(e) => { copyToClipboard(this.responseHeaders, e); }}' part="btn btn-fill"> Copy </button>
|
|
948
963
|
<pre style="white-space:pre"><code>${unsafeHTML(Prism.highlight(this.responseHeaders, Prism.languages.css, 'css'))}</code></pre>
|
|
949
964
|
</div>
|
|
950
|
-
<div class="tab-content col m-markdown" style="flex:1;display:${this.activeResponseTab === 'curl' ? 'flex' : 'none'};">
|
|
965
|
+
<div class="tab-content col m-markdown" style="flex:1; display:${this.activeResponseTab === 'curl' ? 'flex' : 'none'};">
|
|
951
966
|
<button class="toolbar-btn" style = "position:absolute; top:12px; right:8px" @click='${(e) => { copyToClipboard(this.curlSyntax.replace(/\\$/, ''), e); }}' part="btn btn-fill"> Copy </button>
|
|
952
967
|
<pre style="white-space:pre"><code>${unsafeHTML(Prism.highlight(this.curlSyntax.trim().replace(/\\$/, ''), Prism.languages.shell, 'shell'))}</code></pre>
|
|
953
968
|
</div>
|
|
@@ -1392,7 +1407,7 @@ export default class ApiRequest extends LitElement {
|
|
|
1392
1407
|
}
|
|
1393
1408
|
if (this.responseIsBlob) {
|
|
1394
1409
|
const contentDisposition = fetchResponse.headers.get('content-disposition');
|
|
1395
|
-
this.respContentDisposition = contentDisposition ? contentDisposition.split('filename=')[1].replace(
|
|
1410
|
+
this.respContentDisposition = contentDisposition ? contentDisposition.split('filename=')[1].replace(/"|'/g, '') : 'filename';
|
|
1396
1411
|
respBlob = await fetchResponse.blob();
|
|
1397
1412
|
this.responseBlobUrl = URL.createObjectURL(respBlob);
|
|
1398
1413
|
}
|
|
@@ -34,6 +34,7 @@ export default class ApiResponse extends LitElement {
|
|
|
34
34
|
schemaExpandLevel: { type: Number, attribute: 'schema-expand-level' },
|
|
35
35
|
schemaDescriptionExpanded: { type: String, attribute: 'schema-description-expanded' },
|
|
36
36
|
allowSchemaDescriptionExpandToggle: { type: String, attribute: 'allow-schema-description-expand-toggle' },
|
|
37
|
+
schemaHideReadOnly: { type: String, attribute: 'schema-hide-read-only' },
|
|
37
38
|
schemaHideWriteOnly: { type: String, attribute: 'schema-hide-write-only' },
|
|
38
39
|
};
|
|
39
40
|
}
|
|
@@ -118,8 +119,8 @@ export default class ApiResponse extends LitElement {
|
|
|
118
119
|
mimeResp,
|
|
119
120
|
mimeRespObj.examples,
|
|
120
121
|
mimeRespObj.example,
|
|
121
|
-
true,
|
|
122
|
-
|
|
122
|
+
!(this.schemaHideReadOnly && (this.schemaHideReadOnly.includes(this.method) || this.schemaHideReadOnly === 'true')),
|
|
123
|
+
!(this.schemaHideWriteOnly && (this.schemaHideWriteOnly.includes(this.method) || this.schemaHideWriteOnly === 'true')),
|
|
123
124
|
mimeResp.includes('json') ? 'json' : 'text',
|
|
124
125
|
);
|
|
125
126
|
allMimeResp[mimeResp] = {
|
|
@@ -309,7 +310,7 @@ export default class ApiResponse extends LitElement {
|
|
|
309
310
|
schema-expand-level = "${this.schemaExpandLevel}"
|
|
310
311
|
schema-description-expanded = "${this.schemaDescriptionExpanded}"
|
|
311
312
|
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
|
|
312
|
-
schema-hide-read-only = "
|
|
313
|
+
schema-hide-read-only = "${this.schemaHideReadOnly}"
|
|
313
314
|
schema-hide-write-only = "${this.schemaHideWriteOnly}"
|
|
314
315
|
> </schema-tree> `
|
|
315
316
|
: html`
|
|
@@ -319,7 +320,7 @@ export default class ApiResponse extends LitElement {
|
|
|
319
320
|
schema-expand-level = "${this.schemaExpandLevel}"
|
|
320
321
|
schema-description-expanded = "${this.schemaDescriptionExpanded}"
|
|
321
322
|
allow-schema-description-expand-toggle = "${this.allowSchemaDescriptionExpandToggle}",
|
|
322
|
-
schema-hide-read-only = "
|
|
323
|
+
schema-hide-read-only = "${this.schemaHideReadOnly}"
|
|
323
324
|
schema-hide-write-only = "${this.schemaHideWriteOnly}"
|
|
324
325
|
> </schema-tree>`
|
|
325
326
|
}`;
|
|
@@ -35,18 +35,29 @@ export default class JsonTree extends LitElement {
|
|
|
35
35
|
text-align: left;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
.open-bracket{
|
|
38
|
+
.open-bracket {
|
|
39
39
|
display:inline-block;
|
|
40
40
|
padding: 0 20px 0 0;
|
|
41
41
|
cursor:pointer;
|
|
42
42
|
border: 1px solid transparent;
|
|
43
43
|
border-radius:3px;
|
|
44
44
|
}
|
|
45
|
-
.
|
|
45
|
+
.close-bracket {
|
|
46
|
+
border: 1px solid transparent;
|
|
47
|
+
border-radius:3px;
|
|
48
|
+
display:inline-block;
|
|
49
|
+
}
|
|
50
|
+
.open-bracket:hover {
|
|
46
51
|
color:var(--primary-color);
|
|
47
52
|
background-color:var(--hover-color);
|
|
48
53
|
border: 1px solid var(--border-color);
|
|
49
54
|
}
|
|
55
|
+
.open-bracket.expanded:hover ~ .inside-bracket {
|
|
56
|
+
border-left: 1px solid var(--fg3);
|
|
57
|
+
}
|
|
58
|
+
.open-bracket.expanded:hover ~ .close-bracket {
|
|
59
|
+
color:var(--primary-color);
|
|
60
|
+
}
|
|
50
61
|
.inside-bracket{
|
|
51
62
|
padding-left:12px;
|
|
52
63
|
border-left:1px dotted var(--border-color);
|
|
@@ -47,7 +47,7 @@ export default class SchemaTable extends LitElement {
|
|
|
47
47
|
width: 240px;
|
|
48
48
|
}
|
|
49
49
|
.key.deprecated .key-label {
|
|
50
|
-
|
|
50
|
+
color: var(--red);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
.table .key-type {
|
|
@@ -92,7 +92,7 @@ export default class SchemaTable extends LitElement {
|
|
|
92
92
|
${this.allowSchemaDescriptionExpandToggle === 'true'
|
|
93
93
|
? html`
|
|
94
94
|
<div style="flex:1"></div>
|
|
95
|
-
<div class='toolbar-item' @click='${() => { this.schemaDescriptionExpanded = (this.schemaDescriptionExpanded === 'true' ? 'false' : 'true'); }}'>
|
|
95
|
+
<div part="schema-multiline-toggle" class='toolbar-item' @click='${() => { this.schemaDescriptionExpanded = (this.schemaDescriptionExpanded === 'true' ? 'false' : 'true'); }}'>
|
|
96
96
|
${this.schemaDescriptionExpanded === 'true' ? 'Single line description' : 'Multiline description'}
|
|
97
97
|
</div>
|
|
98
98
|
`
|
|
@@ -100,7 +100,7 @@ export default class SchemaTable extends LitElement {
|
|
|
100
100
|
}
|
|
101
101
|
</div>
|
|
102
102
|
${this.data?.['::description']
|
|
103
|
-
? html`<span class='m-markdown'> ${unsafeHTML(marked(this.data['::description'] || ''))}</span>`
|
|
103
|
+
? html`<span part="schema-description" class='m-markdown'> ${unsafeHTML(marked(this.data['::description'] || ''))}</span>`
|
|
104
104
|
: ''
|
|
105
105
|
}
|
|
106
106
|
<div style = 'border:1px solid var(--light-border-color)'>
|
|
@@ -130,7 +130,7 @@ export default class SchemaTable extends LitElement {
|
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
if (data['::readwrite'] === 'readonly') {
|
|
133
|
+
if (data && data['::readwrite'] === 'readonly') {
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
136
|
}
|
|
@@ -140,17 +140,27 @@ export default class SchemaTable extends LitElement {
|
|
|
140
140
|
return;
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
if (data['::readwrite'] === 'writeonly') {
|
|
143
|
+
if (data && data['::readwrite'] === 'writeonly') {
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
+
if (!data) {
|
|
148
|
+
return html`<div class="null" style="display:inline;">
|
|
149
|
+
<span style='margin-left:${(schemaLevel + 1) * 16}px'> </span>
|
|
150
|
+
<span class="key-label xxx-of-key"> ${key.replace('::OPTION~', '')}</span>
|
|
151
|
+
${
|
|
152
|
+
dataType === 'array'
|
|
153
|
+
? html`<span class='mono-font'> [ ] </span>`
|
|
154
|
+
: dataType === 'object'
|
|
155
|
+
? html`<span class='mono-font'> { } </span>`
|
|
156
|
+
: html`<span class='mono-font'> schema undefined </span>`
|
|
157
|
+
}
|
|
158
|
+
</div>`;
|
|
159
|
+
}
|
|
147
160
|
|
|
148
161
|
const newSchemaLevel = data['::type']?.startsWith('xxx-of') ? schemaLevel : (schemaLevel + 1);
|
|
149
162
|
const newIndentLevel = dataType === 'xxx-of-option' || data['::type'] === 'xxx-of-option' || key.startsWith('::OPTION') ? indentLevel : (indentLevel + 1);
|
|
150
163
|
const leftPadding = 16 * newIndentLevel; // 2 space indentation at each level
|
|
151
|
-
if (!data) {
|
|
152
|
-
return html`<div class="null" style="display:inline;">null</div>`;
|
|
153
|
-
}
|
|
154
164
|
if (Object.keys(data).length === 0) {
|
|
155
165
|
return html`<span class="td key object" style='padding-left:${leftPadding}px'>${key}</span>`;
|
|
156
166
|
}
|
|
@@ -188,7 +198,7 @@ export default class SchemaTable extends LitElement {
|
|
|
188
198
|
return html`
|
|
189
199
|
${newSchemaLevel >= 0 && key
|
|
190
200
|
? html`
|
|
191
|
-
<div class='tr ${newSchemaLevel <= this.schemaExpandLevel ? 'expanded' : 'collapsed'} ${data['::type']}' data-obj='${keyLabel}'>
|
|
201
|
+
<div class='tr ${newSchemaLevel <= this.schemaExpandLevel ? 'expanded' : 'collapsed'} ${data['::type']}' data-obj='${keyLabel}' title="${data['::deprecated'] ? 'Deprecated' : ''}">
|
|
192
202
|
<div class="td key ${data['::deprecated'] ? 'deprecated' : ''}" style='padding-left:${leftPadding}px'>
|
|
193
203
|
${(keyLabel || keyDescr)
|
|
194
204
|
? html`
|
|
@@ -204,8 +214,8 @@ export default class SchemaTable extends LitElement {
|
|
|
204
214
|
${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION')
|
|
205
215
|
? html`<span class="xxx-of-key" style="margin-left:-6px">${keyLabel}</span><span class="${isOneOfLabel ? 'xxx-of-key' : 'xxx-of-descr'}">${keyDescr}</span>`
|
|
206
216
|
: keyLabel.endsWith('*')
|
|
207
|
-
? html`<span class="key-label" style="display:inline-block; margin-left:-6px;"
|
|
208
|
-
: html`<span class="key-label" style="display:inline-block; margin-left:-6px;">${keyLabel === '::props' ? '' : keyLabel}</span>`
|
|
217
|
+
? html`<span class="key-label" style="display:inline-block; margin-left:-6px;">${data['::deprecated'] ? '✗' : ''} ${keyLabel.substring(0, keyLabel.length - 1)}</span><span style='color:var(--red);'>*</span>`
|
|
218
|
+
: html`<span class="key-label" style="display:inline-block; margin-left:-6px;">${data['::deprecated'] ? '✗' : ''} ${keyLabel === '::props' ? '' : keyLabel}</span>`
|
|
209
219
|
}
|
|
210
220
|
${data['::type'] === 'xxx-of' && dataType === 'array' ? html`<span style="color:var(--primary-color)">ARRAY</span>` : ''}
|
|
211
221
|
</div>
|
|
@@ -287,23 +297,35 @@ export default class SchemaTable extends LitElement {
|
|
|
287
297
|
</div>`;
|
|
288
298
|
}
|
|
289
299
|
return html`
|
|
290
|
-
<div class = "tr primitive">
|
|
300
|
+
<div class = "tr primitive" title="${deprecated ? 'Deprecated' : ''}">
|
|
291
301
|
<div class="td key ${deprecated}" style='padding-left:${leftPadding}px'>
|
|
302
|
+
${deprecated ? html`<span style='color:var(--red);'>✗</span>` : ''}
|
|
292
303
|
${keyLabel?.endsWith('*')
|
|
293
|
-
? html
|
|
304
|
+
? html`
|
|
305
|
+
<span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span>
|
|
306
|
+
<span style='color:var(--red);'>*</span>`
|
|
294
307
|
: key.startsWith('::OPTION')
|
|
295
308
|
? html`<span class='xxx-of-key'>${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>`
|
|
296
309
|
: html`${keyLabel ? html`<span class="key-label"> ${keyLabel}</span>` : html`<span class="xxx-of-descr">${schemaTitle}</span>`}`
|
|
297
310
|
}
|
|
298
311
|
</div>
|
|
299
312
|
${dataTypeHtml}
|
|
300
|
-
<div class='td key-descr'>
|
|
313
|
+
<div class='td key-descr' @click="${() => { this.schemaDescriptionExpanded = 'true'; }}">
|
|
301
314
|
${dataType === 'array' ? html`<span class="m-markdown-small">${unsafeHTML(marked(description))}</span>` : ''}
|
|
315
|
+
${schemaDescription
|
|
316
|
+
? html`<span class="m-markdown-small">
|
|
317
|
+
${unsafeHTML(marked(`${schemaTitle ? `**${schemaTitle}:**` : ''} ${schemaDescription} ${constraint || defaultValue || allowedValues || pattern ? '<span class="more-content">⤵</span>' : ''}`))}
|
|
318
|
+
</span>`
|
|
319
|
+
: schemaTitle
|
|
320
|
+
? html`${schemaTitle} ${constraint || defaultValue || allowedValues || pattern
|
|
321
|
+
? html`<span class="more-content">⤵</span>`
|
|
322
|
+
: ''}`
|
|
323
|
+
: ''
|
|
324
|
+
}
|
|
302
325
|
${constraint ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px;'> <span class='bold-text'>Constraints: </span> ${constraint}</div>` : ''}
|
|
303
326
|
${defaultValue ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px;'> <span class='bold-text'>Default: </span>${defaultValue}</div>` : ''}
|
|
304
327
|
${allowedValues ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px;'> <span class='bold-text'>Allowed: </span>${allowedValues}</div>` : ''}
|
|
305
328
|
${pattern ? html`<div style='display:inline-block; line-break:anywhere; margin-right:8px;'> <span class='bold-text'>Pattern: </span>${pattern}</div>` : ''}
|
|
306
|
-
${schemaDescription ? html`<span class="m-markdown-small">${unsafeHTML(marked(`${schemaTitle ? `**${schemaTitle}:**` : ''} ${schemaDescription}`))}</span>` : ''}
|
|
307
329
|
</div>
|
|
308
330
|
</div>
|
|
309
331
|
`;
|