openapi-explorer 0.9.310 → 0.9.314
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/CHANGELOG.md +1 -0
- package/dist/{openapi-explorer.min.js → browser/openapi-explorer.min.js} +3 -3
- package/dist/{openapi-explorer.min.js.map → browser/openapi-explorer.min.js.map} +0 -0
- package/dist/es/components/api-request.js +936 -0
- package/dist/es/components/api-response.js +184 -0
- package/dist/es/components/json-tree.js +67 -0
- package/{src → dist/es}/components/mime-types.js +11 -17
- package/dist/es/components/schema-table.js +156 -0
- package/dist/es/components/schema-tree.js +191 -0
- package/dist/es/components/tag-input.js +67 -0
- package/{src → dist/es}/openapi-explorer-oauth-handler.js +2 -2
- package/{src → dist/es}/openapi-explorer.js +364 -371
- package/dist/es/styles/advanced-search-styles.js +2 -0
- package/dist/es/styles/api-request-styles.js +2 -0
- package/dist/es/styles/border-styles.js +2 -0
- package/dist/es/styles/endpoint-styles.js +2 -0
- package/dist/es/styles/flex-styles.js +2 -0
- package/dist/es/styles/font-styles.js +2 -0
- package/dist/es/styles/info-styles.js +2 -0
- package/dist/es/styles/input-styles.js +4 -0
- package/dist/es/styles/nav-styles.js +2 -0
- package/dist/es/styles/prism-styles.js +2 -0
- package/dist/es/styles/schema-styles.js +2 -0
- package/dist/es/styles/tab-styles.js +2 -0
- package/dist/es/styles/table-styles.js +2 -0
- package/dist/es/templates/advance-search-template.js +37 -0
- package/dist/es/templates/callback-template.js +7 -0
- package/dist/es/templates/code-samples-template.js +26 -0
- package/dist/es/templates/components-template.js +17 -0
- package/dist/es/templates/endpoint-template.js +94 -0
- package/dist/es/templates/expanded-endpoint-template.js +32 -0
- package/{src → dist/es}/templates/focused-endpoint-template.js +15 -15
- package/dist/es/templates/navbar-template.js +46 -0
- package/dist/es/templates/overview-template.js +9 -0
- package/dist/es/templates/responsiveViewMainBodyTemplate.js +30 -0
- package/dist/es/templates/security-scheme-template.js +330 -0
- package/dist/es/templates/server-template.js +42 -0
- package/{src → dist/es}/utils/color-utils.js +53 -16
- package/{src → dist/es}/utils/common-utils.js +18 -18
- package/{src → dist/es}/utils/schema-utils.js +248 -124
- package/{src → dist/es}/utils/spec-parser.js +112 -71
- package/dist/es/utils/theme.js +75 -0
- package/{src → dist/es}/utils/xml/xml.js +41 -38
- package/dist/lib/components/api-request.js +957 -0
- package/dist/lib/components/api-response.js +206 -0
- package/dist/lib/components/json-tree.js +82 -0
- package/dist/lib/components/mime-types.js +70 -0
- package/dist/lib/components/schema-table.js +170 -0
- package/dist/lib/components/schema-tree.js +206 -0
- package/dist/lib/components/tag-input.js +76 -0
- package/dist/lib/openapi-explorer-oauth-handler.js +19 -0
- package/dist/lib/openapi-explorer.js +817 -0
- package/dist/lib/styles/advanced-search-styles.js +10 -0
- package/dist/lib/styles/api-request-styles.js +10 -0
- package/dist/lib/styles/border-styles.js +10 -0
- package/dist/lib/styles/endpoint-styles.js +10 -0
- package/dist/lib/styles/flex-styles.js +10 -0
- package/dist/lib/styles/font-styles.js +10 -0
- package/dist/lib/styles/info-styles.js +10 -0
- package/dist/lib/styles/input-styles.js +11 -0
- package/dist/lib/styles/nav-styles.js +10 -0
- package/dist/lib/styles/prism-styles.js +10 -0
- package/dist/lib/styles/schema-styles.js +10 -0
- package/dist/lib/styles/tab-styles.js +10 -0
- package/dist/lib/styles/table-styles.js +10 -0
- package/dist/lib/templates/advance-search-template.js +42 -0
- package/dist/lib/templates/callback-template.js +12 -0
- package/dist/lib/templates/code-samples-template.js +36 -0
- package/dist/lib/templates/components-template.js +27 -0
- package/dist/lib/templates/endpoint-template.js +111 -0
- package/dist/lib/templates/expanded-endpoint-template.js +48 -0
- package/dist/lib/templates/focused-endpoint-template.js +95 -0
- package/dist/lib/templates/navbar-template.js +54 -0
- package/dist/lib/templates/overview-template.js +16 -0
- package/dist/lib/templates/responsiveViewMainBodyTemplate.js +47 -0
- package/dist/lib/templates/security-scheme-template.js +342 -0
- package/dist/lib/templates/server-template.js +49 -0
- package/dist/lib/utils/color-utils.js +112 -0
- package/dist/lib/utils/common-utils.js +156 -0
- package/dist/lib/utils/schema-utils.js +743 -0
- package/dist/lib/utils/spec-parser.js +361 -0
- package/dist/lib/utils/theme.js +84 -0
- package/dist/lib/utils/xml/xml.js +239 -0
- package/package.json +19 -6
- package/dist/openapi-explorer.min.js.LICENSE.txt +0 -71
- package/dist/openapi-explorer.min.js.LICENSE.txt.gz +0 -0
- package/dist/openapi-explorer.min.js.gz +0 -0
- package/dist/openapi-explorer.min.js.map.gz +0 -0
- package/dist/report.html +0 -38
- package/src/components/api-request.js +0 -1244
- package/src/components/api-response.js +0 -340
- package/src/components/json-tree.js +0 -129
- package/src/components/schema-table.js +0 -250
- package/src/components/schema-tree.js +0 -280
- package/src/components/tag-input.js +0 -109
- package/src/styles/advanced-search-styles.js +0 -84
- package/src/styles/api-request-styles.js +0 -111
- package/src/styles/border-styles.js +0 -24
- package/src/styles/css/main.css +0 -24
- package/src/styles/endpoint-styles.js +0 -222
- package/src/styles/flex-styles.js +0 -15
- package/src/styles/font-styles.js +0 -266
- package/src/styles/info-styles.js +0 -20
- package/src/styles/input-styles.js +0 -236
- package/src/styles/nav-styles.js +0 -141
- package/src/styles/prism-styles.js +0 -107
- package/src/styles/schema-styles.js +0 -121
- package/src/styles/tab-styles.js +0 -44
- package/src/styles/table-styles.js +0 -48
- package/src/templates/advance-search-template.js +0 -81
- package/src/templates/callback-template.js +0 -63
- package/src/templates/code-samples-template.js +0 -35
- package/src/templates/components-template.js +0 -43
- package/src/templates/endpoint-template.js +0 -175
- package/src/templates/expanded-endpoint-template.js +0 -104
- package/src/templates/navbar-template.js +0 -175
- package/src/templates/overview-template.js +0 -58
- package/src/templates/responsiveViewMainBodyTemplate.js +0 -72
- package/src/templates/security-scheme-template.js +0 -487
- package/src/templates/server-template.js +0 -106
- package/src/utils/theme.js +0 -163
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
|
|
6
|
+
var _litElement = require("lit-element");
|
|
7
|
+
|
|
8
|
+
var _marked = require("marked");
|
|
9
|
+
|
|
10
|
+
var _unsafeHtml = require("lit-html/directives/unsafe-html");
|
|
11
|
+
|
|
12
|
+
var _schemaUtils = require("../utils/schema-utils");
|
|
13
|
+
|
|
14
|
+
var _fontStyles = _interopRequireDefault(require("../styles/font-styles"));
|
|
15
|
+
|
|
16
|
+
var _flexStyles = _interopRequireDefault(require("../styles/flex-styles"));
|
|
17
|
+
|
|
18
|
+
var _tableStyles = _interopRequireDefault(require("../styles/table-styles"));
|
|
19
|
+
|
|
20
|
+
var _inputStyles = _interopRequireDefault(require("../styles/input-styles"));
|
|
21
|
+
|
|
22
|
+
var _tabStyles = _interopRequireDefault(require("../styles/tab-styles"));
|
|
23
|
+
|
|
24
|
+
var _borderStyles = _interopRequireDefault(require("../styles/border-styles"));
|
|
25
|
+
|
|
26
|
+
require("./schema-tree");
|
|
27
|
+
|
|
28
|
+
require("./schema-table");
|
|
29
|
+
|
|
30
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
+
|
|
32
|
+
class ApiResponse extends _litElement.LitElement {
|
|
33
|
+
constructor() {
|
|
34
|
+
super();
|
|
35
|
+
this.selectedStatus = '';
|
|
36
|
+
this.headersForEachRespStatus = {};
|
|
37
|
+
this.mimeResponsesForEachStatus = {};
|
|
38
|
+
this.activeSchemaTab = 'model';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static get properties() {
|
|
42
|
+
return {
|
|
43
|
+
callback: {
|
|
44
|
+
type: String
|
|
45
|
+
},
|
|
46
|
+
responses: {
|
|
47
|
+
type: Object
|
|
48
|
+
},
|
|
49
|
+
parser: {
|
|
50
|
+
type: Object
|
|
51
|
+
},
|
|
52
|
+
schemaStyle: {
|
|
53
|
+
type: String,
|
|
54
|
+
attribute: 'schema-style'
|
|
55
|
+
},
|
|
56
|
+
renderStyle: {
|
|
57
|
+
type: String,
|
|
58
|
+
attribute: 'render-style'
|
|
59
|
+
},
|
|
60
|
+
selectedStatus: {
|
|
61
|
+
type: String,
|
|
62
|
+
attribute: 'selected-status'
|
|
63
|
+
},
|
|
64
|
+
selectedMimeType: {
|
|
65
|
+
type: String,
|
|
66
|
+
attribute: 'selected-mime-type'
|
|
67
|
+
},
|
|
68
|
+
activeSchemaTab: {
|
|
69
|
+
type: String,
|
|
70
|
+
attribute: 'active-schema-tab'
|
|
71
|
+
},
|
|
72
|
+
schemaExpandLevel: {
|
|
73
|
+
type: Number,
|
|
74
|
+
attribute: 'schema-expand-level'
|
|
75
|
+
},
|
|
76
|
+
schemaDescriptionExpanded: {
|
|
77
|
+
type: String,
|
|
78
|
+
attribute: 'schema-description-expanded'
|
|
79
|
+
},
|
|
80
|
+
schemaHideWriteOnly: {
|
|
81
|
+
type: String,
|
|
82
|
+
attribute: 'schema-hide-write-only'
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static get styles() {
|
|
88
|
+
return [_fontStyles.default, _flexStyles.default, _tabStyles.default, _tableStyles.default, _inputStyles.default, _borderStyles.default, (0, _litElement.css)`.resp-head{vertical-align:middle;padding:16px 0 8px}.resp-head.divider{border-top:1px solid var(--border-color);margin-top:10px}.resp-status{font-weight:700;font-size:calc(var(--font-size-small) + 1px)}.resp-descr{font-size:calc(var(--font-size-small) + 1px)}.top-gap{margin-top:16px}.example-panel{font-size:var(--font-size-small);margin:0}.generic-tree{background:#333;color:#fff}.example-panel.generic-tree{margin-top:8px}pre.generic-tree{border:none;padding:8px 10px 10px}.example-panel select{margin-left:8px;padding-top:8px;min-width:100px;max-width:100%}.example-panel .example{padding-top:8px}.focused-mode,.read-mode{padding-top:24px;margin-top:12px;border-top:1px dashed var(--border-color)}`];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
render() {
|
|
92
|
+
return (0, _litElement.html)` <div class="col regular-font response-panel ${this.renderStyle}-mode"> <div class="${this.callback === 'true' ? 'tiny-title' : 'req-res-title'}"> ${this.callback === 'true' ? 'CALLBACK RESPONSE' : 'RESPONSE'} </div> <div> ${this.responseTemplate()} <div> </div> </div></div>`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
resetSelection() {
|
|
96
|
+
this.selectedStatus = '';
|
|
97
|
+
this.selectedMimeType = '';
|
|
98
|
+
}
|
|
99
|
+
/* eslint-disable indent */
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
responseTemplate() {
|
|
103
|
+
if (!this.responses) {
|
|
104
|
+
return '';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
for (const statusCode in this.responses) {
|
|
108
|
+
if (!this.selectedStatus) {
|
|
109
|
+
this.selectedStatus = statusCode;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const allMimeResp = {};
|
|
113
|
+
|
|
114
|
+
for (const mimeResp in this.responses[statusCode] && this.responses[statusCode].content) {
|
|
115
|
+
const mimeRespObj = this.responses[statusCode].content[mimeResp];
|
|
116
|
+
|
|
117
|
+
if (!this.selectedMimeType) {
|
|
118
|
+
this.selectedMimeType = mimeResp;
|
|
119
|
+
} // Generate Schema
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
const schemaTree = (0, _schemaUtils.schemaInObjectNotation)(mimeRespObj.schema, {}); // Generate Example
|
|
123
|
+
|
|
124
|
+
const respExamples = (0, _schemaUtils.generateExample)(mimeRespObj.examples || '', mimeRespObj.example || '', mimeRespObj.schema, mimeResp, true, false, mimeResp.includes('json') ? 'json' : 'text');
|
|
125
|
+
allMimeResp[mimeResp] = {
|
|
126
|
+
description: this.responses[statusCode].description,
|
|
127
|
+
examples: respExamples,
|
|
128
|
+
selectedExample: respExamples[0] && respExamples[0].exampleId || '',
|
|
129
|
+
schemaTree
|
|
130
|
+
};
|
|
131
|
+
} // Headers for each response status
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
const tempHeaders = [];
|
|
135
|
+
|
|
136
|
+
for (const key in this.responses[statusCode] && this.responses[statusCode].headers) {
|
|
137
|
+
tempHeaders.push({
|
|
138
|
+
name: key,
|
|
139
|
+
...this.responses[statusCode].headers[key]
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
this.headersForEachRespStatus[statusCode] = tempHeaders;
|
|
144
|
+
this.mimeResponsesForEachStatus[statusCode] = allMimeResp;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return (0, _litElement.html)`<div class="row" style="flex-wrap:wrap"> ${Object.keys(this.responses).map(respStatus => (0, _litElement.html)` ${respStatus === '$$ref' // Swagger-Client parser creates '$$ref' object if JSON references are used to create responses - this should be ignored
|
|
148
|
+
? '' : (0, _litElement.html)` <button @click="${() => {
|
|
149
|
+
this.selectedStatus = respStatus;
|
|
150
|
+
|
|
151
|
+
if (this.responses[respStatus].content && Object.keys(this.responses[respStatus].content)[0]) {
|
|
152
|
+
this.selectedMimeType = Object.keys(this.responses[respStatus].content)[0];
|
|
153
|
+
} else {
|
|
154
|
+
this.selectedMimeType = undefined;
|
|
155
|
+
}
|
|
156
|
+
}}" class="m-btn small ${this.selectedStatus === respStatus ? 'primary' : ''}" part="btn--resp ${this.selectedStatus === respStatus ? 'btn-fill--resp' : 'btn-outline--resp'} btn-response-status" style="margin:8px 4px 0 0"> ${respStatus} </button>`}`)} </div> ${Object.keys(this.responses).map(status => (0, _litElement.html)` <div style="display:${status === this.selectedStatus ? 'block' : 'none'}"> <div class="top-gap"> <span class="resp-descr m-markdown">${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(this.responses[status] && this.responses[status].description || ''))}</span> ${this.headersForEachRespStatus[status] && this.headersForEachRespStatus[status].length > 0 ? (0, _litElement.html)`${this.responseHeaderListTemplate(this.headersForEachRespStatus[status])}` : ''} </div> ${Object.keys(this.mimeResponsesForEachStatus[status]).length === 0 ? '' : (0, _litElement.html)` <div class="tab-panel col"> <div class="tab-buttons row" @click="${e => {
|
|
157
|
+
if (e.target.tagName.toLowerCase() === 'button') {
|
|
158
|
+
this.activeSchemaTab = e.target.dataset.tab;
|
|
159
|
+
}
|
|
160
|
+
}}"> <button class="tab-btn ${this.activeSchemaTab === 'model' ? 'active' : ''}" data-tab="model">MODEL</button> <button class="tab-btn ${this.activeSchemaTab === 'body' ? 'active' : ''}" data-tab="body">EXAMPLE</button> <div style="flex:1"></div> ${Object.keys(this.mimeResponsesForEachStatus[status]).length === 1 ? (0, _litElement.html)`<span class="small-font-size gray-text" style="align-self:center;margin-top:8px"> ${Object.keys(this.mimeResponsesForEachStatus[status])[0]} </span>` : (0, _litElement.html)`${this.mimeTypeDropdownTemplate(Object.keys(this.mimeResponsesForEachStatus[status]))}`} </div> ${this.activeSchemaTab === 'body' ? (0, _litElement.html)`<div class="tab-content col" style="flex:1"> ${this.mimeExampleTemplate(this.mimeResponsesForEachStatus[status][this.selectedMimeType])} </div>` : (0, _litElement.html)`<div class="tab-content col" style="flex:1"> ${this.mimeSchemaTemplate(this.mimeResponsesForEachStatus[status][this.selectedMimeType])} </div>`} </div> `}</div>`)} `;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
responseHeaderListTemplate(respHeaders) {
|
|
164
|
+
return (0, _litElement.html)` <div style="padding:16px 0 8px 0" class="resp-headers small-font-size bold-text">RESPONSE HEADERS</div> <table role="presentation" style="border-collapse:collapse;margin-bottom:16px;border:1px solid var(--border-color);border-radius:var(--border-radius)" class="small-font-size mono-font"> ${respHeaders.map(v => (0, _litElement.html)` <tr> <td style="padding:8px;vertical-align:baseline;min-width:120px;border-top:1px solid var(--light-border-color);text-overflow:ellipsis"> ${v.name || ''} </td> <td style="padding:4px;vertical-align:baseline;padding:0 5px;border-top:1px solid var(--light-border-color);text-overflow:ellipsis"> ${v.schema.type || ''} </td> <td style="padding:8px;vertical-align:baseline;border-top:1px solid var(--light-border-color);text-overflow:ellipsis"> <div class="m-markdown-small regular-font">${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(v.description || ''))}</div> </td> <td style="padding:8px;vertical-align:baseline;border-top:1px solid var(--light-border-color);text-overflow:ellipsis"> ${v.schema.example || ''} </td> </tr> `)} </table>`;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
mimeTypeDropdownTemplate(mimeTypes) {
|
|
168
|
+
return (0, _litElement.html)` <select aria-label="mime type" @change="${e => {
|
|
169
|
+
this.selectedMimeType = e.target.value;
|
|
170
|
+
}}" style="margin-bottom:-1px;z-index:1"> ${mimeTypes.map(mimeType => (0, _litElement.html)`<option value="${mimeType}" ?selected="${mimeType === this.selectedMimeType}"> ${mimeType} </option>`)} </select>`;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
onSelectExample(e) {
|
|
174
|
+
const exampleContainerEl = e.target.closest('.example-panel');
|
|
175
|
+
const exampleEls = [...exampleContainerEl.querySelectorAll('.example')];
|
|
176
|
+
exampleEls.forEach(v => {
|
|
177
|
+
v.style.display = v.dataset.example === e.target.value ? 'block' : 'none';
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
mimeExampleTemplate(mimeRespDetails) {
|
|
182
|
+
if (!mimeRespDetails) {
|
|
183
|
+
return (0, _litElement.html)` <pre style="color:var(--red)" class="example-panel border-top"> No example provided </pre> `;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return (0, _litElement.html)` ${mimeRespDetails.examples.length === 1 ? (0, _litElement.html)` ${mimeRespDetails.examples[0].exampleSummary && mimeRespDetails.examples[0].exampleSummary.length > 80 ? (0, _litElement.html)`<div style="padding:4px 0"> ${mimeRespDetails.examples[0].exampleSummary} </div>` : ''} ${mimeRespDetails.examples[0].exampleDescription ? (0, _litElement.html)`<div class="m-markdown-small" style="padding:4px 0"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(mimeRespDetails.examples[0].exampleDescription || ''))} </div>` : ''} ${mimeRespDetails.examples[0].exampleFormat === 'json' ? (0, _litElement.html)` <json-tree render-style="${this.renderStyle}" .data="${mimeRespDetails.examples[0].exampleValue}" class="example-panel pad-top-8"></json-tree>` : (0, _litElement.html)` <pre class="example-panel generic-tree border-top pad-top-8">${mimeRespDetails.examples[0].exampleValue}</pre> `}` : (0, _litElement.html)` <span class="example-panel generic-tree ${this.renderStyle === 'read' ? 'border pad-8-16' : 'border-top pad-top-8'}"> <select aria-label="response body example" @change="${e => this.onSelectExample(e)}"> ${mimeRespDetails.examples.map(v => (0, _litElement.html)`<option value="${v.exampleId}" ?selected="${v.exampleId === mimeRespDetails.selectedExample}"> ${v.exampleSummary.length > 80 ? v.exampleId : v.exampleSummary} </option>`)} </select> ${mimeRespDetails.examples.map(v => (0, _litElement.html)` <div class="example" data-example="${v.exampleId}" style="display:${v.exampleId === mimeRespDetails.selectedExample ? 'block' : 'none'}"> ${v.exampleSummary && v.exampleSummary.length > 80 ? (0, _litElement.html)`<div style="padding:4px 0"> ${v.exampleSummary} </div>` : ''} ${v.exampleDescription ? (0, _litElement.html)`<div class="m-markdown-small" style="padding:4px 0"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(v.exampleDescription || ''))} </div>` : ''} ${v.exampleFormat === 'json' ? (0, _litElement.html)` <json-tree render-style="${this.renderStyle}" .data="${v.exampleValue}"></json-tree>` : (0, _litElement.html)`<pre class="generic-tree">${v.exampleValue}</pre>`} </div> `)} </span> `} `;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
mimeSchemaTemplate(mimeRespDetails) {
|
|
190
|
+
if (!mimeRespDetails) {
|
|
191
|
+
return (0, _litElement.html)` <pre style="color:var(--red)" class="${this.renderStyle === 'read' ? 'border pad-8-16' : 'border-top'}"> Schema not found</pre> `;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return (0, _litElement.html)` ${this.schemaStyle === 'table' ? (0, _litElement.html)` <schema-table render-style="${this.renderStyle}" .data="${mimeRespDetails.schemaTree}" class="example-panel ${this.renderStyle === 'read' ? 'border pad-8-16' : 'border-top pad-top-8'}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" schema-hide-read-only="false" schema-hide-write-only="${this.schemaHideWriteOnly}"> </schema-table>` : (0, _litElement.html)` <schema-tree render-style="${this.renderStyle}" .data="${mimeRespDetails.schemaTree}" class="example-panel ${this.renderStyle === 'read' ? 'border pad-8-16' : 'pad-top-8'}" schema-expand-level="${this.schemaExpandLevel}" schema-description-expanded="${this.schemaDescriptionExpanded}" schema-hide-read-only="false" schema-hide-write-only="${this.schemaHideWriteOnly}"> </schema-tree>`}`;
|
|
195
|
+
}
|
|
196
|
+
/* eslint-enable indent */
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
} // Register the element with the browser
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
exports.default = ApiResponse;
|
|
203
|
+
|
|
204
|
+
if (!customElements.get('openapi-explorer')) {
|
|
205
|
+
customElements.define('api-response', ApiResponse);
|
|
206
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
|
|
6
|
+
var _litElement = require("lit-element");
|
|
7
|
+
|
|
8
|
+
var _commonUtils = require("../utils/common-utils");
|
|
9
|
+
|
|
10
|
+
var _fontStyles = _interopRequireDefault(require("../styles/font-styles"));
|
|
11
|
+
|
|
12
|
+
var _borderStyles = _interopRequireDefault(require("../styles/border-styles"));
|
|
13
|
+
|
|
14
|
+
var _inputStyles = _interopRequireDefault(require("../styles/input-styles"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
class JsonTree extends _litElement.LitElement {
|
|
19
|
+
static get properties() {
|
|
20
|
+
return {
|
|
21
|
+
data: {
|
|
22
|
+
type: Object
|
|
23
|
+
},
|
|
24
|
+
renderStyle: {
|
|
25
|
+
type: String,
|
|
26
|
+
attribute: 'render-style'
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static get styles() {
|
|
32
|
+
return [_fontStyles.default, _borderStyles.default, _inputStyles.default, (0, _litElement.css)`:host{display:flex}.json-tree{background:#333;color:#fff;padding:8px;min-height:30px;font-family:var(--font-mono);font-size:var(--font-size-small);overflow:hidden;word-break:break-all;flex:1;line-height:calc(var(--font-size-small) + 6px)}.open-bracket{display:inline-block;padding:0 20px 0 0;cursor:pointer;border:1px solid transparent;border-radius:3px}.open-bracket:hover{color:var(--primary-color);background-color:var(--hover-color);border:1px solid var(--border-color)}.inside-bracket{padding-left:16px;border-left:1px dotted var(--border-color)}.open-bracket.collapsed+.inside-bracket,.open-bracket.collapsed+.inside-bracket+.close-bracket{display:none}.string{color:var(--green)}.number{color:var(--blue)}.null{color:var(--red)}.boolean{color:var(--orange)}.object{color:#fff}.toolbar{position:absolute;right:6px;display:flex;align-items:center}`];
|
|
33
|
+
}
|
|
34
|
+
/* eslint-disable indent */
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
render() {
|
|
38
|
+
return (0, _litElement.html)` <div class="json-tree"> <div class="toolbar"> <button class="toolbar-copy-btn" part="btn btn-fill" @click="${e => {
|
|
39
|
+
(0, _commonUtils.copyToClipboard)(JSON.stringify(this.data, null, 2), e);
|
|
40
|
+
}}">Copy</button> </div> ${this.generateTree(this.data, true)} </div> `;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
generateTree(data, isLast = false) {
|
|
44
|
+
if (data === null) {
|
|
45
|
+
return (0, _litElement.html)`<div class="null" style="display:inline">null</div>`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (typeof data === 'object' && data instanceof Date === false) {
|
|
49
|
+
const detailType = Array.isArray(data) ? 'array' : 'pure_object';
|
|
50
|
+
|
|
51
|
+
if (Object.keys(data).length === 0) {
|
|
52
|
+
return (0, _litElement.html)`${Array.isArray(data) ? '[ ],' : '{ },'}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return (0, _litElement.html)` <div class="open-bracket expanded ${detailType === 'array' ? 'array' : 'object'}" @click="${this.toggleExpand}"> ${detailType === 'array' ? '[' : '{'}</div> <div class="inside-bracket"> ${Object.keys(data).map((key, i, a) => (0, _litElement.html)` <div class="item"> ${detailType === 'pure_object' ? (0, _litElement.html)`"${key}":` : ''} ${this.generateTree(data[key], i === a.length - 1)} </div>`)} </div> <div class="close-bracket">${detailType === 'array' ? ']' : '}'}${isLast ? '' : ','}</div> `;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return typeof data === 'string' || data instanceof Date ? (0, _litElement.html)`<span class="${typeof data}">"${data}"</span>${isLast ? '' : ','}` : (0, _litElement.html)`<span class="${typeof data}">${data}</span>${isLast ? '' : ','}`;
|
|
59
|
+
}
|
|
60
|
+
/* eslint-enable indent */
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
toggleExpand(e) {
|
|
64
|
+
const openBracketEl = e.target;
|
|
65
|
+
|
|
66
|
+
if (openBracketEl.classList.contains('expanded')) {
|
|
67
|
+
openBracketEl.classList.replace('expanded', 'collapsed');
|
|
68
|
+
e.target.innerHTML = e.target.classList.contains('array') ? '[...]' : '{...}';
|
|
69
|
+
} else {
|
|
70
|
+
openBracketEl.classList.replace('collapsed', 'expanded');
|
|
71
|
+
e.target.innerHTML = e.target.classList.contains('array') ? '[' : '{';
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
} // Register the element with the browser
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
exports.default = JsonTree;
|
|
79
|
+
|
|
80
|
+
if (!customElements.get('openapi-explorer')) {
|
|
81
|
+
customElements.define('json-tree', JsonTree);
|
|
82
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = extension;
|
|
5
|
+
|
|
6
|
+
var _mimeDb = _interopRequireDefault(require("mime-db"));
|
|
7
|
+
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
|
|
10
|
+
const EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
|
|
11
|
+
/**
|
|
12
|
+
* Get the default extension for a MIME type.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} type
|
|
15
|
+
* @return {boolean|string}
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
function extension(type) {
|
|
19
|
+
if (!type || typeof type !== 'string') {
|
|
20
|
+
return false;
|
|
21
|
+
} // TODO: use media-typer
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const match = EXTRACT_TYPE_REGEXP.exec(type); // get extensions
|
|
25
|
+
|
|
26
|
+
const exts = match && exports.extensions[match[1].toLowerCase()];
|
|
27
|
+
|
|
28
|
+
if (!exts || !exts.length) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return exts[0];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const extensions = {};
|
|
36
|
+
const types = {};
|
|
37
|
+
populateMaps();
|
|
38
|
+
|
|
39
|
+
function populateMaps() {
|
|
40
|
+
// source preference (least -> most)
|
|
41
|
+
const preference = ['nginx', 'apache', undefined, 'iana'];
|
|
42
|
+
Object.keys(_mimeDb.default).forEach(function forEachMimeType(type) {
|
|
43
|
+
const mime = _mimeDb.default[type];
|
|
44
|
+
const exts = mime.extensions;
|
|
45
|
+
|
|
46
|
+
if (!exts || !exts.length) {
|
|
47
|
+
return;
|
|
48
|
+
} // mime -> extensions
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
extensions[type] = exts; // extension -> mime
|
|
52
|
+
|
|
53
|
+
for (let i = 0; i < exts.length; i++) {
|
|
54
|
+
const extensionToTest = exts[i];
|
|
55
|
+
|
|
56
|
+
if (types[extensionToTest]) {
|
|
57
|
+
const from = preference.indexOf(_mimeDb.default[types[extensionToTest]].source);
|
|
58
|
+
const to = preference.indexOf(mime.source);
|
|
59
|
+
|
|
60
|
+
if (types[extensionToTest] !== 'application/octet-stream' && (from > to || from === to && types[extensionToTest].substr(0, 12) === 'application/')) {
|
|
61
|
+
// skip the remapping
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
} // set the extension -> mime
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
types[extensionToTest] = type;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.default = void 0;
|
|
5
|
+
|
|
6
|
+
var _litElement = require("lit-element");
|
|
7
|
+
|
|
8
|
+
var _marked = require("marked");
|
|
9
|
+
|
|
10
|
+
var _unsafeHtml = require("lit-html/directives/unsafe-html");
|
|
11
|
+
|
|
12
|
+
var _fontStyles = _interopRequireDefault(require("../styles/font-styles"));
|
|
13
|
+
|
|
14
|
+
var _schemaStyles = _interopRequireDefault(require("../styles/schema-styles"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
class SchemaTable extends _litElement.LitElement {
|
|
19
|
+
static get properties() {
|
|
20
|
+
return {
|
|
21
|
+
schemaExpandLevel: {
|
|
22
|
+
type: Number,
|
|
23
|
+
attribute: 'schema-expand-level'
|
|
24
|
+
},
|
|
25
|
+
schemaDescriptionExpanded: {
|
|
26
|
+
type: String,
|
|
27
|
+
attribute: 'schema-description-expanded'
|
|
28
|
+
},
|
|
29
|
+
schemaHideReadOnly: {
|
|
30
|
+
type: String,
|
|
31
|
+
attribute: 'schema-hide-read-only'
|
|
32
|
+
},
|
|
33
|
+
schemaHideWriteOnly: {
|
|
34
|
+
type: String,
|
|
35
|
+
attribute: 'schema-hide-write-only'
|
|
36
|
+
},
|
|
37
|
+
data: {
|
|
38
|
+
type: Object
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
connectedCallback() {
|
|
44
|
+
super.connectedCallback();
|
|
45
|
+
|
|
46
|
+
if (!this.schemaExpandLevel || this.schemaExpandLevel < 1) {
|
|
47
|
+
this.schemaExpandLevel = 99999;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!this.schemaDescriptionExpanded || !'true false'.includes(this.schemaDescriptionExpanded)) {
|
|
51
|
+
this.schemaDescriptionExpanded = 'true';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!this.schemaHideReadOnly || !'true false'.includes(this.schemaHideReadOnly)) {
|
|
55
|
+
this.schemaHideReadOnly = 'true';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!this.schemaHideWriteOnly || !'true false'.includes(this.schemaHideWriteOnly)) {
|
|
59
|
+
this.schemaHideWriteOnly = 'true';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static get styles() {
|
|
64
|
+
return [_fontStyles.default, _schemaStyles.default, (0, _litElement.css)`.table{font-size:var(--font-size-small);text-align:left;line-height:calc(var(--font-size-small) + 6px)}.table .tr{width:calc(100% - 5px);padding:0 0 0 5px;border-bottom:1px dotted var(--light-border-color)}.table .td{padding:4px 0}.table .key{width:240px}.key.deprecated .key-label{text-decoration:line-through}.table .key-type{white-space:normal;width:150px}.collapsed-descr .tr{max-height:calc(var(--font-size-small) + var(--font-size-small) + 4px)}.obj-toggle{padding:0 2px;border-radius:2px;border:1px solid transparent;display:inline-block;margin-left:-16px;color:var(--primary-color);cursor:pointer;font-size:calc(var(--font-size-small) + 4px);font-family:var(--font-mono);background-clip:border-box}.obj-toggle:hover{border-color:var(--primary-color)}.tr.expanded+.object-body{display:block}.tr.collapsed+.object-body{display:none}`];
|
|
65
|
+
}
|
|
66
|
+
/* eslint-disable indent */
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
render() {
|
|
70
|
+
return (0, _litElement.html)` <div class="table ${this.schemaDescriptionExpanded === 'true' ? 'expanded-descr' : 'collapsed-descr'}"> <div class="toolbar"> <div style="flex:1"></div> <div class="toolbar-item" @click="${() => {
|
|
71
|
+
this.schemaDescriptionExpanded = this.schemaDescriptionExpanded === 'true' ? 'false' : 'true';
|
|
72
|
+
}}"> ${this.schemaDescriptionExpanded === 'true' ? 'Collapse descriptions' : 'Expand descriptions'} </div> </div> ${this.data && this.data['::description'] ? (0, _litElement.html)`<span class="m-markdown"> ${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(this.data['::description'] || ''))}</span>` : ''} <div style="border:1px solid var(--light-border-color)"> <div style="display:flex;background-color:var(--bg2);padding:8px 4px;border-bottom:1px solid var(--light-border-color)"> <div class="key" style="font-family:var(--font-regular);font-weight:700;color:var(--fg)"> Field </div> <div class="key-type" style="font-family:var(--font-regular);font-weight:700;color:var(--fg)"> Type </div> <div class="key-descr" style="font-family:var(--font-regular);font-weight:700;color:var(--fg)"> Description </div> </div> ${this.data ? (0, _litElement.html)`${this.generateTree(this.data['::type'] === 'array' ? this.data['::props'] : this.data, this.data['::type'])}` : ''} </div> </div> `;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
generateTree(data, dataType = 'object', key = '', description = '', schemaLevel = 0, indentLevel = 0) {
|
|
76
|
+
const newSchemaLevel = data['::type'] && data['::type'].startsWith('xxx-of') ? schemaLevel : schemaLevel + 1;
|
|
77
|
+
const newIndentLevel = dataType === 'xxx-of-option' || data['::type'] === 'xxx-of-option' || key.startsWith('::OPTION') ? indentLevel : indentLevel + 1;
|
|
78
|
+
const leftPadding = 16 * newIndentLevel; // 2 space indentation at each level
|
|
79
|
+
|
|
80
|
+
if (!data) {
|
|
81
|
+
return (0, _litElement.html)`<div class="null" style="display:inline">null</div>`;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (Object.keys(data).length === 0) {
|
|
85
|
+
return (0, _litElement.html)`<span class="td key object" style="padding-left:${leftPadding}px">${key}</span>`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let keyLabel = '';
|
|
89
|
+
let keyDescr = '';
|
|
90
|
+
let isOneOfLabel = false;
|
|
91
|
+
|
|
92
|
+
if (key.startsWith('::ONE~OF') || key.startsWith('::ANY~OF')) {
|
|
93
|
+
keyLabel = key.replace('::', '').replace('~', ' ');
|
|
94
|
+
isOneOfLabel = true;
|
|
95
|
+
} else if (key.startsWith('::OPTION')) {
|
|
96
|
+
const parts = key.split('~');
|
|
97
|
+
keyLabel = parts[1];
|
|
98
|
+
keyDescr = parts[2];
|
|
99
|
+
} else {
|
|
100
|
+
keyLabel = key;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
let detailObjType = '';
|
|
104
|
+
|
|
105
|
+
if (data['::type'] === 'object') {
|
|
106
|
+
if (dataType === 'array') {
|
|
107
|
+
detailObjType = 'array'; // Array of Object
|
|
108
|
+
} else {
|
|
109
|
+
detailObjType = 'object';
|
|
110
|
+
}
|
|
111
|
+
} else if (data['::type'] === 'array') {
|
|
112
|
+
if (dataType === 'array') {
|
|
113
|
+
detailObjType = 'array of array'; // Array of array
|
|
114
|
+
} else {
|
|
115
|
+
detailObjType = 'array';
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (typeof data === 'object') {
|
|
120
|
+
return (0, _litElement.html)` ${newSchemaLevel >= 0 && key ? (0, _litElement.html)` <div class="tr ${newSchemaLevel <= this.schemaExpandLevel ? 'expanded' : 'collapsed'} ${data['::type']}" data-obj="${keyLabel}"> <div class="td key ${data['::deprecated'] ? 'deprecated' : ''}" style="padding-left:${leftPadding}px"> ${keyLabel || keyDescr ? (0, _litElement.html)` <span class="obj-toggle ${newSchemaLevel < this.schemaExpandLevel ? 'expanded' : 'collapsed'}" data-obj="${keyLabel}" @click="${e => this.toggleObjectExpand(e, keyLabel)}"> ${schemaLevel < this.schemaExpandLevel ? '-' : '+'} </span>` : ''} ${data['::type'] === 'xxx-of-option' || data['::type'] === 'xxx-of-array' || key.startsWith('::OPTION') ? (0, _litElement.html)`<span class="xxx-of-key" style="margin-left:-6px">${keyLabel}</span><span class="${isOneOfLabel ? 'xxx-of-key' : 'xxx-of-descr'}">${keyDescr}</span>` : keyLabel.endsWith('*') ? (0, _litElement.html)`<span class="key-label" style="display:inline-block;margin-left:-6px"> ${keyLabel.substring(0, keyLabel.length - 1)}</span><span style="color:var(--red)">*</span>` : (0, _litElement.html)`<span class="key-label" style="display:inline-block;margin-left:-6px">${keyLabel === '::props' ? '' : keyLabel}</span>`} ${data['::type'] === 'xxx-of' && dataType === 'array' ? (0, _litElement.html)`<span style="color:var(--primary-color)">ARRAY</span>` : ''} </div> <div class="td key-type">${(data['::type'] || '').includes('xxx-of') ? '' : detailObjType}</div> <div class="td key-descr m-markdown-small" style="line-height:1.7">${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(description || ''))}</div> </div>` : (0, _litElement.html)` ${data['::type'] === 'array' && dataType === 'array' ? (0, _litElement.html)`<div class="tr"> <div class="td"> ${dataType} </div> </div>` : ''} `} <div class="object-body"> ${Array.isArray(data) && data[0] ? (0, _litElement.html)`${this.generateTree(data[0], 'xxx-of-option', '::ARRAY~OF', '', newSchemaLevel, newIndentLevel)}` : (0, _litElement.html)`${Object.keys(data).map(dataKey => ['::title', '::description', '::type', '::props', '::deprecated'].includes(dataKey) && data[dataKey]['::type'] !== 'array' && data[dataKey]['::type'] !== 'object' ? '' : (0, _litElement.html)`${this.generateTree(data[dataKey]['::type'] === 'array' ? data[dataKey]['::props'] : data[dataKey], data[dataKey]['::type'], dataKey, data[dataKey]['::description'], newSchemaLevel, newIndentLevel)}`)}`} <div> </div></div>`;
|
|
121
|
+
} // For Primitive Data types
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
const {
|
|
125
|
+
type,
|
|
126
|
+
readOrWriteOnly,
|
|
127
|
+
constraint,
|
|
128
|
+
defaultValue,
|
|
129
|
+
allowedValues,
|
|
130
|
+
pattern,
|
|
131
|
+
schemaDescription,
|
|
132
|
+
schemaTitle,
|
|
133
|
+
deprecated
|
|
134
|
+
} = JSON.parse(data);
|
|
135
|
+
|
|
136
|
+
if (readOrWriteOnly === '🆁' && this.schemaHideReadOnly === 'true') {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (readOrWriteOnly === '🆆' && this.schemaHideWriteOnly === 'true') {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const dataTypeCss = type.replace(/┃.*/g, '').replace(/[^a-zA-Z0-9+]/g, '').substring(0, 4).toLowerCase();
|
|
145
|
+
return (0, _litElement.html)` <div class="tr primitive"> <div class="td key ${deprecated ? 'deprecated' : ''}" style="padding-left:${leftPadding}px"> ${keyLabel && keyLabel.endsWith('*') ? (0, _litElement.html)`<span class="key-label">${keyLabel.substring(0, keyLabel.length - 1)}</span><span style="color:var(--red)">*</span>` : key.startsWith('::OPTION') ? (0, _litElement.html)`<span class="xxx-of-key">${keyLabel}</span><span class="xxx-of-descr">${keyDescr}</span>` : (0, _litElement.html)`${keyLabel ? (0, _litElement.html)`<span class="key-label"> ${keyLabel}</span>` : (0, _litElement.html)`<span class="xxx-of-descr">${schemaTitle}</span>`}`} </div> <div class="td key-type ${dataTypeCss}"> ${dataType === 'array' ? `${type}[]` : type} <span style="font-family:var(--font-mono)" title="${readOrWriteOnly === '🆁' && 'Read only attribute' || readOrWriteOnly === '🆆' && 'Write only attribute' || ''}"> ${readOrWriteOnly} </span> </div> <div class="td key-descr"> ${dataType === 'array' ? (0, _litElement.html)`<span class="m-markdown-small">${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(description))}</span>` : ''} ${schemaTitle || schemaDescription ? (0, _litElement.html)`<span class="m-markdown-small">${(0, _unsafeHtml.unsafeHTML)((0, _marked.marked)(`${schemaTitle ? `**${schemaTitle}:** ` : ''}${schemaDescription || ''}`))}</span>` : ''} ${constraint ? (0, _litElement.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"> <span class="bold-text">Constraints: </span> ${constraint}</div>` : ''} ${defaultValue ? (0, _litElement.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"> <span class="bold-text">Default: </span>${defaultValue}</div>` : ''} ${allowedValues ? (0, _litElement.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"> <span class="bold-text">Allowed: </span>${allowedValues}</div>` : ''} ${pattern ? (0, _litElement.html)`<div style="display:inline-block;line-break:anywhere;margin-right:8px"> <span class="bold-text">Pattern: </span>${pattern}</div>` : ''} </div> </div> `;
|
|
146
|
+
}
|
|
147
|
+
/* eslint-enable indent */
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
toggleObjectExpand(e) {
|
|
151
|
+
const rowEl = e.target.closest('.tr');
|
|
152
|
+
|
|
153
|
+
if (rowEl.classList.contains('expanded')) {
|
|
154
|
+
rowEl.classList.add('collapsed');
|
|
155
|
+
rowEl.classList.remove('expanded');
|
|
156
|
+
e.target.innerText = '+';
|
|
157
|
+
} else {
|
|
158
|
+
rowEl.classList.remove('collapsed');
|
|
159
|
+
rowEl.classList.add('expanded');
|
|
160
|
+
e.target.innerText = '-';
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
exports.default = SchemaTable;
|
|
167
|
+
|
|
168
|
+
if (!customElements.get('openapi-explorer')) {
|
|
169
|
+
customElements.define('schema-table', SchemaTable);
|
|
170
|
+
}
|