@stoplight/elements 9.0.10 → 9.0.12-beta-0.1
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/.storybook/main.js +6 -0
- package/.storybook/manager.js +1 -0
- package/.storybook/preview.jsx +3 -0
- package/jest.config.js +7 -0
- package/package.json +76 -16
- package/src/__fixtures__/api-descriptions/Instagram.ts +1859 -0
- package/src/__fixtures__/api-descriptions/badgesForSchema.ts +36 -0
- package/src/__fixtures__/api-descriptions/simpleApiWithInternalOperations.ts +253 -0
- package/src/__fixtures__/api-descriptions/simpleApiWithoutDescription.ts +243 -0
- package/src/__fixtures__/api-descriptions/todosApiBundled.ts +430 -0
- package/src/__fixtures__/api-descriptions/zoomApiYaml.ts +6083 -0
- package/src/components/API/APIWithResponsiveSidebarLayout.tsx +125 -0
- package/src/components/API/APIWithSidebarLayout.tsx +158 -0
- package/src/components/API/APIWithStackedLayout.tsx +286 -0
- package/src/components/API/__tests__/utils.test.ts +1323 -0
- package/src/components/API/utils.ts +206 -0
- package/src/containers/API.spec.tsx +122 -0
- package/src/containers/API.stories.tsx +117 -0
- package/src/containers/API.tsx +277 -0
- package/src/containers/story-helper.tsx +53 -0
- package/src/hooks/useExportDocumentProps.spec.tsx +68 -0
- package/src/hooks/useExportDocumentProps.tsx +48 -0
- package/src/styles.css +1 -0
- package/src/utils/oas/__tests__/oas.spec.ts +411 -0
- package/src/utils/oas/index.ts +192 -0
- package/src/utils/oas/oas2.ts +31 -0
- package/src/utils/oas/oas3.ts +54 -0
- package/src/utils/oas/types.ts +34 -0
- package/src/web-components/__stories__/Api.stories.tsx +63 -0
- package/src/web-components/components.ts +26 -0
- package/src/web-components/index.ts +3 -0
- package/tsconfig.build.json +18 -0
- package/tsconfig.json +7 -0
- package/web-components.config.js +1 -0
- package/__fixtures__/api-descriptions/Instagram.d.ts +0 -1547
- package/__fixtures__/api-descriptions/badgesForSchema.d.ts +0 -1
- package/__fixtures__/api-descriptions/simpleApiWithInternalOperations.d.ts +0 -224
- package/__fixtures__/api-descriptions/simpleApiWithoutDescription.d.ts +0 -212
- package/__fixtures__/api-descriptions/todosApiBundled.d.ts +0 -1
- package/__fixtures__/api-descriptions/zoomApiYaml.d.ts +0 -1
- package/components/API/APIWithResponsiveSidebarLayout.d.ts +0 -25
- package/components/API/APIWithSidebarLayout.d.ts +0 -32
- package/components/API/APIWithStackedLayout.d.ts +0 -29
- package/components/API/utils.d.ts +0 -20
- package/containers/API.d.ts +0 -30
- package/containers/API.spec.d.ts +0 -1
- package/containers/API.stories.d.ts +0 -58
- package/containers/story-helper.d.ts +0 -2
- package/hooks/useExportDocumentProps.d.ts +0 -11
- package/hooks/useExportDocumentProps.spec.d.ts +0 -1
- package/index.esm.js +0 -657
- package/index.js +0 -681
- package/index.mjs +0 -657
- package/styles.min.css +0 -1
- package/utils/oas/index.d.ts +0 -3
- package/utils/oas/oas2.d.ts +0 -2
- package/utils/oas/oas3.d.ts +0 -2
- package/utils/oas/types.d.ts +0 -33
- package/web-components/components.d.ts +0 -1
- package/web-components/index.d.ts +0 -1
- package/web-components.min.js +0 -2
- package/web-components.min.js.LICENSE.txt +0 -176
- /package/{index.d.ts → src/index.ts} +0 -0
package/index.js
DELETED
|
@@ -1,681 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var elementsCore = require('@stoplight/elements-core');
|
|
4
|
-
var mosaic = require('@stoplight/mosaic');
|
|
5
|
-
var types = require('@stoplight/types');
|
|
6
|
-
var cn = require('classnames');
|
|
7
|
-
var React = require('react');
|
|
8
|
-
var defaults = require('lodash/defaults.js');
|
|
9
|
-
var flow = require('lodash/flow.js');
|
|
10
|
-
var reactQuery = require('react-query');
|
|
11
|
-
var reactRouterDom = require('react-router-dom');
|
|
12
|
-
var yaml = require('@stoplight/yaml');
|
|
13
|
-
var saver = require('file-saver');
|
|
14
|
-
var oas = require('@stoplight/http-spec/oas');
|
|
15
|
-
var oas2 = require('@stoplight/http-spec/oas2');
|
|
16
|
-
var oas3 = require('@stoplight/http-spec/oas3');
|
|
17
|
-
var json = require('@stoplight/json');
|
|
18
|
-
var get = require('lodash/get.js');
|
|
19
|
-
var isObject = require('lodash/isObject.js');
|
|
20
|
-
var last = require('lodash/last.js');
|
|
21
|
-
|
|
22
|
-
function _interopNamespaceDefault(e) {
|
|
23
|
-
var n = Object.create(null);
|
|
24
|
-
if (e) {
|
|
25
|
-
Object.keys(e).forEach(function (k) {
|
|
26
|
-
if (k !== 'default') {
|
|
27
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
28
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
get: function () { return e[k]; }
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
n.default = e;
|
|
36
|
-
return Object.freeze(n);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
40
|
-
|
|
41
|
-
function computeTagGroups(serviceNode, nodeType) {
|
|
42
|
-
const groupsByTagId = {};
|
|
43
|
-
const ungrouped = [];
|
|
44
|
-
const lowerCaseServiceTags = serviceNode.tags.map(tn => tn.toLowerCase());
|
|
45
|
-
const groupableNodes = serviceNode.children.filter(n => n.type === nodeType);
|
|
46
|
-
for (const node of groupableNodes) {
|
|
47
|
-
for (const tagName of node.tags) {
|
|
48
|
-
const tagId = tagName.toLowerCase();
|
|
49
|
-
if (groupsByTagId[tagId]) {
|
|
50
|
-
groupsByTagId[tagId].items.push(node);
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
const serviceTagIndex = lowerCaseServiceTags.findIndex(tn => tn === tagId);
|
|
54
|
-
const serviceTagName = serviceNode.tags[serviceTagIndex];
|
|
55
|
-
groupsByTagId[tagId] = {
|
|
56
|
-
title: serviceTagName || tagName,
|
|
57
|
-
items: [node],
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
if (node.tags.length === 0) {
|
|
62
|
-
ungrouped.push(node);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
const orderedTagGroups = Object.entries(groupsByTagId)
|
|
66
|
-
.sort(([g1], [g2]) => {
|
|
67
|
-
const g1LC = g1.toLowerCase();
|
|
68
|
-
const g2LC = g2.toLowerCase();
|
|
69
|
-
const g1Idx = lowerCaseServiceTags.findIndex(tn => tn === g1LC);
|
|
70
|
-
const g2Idx = lowerCaseServiceTags.findIndex(tn => tn === g2LC);
|
|
71
|
-
if (g1Idx < 0 && g2Idx < 0)
|
|
72
|
-
return 0;
|
|
73
|
-
if (g1Idx < 0)
|
|
74
|
-
return 1;
|
|
75
|
-
if (g2Idx < 0)
|
|
76
|
-
return -1;
|
|
77
|
-
return g1Idx - g2Idx;
|
|
78
|
-
})
|
|
79
|
-
.map(([, tagGroup]) => tagGroup);
|
|
80
|
-
return { groups: orderedTagGroups, ungrouped };
|
|
81
|
-
}
|
|
82
|
-
const defaultComputerAPITreeConfig = {
|
|
83
|
-
hideSchemas: false,
|
|
84
|
-
hideInternal: false,
|
|
85
|
-
};
|
|
86
|
-
const computeAPITree = (serviceNode, config = {}) => {
|
|
87
|
-
const mergedConfig = defaults(config, defaultComputerAPITreeConfig);
|
|
88
|
-
const tree = [];
|
|
89
|
-
tree.push({
|
|
90
|
-
id: '/',
|
|
91
|
-
slug: '/',
|
|
92
|
-
title: 'Overview',
|
|
93
|
-
type: 'overview',
|
|
94
|
-
meta: '',
|
|
95
|
-
});
|
|
96
|
-
const hasOperationNodes = serviceNode.children.some(node => node.type === types.NodeType.HttpOperation);
|
|
97
|
-
if (hasOperationNodes) {
|
|
98
|
-
tree.push({
|
|
99
|
-
title: 'Endpoints',
|
|
100
|
-
});
|
|
101
|
-
const { groups, ungrouped } = computeTagGroups(serviceNode, types.NodeType.HttpOperation);
|
|
102
|
-
addTagGroupsToTree(groups, ungrouped, tree, types.NodeType.HttpOperation, mergedConfig.hideInternal);
|
|
103
|
-
}
|
|
104
|
-
const hasWebhookNodes = serviceNode.children.some(node => node.type === types.NodeType.HttpWebhook);
|
|
105
|
-
if (hasWebhookNodes) {
|
|
106
|
-
tree.push({
|
|
107
|
-
title: 'Webhooks',
|
|
108
|
-
});
|
|
109
|
-
const { groups, ungrouped } = computeTagGroups(serviceNode, types.NodeType.HttpWebhook);
|
|
110
|
-
addTagGroupsToTree(groups, ungrouped, tree, types.NodeType.HttpWebhook, mergedConfig.hideInternal);
|
|
111
|
-
}
|
|
112
|
-
let schemaNodes = serviceNode.children.filter(node => node.type === types.NodeType.Model);
|
|
113
|
-
if (mergedConfig.hideInternal) {
|
|
114
|
-
schemaNodes = schemaNodes.filter(n => !isInternal(n));
|
|
115
|
-
}
|
|
116
|
-
if (!mergedConfig.hideSchemas && schemaNodes.length) {
|
|
117
|
-
tree.push({
|
|
118
|
-
title: 'Schemas',
|
|
119
|
-
});
|
|
120
|
-
const { groups, ungrouped } = computeTagGroups(serviceNode, types.NodeType.Model);
|
|
121
|
-
addTagGroupsToTree(groups, ungrouped, tree, types.NodeType.Model, mergedConfig.hideInternal);
|
|
122
|
-
}
|
|
123
|
-
return tree;
|
|
124
|
-
};
|
|
125
|
-
const findFirstNodeSlug = (tree) => {
|
|
126
|
-
for (const item of tree) {
|
|
127
|
-
if ('slug' in item) {
|
|
128
|
-
return item.slug;
|
|
129
|
-
}
|
|
130
|
-
if ('items' in item) {
|
|
131
|
-
const slug = findFirstNodeSlug(item.items);
|
|
132
|
-
if (slug) {
|
|
133
|
-
return slug;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return;
|
|
138
|
-
};
|
|
139
|
-
const isInternal = (node) => {
|
|
140
|
-
const data = node.data;
|
|
141
|
-
if (elementsCore.isHttpOperation(data) || elementsCore.isHttpWebhookOperation(data)) {
|
|
142
|
-
return !!data.internal;
|
|
143
|
-
}
|
|
144
|
-
if (elementsCore.isHttpService(data)) {
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
return !!data['x-internal'];
|
|
148
|
-
};
|
|
149
|
-
const addTagGroupsToTree = (groups, ungrouped, tree, itemsType, hideInternal) => {
|
|
150
|
-
ungrouped.forEach(node => {
|
|
151
|
-
if (hideInternal && isInternal(node)) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
tree.push({
|
|
155
|
-
id: node.uri,
|
|
156
|
-
slug: node.uri,
|
|
157
|
-
title: node.name,
|
|
158
|
-
type: node.type,
|
|
159
|
-
meta: elementsCore.isHttpOperation(node.data) || elementsCore.isHttpWebhookOperation(node.data) ? node.data.method : '',
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
groups.forEach(group => {
|
|
163
|
-
const items = group.items.flatMap(node => {
|
|
164
|
-
if (hideInternal && isInternal(node)) {
|
|
165
|
-
return [];
|
|
166
|
-
}
|
|
167
|
-
return {
|
|
168
|
-
id: node.uri,
|
|
169
|
-
slug: node.uri,
|
|
170
|
-
title: node.name,
|
|
171
|
-
type: node.type,
|
|
172
|
-
meta: elementsCore.isHttpOperation(node.data) || elementsCore.isHttpWebhookOperation(node.data) ? node.data.method : '',
|
|
173
|
-
};
|
|
174
|
-
});
|
|
175
|
-
if (items.length > 0) {
|
|
176
|
-
tree.push({
|
|
177
|
-
title: group.title,
|
|
178
|
-
items,
|
|
179
|
-
itemsType,
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
};
|
|
184
|
-
const resolveRelativePath = (currentPath, basePath, outerRouter) => {
|
|
185
|
-
if (!outerRouter || !basePath || basePath === '/') {
|
|
186
|
-
return currentPath;
|
|
187
|
-
}
|
|
188
|
-
const baseUrl = elementsCore.resolveUrl(basePath);
|
|
189
|
-
const currentUrl = elementsCore.resolveUrl(currentPath);
|
|
190
|
-
return baseUrl && currentUrl && baseUrl !== currentUrl ? currentUrl.replace(baseUrl, '') : '/';
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
const itemMatchesHash = (hash, item) => {
|
|
194
|
-
if (item.type === types.NodeType.HttpOperation) {
|
|
195
|
-
return hash.substr(1) === `${item.data.path}-${item.data.method}`;
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
return hash.substr(1) === `${item.data.name}-${item.data.method}`;
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
const TryItContext = React__namespace.createContext({
|
|
202
|
-
hideTryIt: false,
|
|
203
|
-
hideTryItPanel: false,
|
|
204
|
-
hideSamples: false,
|
|
205
|
-
tryItCredentialsPolicy: 'omit',
|
|
206
|
-
});
|
|
207
|
-
TryItContext.displayName = 'TryItContext';
|
|
208
|
-
const LocationContext = React__namespace.createContext({
|
|
209
|
-
location: {
|
|
210
|
-
hash: '',
|
|
211
|
-
key: '',
|
|
212
|
-
pathname: '',
|
|
213
|
-
search: '',
|
|
214
|
-
state: '',
|
|
215
|
-
},
|
|
216
|
-
});
|
|
217
|
-
LocationContext.displayName = 'LocationContext';
|
|
218
|
-
const APIWithStackedLayout = ({ serviceNode, hideTryItPanel, hideTryIt, hideSamples, hideExport, hideSecurityInfo, hideServerInfo, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, showPoweredByLink = true, location, }) => {
|
|
219
|
-
const { groups: operationGroups } = computeTagGroups(serviceNode, types.NodeType.HttpOperation);
|
|
220
|
-
const { groups: webhookGroups } = computeTagGroups(serviceNode, types.NodeType.HttpWebhook);
|
|
221
|
-
return (React__namespace.createElement(LocationContext.Provider, { value: { location } },
|
|
222
|
-
React__namespace.createElement(TryItContext.Provider, { value: { hideTryItPanel, hideTryIt, hideSamples, tryItCredentialsPolicy, corsProxy: tryItCorsProxy } },
|
|
223
|
-
React__namespace.createElement(mosaic.Flex, { w: "full", flexDirection: "col", m: "auto", className: "sl-max-w-4xl" },
|
|
224
|
-
React__namespace.createElement(mosaic.Box, { w: "full", borderB: true },
|
|
225
|
-
React__namespace.createElement(elementsCore.Docs, { className: "sl-mx-auto", nodeData: serviceNode.data, nodeTitle: serviceNode.name, nodeType: types.NodeType.HttpService, location: location, layoutOptions: { showPoweredByLink, hideExport, hideSecurityInfo, hideServerInfo }, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, renderExtensionAddon: renderExtensionAddon })),
|
|
226
|
-
operationGroups.length > 0 && webhookGroups.length > 0 ? React__namespace.createElement(mosaic.Heading, { size: 2 }, "Endpoints") : null,
|
|
227
|
-
operationGroups.map(group => (React__namespace.createElement(Group, { key: group.title, group: group }))),
|
|
228
|
-
webhookGroups.length > 0 ? React__namespace.createElement(mosaic.Heading, { size: 2 }, "Webhooks") : null,
|
|
229
|
-
webhookGroups.map(group => (React__namespace.createElement(Group, { key: group.title, group: group })))))));
|
|
230
|
-
};
|
|
231
|
-
APIWithStackedLayout.displayName = 'APIWithStackedLayout';
|
|
232
|
-
const Group = React__namespace.memo(({ group }) => {
|
|
233
|
-
const [isExpanded, setIsExpanded] = React__namespace.useState(false);
|
|
234
|
-
const scrollRef = React__namespace.useRef(null);
|
|
235
|
-
const { location: { hash }, } = React__namespace.useContext(LocationContext);
|
|
236
|
-
const urlHashMatches = hash.substr(1) === group.title;
|
|
237
|
-
const onClick = React__namespace.useCallback(() => setIsExpanded(!isExpanded), [isExpanded]);
|
|
238
|
-
const shouldExpand = React__namespace.useMemo(() => {
|
|
239
|
-
return urlHashMatches || group.items.some(item => itemMatchesHash(hash, item));
|
|
240
|
-
}, [group, hash, urlHashMatches]);
|
|
241
|
-
React__namespace.useEffect(() => {
|
|
242
|
-
var _a;
|
|
243
|
-
if (shouldExpand) {
|
|
244
|
-
setIsExpanded(true);
|
|
245
|
-
if (urlHashMatches && ((_a = scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) === null || _a === void 0 ? void 0 : _a.offsetTop)) {
|
|
246
|
-
window.scrollTo(0, scrollRef.current.offsetTop);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}, [shouldExpand, urlHashMatches, group, hash]);
|
|
250
|
-
return (React__namespace.createElement(mosaic.Box, null,
|
|
251
|
-
React__namespace.createElement(mosaic.Flex, { ref: scrollRef, onClick: onClick, mx: "auto", justifyContent: "between", alignItems: "center", borderB: true, px: 2, py: 4, cursor: "pointer", color: { default: 'current', hover: 'muted' } },
|
|
252
|
-
React__namespace.createElement(mosaic.Box, { fontSize: "lg", fontWeight: "medium" }, group.title),
|
|
253
|
-
React__namespace.createElement(mosaic.Icon, { className: "sl-mr-2", icon: isExpanded ? 'chevron-down' : 'chevron-right', size: "sm" })),
|
|
254
|
-
React__namespace.createElement(Collapse, { isOpen: isExpanded }, group.items.map(item => {
|
|
255
|
-
return React__namespace.createElement(Item, { key: item.uri, item: item });
|
|
256
|
-
}))));
|
|
257
|
-
});
|
|
258
|
-
Group.displayName = 'Group';
|
|
259
|
-
const Item = React__namespace.memo(({ item }) => {
|
|
260
|
-
const { location } = React__namespace.useContext(LocationContext);
|
|
261
|
-
const { hash } = location;
|
|
262
|
-
const [isExpanded, setIsExpanded] = React__namespace.useState(false);
|
|
263
|
-
const scrollRef = React__namespace.useRef(null);
|
|
264
|
-
const color = elementsCore.HttpMethodColors[item.data.method] || 'gray';
|
|
265
|
-
const isDeprecated = !!item.data.deprecated;
|
|
266
|
-
const { hideTryIt, hideSamples, hideTryItPanel, tryItCredentialsPolicy, corsProxy } = React__namespace.useContext(TryItContext);
|
|
267
|
-
const onClick = React__namespace.useCallback(() => setIsExpanded(!isExpanded), [isExpanded]);
|
|
268
|
-
React__namespace.useEffect(() => {
|
|
269
|
-
var _a;
|
|
270
|
-
if (itemMatchesHash(hash, item)) {
|
|
271
|
-
setIsExpanded(true);
|
|
272
|
-
if ((_a = scrollRef === null || scrollRef === void 0 ? void 0 : scrollRef.current) === null || _a === void 0 ? void 0 : _a.offsetTop) {
|
|
273
|
-
window.scrollTo(0, scrollRef.current.offsetTop);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}, [hash, item]);
|
|
277
|
-
return (React__namespace.createElement(mosaic.Box, { ref: scrollRef, w: "full", my: 2, border: true, borderColor: { default: isExpanded ? 'light' : 'transparent', hover: 'light' }, bg: { default: isExpanded ? 'code' : 'transparent', hover: 'code' } },
|
|
278
|
-
React__namespace.createElement(mosaic.Flex, { mx: "auto", alignItems: "center", cursor: "pointer", fontSize: "lg", p: 2, onClick: onClick, color: "current" },
|
|
279
|
-
React__namespace.createElement(mosaic.Box, { w: 24, textTransform: "uppercase", textAlign: "center", fontWeight: "semibold", border: true, rounded: true, px: 2, bg: "canvas", className: cn(`sl-mr-5 sl-text-base`, `sl-text-${color}`, `sl-border-${color}`) }, item.data.method || 'UNKNOWN'),
|
|
280
|
-
React__namespace.createElement(mosaic.Box, { flex: 1, fontWeight: "medium", wordBreak: "all" }, item.type === types.NodeType.HttpOperation ? item.data.path : item.name),
|
|
281
|
-
isDeprecated && React__namespace.createElement(elementsCore.DeprecatedBadge, null)),
|
|
282
|
-
React__namespace.createElement(Collapse, { isOpen: isExpanded },
|
|
283
|
-
React__namespace.createElement(mosaic.Box, { flex: 1, p: 2, fontWeight: "medium", mx: "auto", fontSize: "xl" }, item.name),
|
|
284
|
-
hideTryItPanel ? (React__namespace.createElement(mosaic.Box, { as: elementsCore.ParsedDocs, layoutOptions: { noHeading: true, hideTryItPanel: true, hideSamples, hideTryIt }, node: item, p: 4 })) : (React__namespace.createElement(mosaic.Tabs, { appearance: "line" },
|
|
285
|
-
React__namespace.createElement(mosaic.TabList, null,
|
|
286
|
-
React__namespace.createElement(mosaic.Tab, null, "Docs"),
|
|
287
|
-
React__namespace.createElement(mosaic.Tab, null, "TryIt")),
|
|
288
|
-
React__namespace.createElement(mosaic.TabPanels, null,
|
|
289
|
-
React__namespace.createElement(mosaic.TabPanel, null,
|
|
290
|
-
React__namespace.createElement(elementsCore.ParsedDocs, { className: "sl-px-4", node: item, location: location, layoutOptions: { noHeading: true, hideTryItPanel: false, hideSamples, hideTryIt } })),
|
|
291
|
-
React__namespace.createElement(mosaic.TabPanel, null,
|
|
292
|
-
React__namespace.createElement(elementsCore.TryItWithRequestSamples, { httpOperation: item.data, tryItCredentialsPolicy: tryItCredentialsPolicy, corsProxy: corsProxy, hideSamples: hideSamples, hideTryIt: hideTryIt }))))))));
|
|
293
|
-
});
|
|
294
|
-
Item.displayName = 'Item';
|
|
295
|
-
const Collapse = ({ isOpen, children }) => {
|
|
296
|
-
if (!isOpen)
|
|
297
|
-
return null;
|
|
298
|
-
return React__namespace.createElement(mosaic.Box, null, children);
|
|
299
|
-
};
|
|
300
|
-
Collapse.displayName = 'Collapse';
|
|
301
|
-
|
|
302
|
-
const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryItPanel, hideTryIt, hideSamples, compact, hideSchemas, hideInternal, hideExport, hideServerInfo, hideSecurityInfo, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, basePath = '/', outerRouter = false, }) => {
|
|
303
|
-
const container = React__namespace.useRef(null);
|
|
304
|
-
const tree = React__namespace.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
|
|
305
|
-
const location = reactRouterDom.useLocation();
|
|
306
|
-
const { pathname: currentPath } = location;
|
|
307
|
-
const relativePath = resolveRelativePath(currentPath, basePath, outerRouter);
|
|
308
|
-
const isRootPath = relativePath === '/';
|
|
309
|
-
const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === relativePath);
|
|
310
|
-
const layoutOptions = React__namespace.useMemo(() => ({
|
|
311
|
-
hideTryIt: hideTryIt,
|
|
312
|
-
hideTryItPanel,
|
|
313
|
-
hideSamples,
|
|
314
|
-
hideSecurityInfo: hideSecurityInfo,
|
|
315
|
-
hideServerInfo: hideServerInfo,
|
|
316
|
-
compact: compact,
|
|
317
|
-
hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== types.NodeType.HttpService,
|
|
318
|
-
}), [hideTryIt, hideSecurityInfo, hideServerInfo, compact, hideExport, hideTryItPanel, hideSamples, node === null || node === void 0 ? void 0 : node.type]);
|
|
319
|
-
if (!node) {
|
|
320
|
-
const firstSlug = findFirstNodeSlug(tree);
|
|
321
|
-
if (firstSlug) {
|
|
322
|
-
return React__namespace.createElement(reactRouterDom.Navigate, { to: elementsCore.resolveRelativeLink(firstSlug), replace: true });
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
if (hideInternal && node && isInternal(node)) {
|
|
326
|
-
return React__namespace.createElement(reactRouterDom.Navigate, { to: ".", replace: true });
|
|
327
|
-
}
|
|
328
|
-
const handleTocClick = () => {
|
|
329
|
-
if (container.current) {
|
|
330
|
-
container.current.scrollIntoView();
|
|
331
|
-
}
|
|
332
|
-
};
|
|
333
|
-
return (React__namespace.createElement(elementsCore.ResponsiveSidebarLayout, { onTocClick: handleTocClick, tree: tree, logo: logo !== null && logo !== void 0 ? logo : serviceNode.data.logo, ref: container, name: serviceNode.name }, node && (React__namespace.createElement(elementsCore.ElementsOptionsProvider, { renderExtensionAddon: renderExtensionAddon },
|
|
334
|
-
React__namespace.createElement(elementsCore.ParsedDocs, { key: relativePath, uri: relativePath, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon })))));
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
const APIWithSidebarLayout = ({ serviceNode, logo, hideTryItPanel, hideTryIt, hideSamples, hideSchemas, hideSecurityInfo, hideServerInfo, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, basePath = '/', outerRouter = false, }) => {
|
|
338
|
-
const container = React__namespace.useRef(null);
|
|
339
|
-
const tree = React__namespace.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
|
|
340
|
-
const location = reactRouterDom.useLocation();
|
|
341
|
-
const { pathname: currentPath } = location;
|
|
342
|
-
const relativePath = resolveRelativePath(currentPath, basePath, outerRouter);
|
|
343
|
-
const isRootPath = relativePath === '/';
|
|
344
|
-
const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === relativePath);
|
|
345
|
-
const layoutOptions = React__namespace.useMemo(() => ({
|
|
346
|
-
hideTryIt: hideTryIt,
|
|
347
|
-
hideTryItPanel,
|
|
348
|
-
hideSamples,
|
|
349
|
-
hideServerInfo: hideServerInfo,
|
|
350
|
-
hideSecurityInfo: hideSecurityInfo,
|
|
351
|
-
hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== types.NodeType.HttpService,
|
|
352
|
-
}), [hideTryIt, hideServerInfo, hideSecurityInfo, hideExport, hideTryItPanel, hideSamples, node === null || node === void 0 ? void 0 : node.type]);
|
|
353
|
-
if (!node) {
|
|
354
|
-
const firstSlug = findFirstNodeSlug(tree);
|
|
355
|
-
if (firstSlug) {
|
|
356
|
-
return React__namespace.createElement(reactRouterDom.Navigate, { to: elementsCore.resolveRelativeLink(firstSlug), replace: true });
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
if (hideInternal && node && isInternal(node)) {
|
|
360
|
-
return React__namespace.createElement(reactRouterDom.Navigate, { to: ".", replace: true });
|
|
361
|
-
}
|
|
362
|
-
const sidebar = (React__namespace.createElement(Sidebar, { serviceNode: serviceNode, logo: logo, container: container, pathname: relativePath, tree: tree }));
|
|
363
|
-
return (React__namespace.createElement(elementsCore.SidebarLayout, { ref: container, sidebar: sidebar }, node && (React__namespace.createElement(elementsCore.ElementsOptionsProvider, { renderExtensionAddon: renderExtensionAddon },
|
|
364
|
-
React__namespace.createElement(elementsCore.ParsedDocs, { key: relativePath, uri: relativePath, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon })))));
|
|
365
|
-
};
|
|
366
|
-
const Sidebar = ({ serviceNode, logo, container, pathname, tree }) => {
|
|
367
|
-
const handleTocClick = () => {
|
|
368
|
-
if (container.current) {
|
|
369
|
-
container.current.scrollIntoView();
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
return (React__namespace.createElement(React__namespace.Fragment, null,
|
|
373
|
-
React__namespace.createElement(mosaic.Flex, { ml: 4, mb: 5, alignItems: "center" },
|
|
374
|
-
logo ? (React__namespace.createElement(elementsCore.Logo, { logo: { url: logo, altText: 'logo' } })) : (serviceNode.data.logo && React__namespace.createElement(elementsCore.Logo, { logo: serviceNode.data.logo })),
|
|
375
|
-
React__namespace.createElement(mosaic.Heading, { size: 4 }, serviceNode.name)),
|
|
376
|
-
React__namespace.createElement(mosaic.Flex, { flexGrow: true, flexShrink: true, overflowY: "auto", direction: "col" },
|
|
377
|
-
React__namespace.createElement(elementsCore.TableOfContents, { tree: tree, activeId: pathname, Link: reactRouterDom.Link, onLinkClick: handleTocClick })),
|
|
378
|
-
React__namespace.createElement(elementsCore.PoweredByLink, { source: serviceNode.name, pathname: pathname, packageType: "elements" })));
|
|
379
|
-
};
|
|
380
|
-
Sidebar.displayName = 'Sidebar';
|
|
381
|
-
|
|
382
|
-
var NodeTypes;
|
|
383
|
-
(function (NodeTypes) {
|
|
384
|
-
NodeTypes["Paths"] = "paths";
|
|
385
|
-
NodeTypes["Path"] = "path";
|
|
386
|
-
NodeTypes["Operation"] = "operation";
|
|
387
|
-
NodeTypes["Webhooks"] = "webhooks";
|
|
388
|
-
NodeTypes["Webhook"] = "webhook";
|
|
389
|
-
NodeTypes["Components"] = "components";
|
|
390
|
-
NodeTypes["Models"] = "models";
|
|
391
|
-
NodeTypes["Model"] = "model";
|
|
392
|
-
})(NodeTypes || (NodeTypes = {}));
|
|
393
|
-
|
|
394
|
-
const oas2SourceMap = [
|
|
395
|
-
{
|
|
396
|
-
match: 'paths',
|
|
397
|
-
type: NodeTypes.Paths,
|
|
398
|
-
children: [
|
|
399
|
-
{
|
|
400
|
-
notMatch: '^x-',
|
|
401
|
-
type: NodeTypes.Path,
|
|
402
|
-
children: [
|
|
403
|
-
{
|
|
404
|
-
match: 'get|post|put|delete|options|head|patch|trace',
|
|
405
|
-
type: NodeTypes.Operation,
|
|
406
|
-
},
|
|
407
|
-
],
|
|
408
|
-
},
|
|
409
|
-
],
|
|
410
|
-
},
|
|
411
|
-
{
|
|
412
|
-
match: 'definitions',
|
|
413
|
-
type: NodeTypes.Models,
|
|
414
|
-
children: [
|
|
415
|
-
{
|
|
416
|
-
notMatch: '^x-',
|
|
417
|
-
type: NodeTypes.Model,
|
|
418
|
-
},
|
|
419
|
-
],
|
|
420
|
-
},
|
|
421
|
-
];
|
|
422
|
-
|
|
423
|
-
const oas3SourceMap = [
|
|
424
|
-
{
|
|
425
|
-
match: 'paths',
|
|
426
|
-
type: NodeTypes.Paths,
|
|
427
|
-
children: [
|
|
428
|
-
{
|
|
429
|
-
notMatch: '^x-',
|
|
430
|
-
type: NodeTypes.Path,
|
|
431
|
-
children: [
|
|
432
|
-
{
|
|
433
|
-
match: 'get|post|put|delete|options|head|patch|trace',
|
|
434
|
-
type: NodeTypes.Operation,
|
|
435
|
-
},
|
|
436
|
-
],
|
|
437
|
-
},
|
|
438
|
-
],
|
|
439
|
-
},
|
|
440
|
-
{
|
|
441
|
-
match: 'webhooks',
|
|
442
|
-
type: NodeTypes.Webhooks,
|
|
443
|
-
children: [
|
|
444
|
-
{
|
|
445
|
-
notMatch: '^x-',
|
|
446
|
-
type: NodeTypes.Webhook,
|
|
447
|
-
children: [
|
|
448
|
-
{
|
|
449
|
-
match: 'get|post|put|delete|options|head|patch|trace',
|
|
450
|
-
type: NodeTypes.Webhook,
|
|
451
|
-
},
|
|
452
|
-
],
|
|
453
|
-
},
|
|
454
|
-
],
|
|
455
|
-
},
|
|
456
|
-
{
|
|
457
|
-
match: 'components',
|
|
458
|
-
type: NodeTypes.Components,
|
|
459
|
-
children: [
|
|
460
|
-
{
|
|
461
|
-
match: 'schemas',
|
|
462
|
-
type: NodeTypes.Models,
|
|
463
|
-
children: [
|
|
464
|
-
{
|
|
465
|
-
notMatch: '^x-',
|
|
466
|
-
type: NodeTypes.Model,
|
|
467
|
-
},
|
|
468
|
-
],
|
|
469
|
-
},
|
|
470
|
-
],
|
|
471
|
-
},
|
|
472
|
-
];
|
|
473
|
-
|
|
474
|
-
const isOas2 = (parsed) => isObject(parsed) &&
|
|
475
|
-
'swagger' in parsed &&
|
|
476
|
-
Number.parseInt(String(parsed.swagger)) === 2;
|
|
477
|
-
const isOas3 = (parsed) => isObject(parsed) &&
|
|
478
|
-
'openapi' in parsed &&
|
|
479
|
-
Number.parseFloat(String(parsed.openapi)) >= 3;
|
|
480
|
-
const isOas31 = (parsed) => isObject(parsed) &&
|
|
481
|
-
'openapi' in parsed &&
|
|
482
|
-
Number.parseFloat(String(parsed.openapi)) === 3.1;
|
|
483
|
-
const OAS_MODEL_REGEXP = /((definitions|components)\/?(schemas)?)\//;
|
|
484
|
-
function transformOasToServiceNode(apiDescriptionDocument) {
|
|
485
|
-
if (isOas31(apiDescriptionDocument)) {
|
|
486
|
-
return computeServiceNode(Object.assign(Object.assign({}, apiDescriptionDocument), { jsonSchemaDialect: 'http://json-schema.org/draft-07/schema#' }), oas3SourceMap, oas3.transformOas3Service, oas3.transformOas3Operation);
|
|
487
|
-
}
|
|
488
|
-
if (isOas3(apiDescriptionDocument)) {
|
|
489
|
-
return computeServiceNode(apiDescriptionDocument, oas3SourceMap, oas3.transformOas3Service, oas3.transformOas3Operation);
|
|
490
|
-
}
|
|
491
|
-
else if (isOas2(apiDescriptionDocument)) {
|
|
492
|
-
return computeServiceNode(apiDescriptionDocument, oas2SourceMap, oas2.transformOas2Service, oas2.transformOas2Operation);
|
|
493
|
-
}
|
|
494
|
-
return null;
|
|
495
|
-
}
|
|
496
|
-
function computeServiceNode(document, map, transformService, transformOperation) {
|
|
497
|
-
var _a;
|
|
498
|
-
const serviceDocument = transformService({ document });
|
|
499
|
-
const serviceNode = {
|
|
500
|
-
type: types.NodeType.HttpService,
|
|
501
|
-
uri: '/',
|
|
502
|
-
name: serviceDocument.name,
|
|
503
|
-
data: serviceDocument,
|
|
504
|
-
tags: ((_a = serviceDocument.tags) === null || _a === void 0 ? void 0 : _a.map(tag => tag.name)) || [],
|
|
505
|
-
children: computeChildNodes(document, document, map, transformOperation),
|
|
506
|
-
};
|
|
507
|
-
return serviceNode;
|
|
508
|
-
}
|
|
509
|
-
function computeChildNodes(document, data, map, transformer, parentUri = '') {
|
|
510
|
-
var _a, _b;
|
|
511
|
-
const nodes = [];
|
|
512
|
-
if (!isObject(data))
|
|
513
|
-
return nodes;
|
|
514
|
-
for (const [key, value] of Object.entries(data)) {
|
|
515
|
-
const sanitizedKey = json.encodePointerFragment(key);
|
|
516
|
-
const match = findMapMatch(sanitizedKey, map);
|
|
517
|
-
if (match) {
|
|
518
|
-
const uri = `${parentUri}/${sanitizedKey}`;
|
|
519
|
-
const jsonPath = json.pointerToPath(`#${uri}`);
|
|
520
|
-
if (match.type === NodeTypes.Operation && jsonPath.length === 3) {
|
|
521
|
-
const path = String(jsonPath[1]);
|
|
522
|
-
const method = String(jsonPath[2]);
|
|
523
|
-
const operationDocument = transformer({
|
|
524
|
-
document,
|
|
525
|
-
name: path,
|
|
526
|
-
method,
|
|
527
|
-
config: oas.OPERATION_CONFIG,
|
|
528
|
-
});
|
|
529
|
-
let parsedUri;
|
|
530
|
-
const encodedPath = String(json.encodePointerFragment(path));
|
|
531
|
-
if (operationDocument.iid) {
|
|
532
|
-
parsedUri = `/operations/${operationDocument.iid}`;
|
|
533
|
-
}
|
|
534
|
-
else {
|
|
535
|
-
parsedUri = uri.replace(encodedPath, elementsCore.slugify(path));
|
|
536
|
-
}
|
|
537
|
-
nodes.push({
|
|
538
|
-
type: types.NodeType.HttpOperation,
|
|
539
|
-
uri: parsedUri,
|
|
540
|
-
data: operationDocument,
|
|
541
|
-
name: operationDocument.summary || operationDocument.iid || operationDocument.path,
|
|
542
|
-
tags: ((_a = operationDocument.tags) === null || _a === void 0 ? void 0 : _a.map(tag => tag.name)) || [],
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
else if (match.type === NodeTypes.Webhook && jsonPath.length === 3) {
|
|
546
|
-
const name = String(jsonPath[1]);
|
|
547
|
-
const method = String(jsonPath[2]);
|
|
548
|
-
const webhookDocument = transformer({
|
|
549
|
-
document,
|
|
550
|
-
name,
|
|
551
|
-
method,
|
|
552
|
-
config: oas.WEBHOOK_CONFIG,
|
|
553
|
-
});
|
|
554
|
-
let parsedUri;
|
|
555
|
-
const encodedPath = String(json.encodePointerFragment(name));
|
|
556
|
-
if (webhookDocument.iid) {
|
|
557
|
-
parsedUri = `/webhooks/${webhookDocument.iid}`;
|
|
558
|
-
}
|
|
559
|
-
else {
|
|
560
|
-
parsedUri = uri.replace(encodedPath, elementsCore.slugify(name));
|
|
561
|
-
}
|
|
562
|
-
nodes.push({
|
|
563
|
-
type: types.NodeType.HttpWebhook,
|
|
564
|
-
uri: parsedUri,
|
|
565
|
-
data: webhookDocument,
|
|
566
|
-
name: webhookDocument.summary || webhookDocument.name,
|
|
567
|
-
tags: ((_b = webhookDocument.tags) === null || _b === void 0 ? void 0 : _b.map(tag => tag.name)) || [],
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
else if (match.type === NodeTypes.Model) {
|
|
571
|
-
const schemaDocument = get(document, jsonPath);
|
|
572
|
-
const parsedUri = uri.replace(OAS_MODEL_REGEXP, 'schemas/');
|
|
573
|
-
nodes.push({
|
|
574
|
-
type: types.NodeType.Model,
|
|
575
|
-
uri: parsedUri,
|
|
576
|
-
data: schemaDocument,
|
|
577
|
-
name: schemaDocument.title || last(uri.split('/')) || '',
|
|
578
|
-
tags: schemaDocument['x-tags'] || [],
|
|
579
|
-
});
|
|
580
|
-
}
|
|
581
|
-
if (match.children) {
|
|
582
|
-
nodes.push(...computeChildNodes(document, value, match.children, transformer, uri));
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
return nodes;
|
|
587
|
-
}
|
|
588
|
-
function findMapMatch(key, map) {
|
|
589
|
-
var _a;
|
|
590
|
-
if (typeof key === 'number')
|
|
591
|
-
return;
|
|
592
|
-
for (const entry of map) {
|
|
593
|
-
const escapedKey = key.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
594
|
-
if (!!((_a = entry.match) === null || _a === void 0 ? void 0 : _a.match(escapedKey)) || (entry.notMatch !== void 0 && !entry.notMatch.match(escapedKey))) {
|
|
595
|
-
return entry;
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
function isJson(value) {
|
|
600
|
-
try {
|
|
601
|
-
JSON.parse(value);
|
|
602
|
-
}
|
|
603
|
-
catch (e) {
|
|
604
|
-
return false;
|
|
605
|
-
}
|
|
606
|
-
return true;
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
function useExportDocumentProps({ originalDocument, bundledDocument, }) {
|
|
610
|
-
const isJsonDocument = typeof originalDocument === 'object' || (!!originalDocument && isJson(originalDocument));
|
|
611
|
-
const exportDocument = React__namespace.useCallback((document) => {
|
|
612
|
-
const type = isJsonDocument ? 'json' : 'yaml';
|
|
613
|
-
const blob = new Blob([document], {
|
|
614
|
-
type: `application/${type}`,
|
|
615
|
-
});
|
|
616
|
-
saver.saveAs(blob, `document.${type}`);
|
|
617
|
-
}, [isJsonDocument]);
|
|
618
|
-
const exportOriginalDocument = React__namespace.useCallback(() => {
|
|
619
|
-
const stringifiedDocument = typeof originalDocument === 'object' ? JSON.stringify(originalDocument, null, 2) : originalDocument || '';
|
|
620
|
-
exportDocument(stringifiedDocument);
|
|
621
|
-
}, [originalDocument, exportDocument]);
|
|
622
|
-
const exportBundledDocument = React__namespace.useCallback(() => {
|
|
623
|
-
const stringifiedDocument = isJsonDocument
|
|
624
|
-
? JSON.stringify(bundledDocument, null, 2)
|
|
625
|
-
: yaml.safeStringify(bundledDocument);
|
|
626
|
-
exportDocument(stringifiedDocument);
|
|
627
|
-
}, [bundledDocument, isJsonDocument, exportDocument]);
|
|
628
|
-
return {
|
|
629
|
-
original: {
|
|
630
|
-
onPress: exportOriginalDocument,
|
|
631
|
-
},
|
|
632
|
-
bundled: {
|
|
633
|
-
onPress: exportBundledDocument,
|
|
634
|
-
},
|
|
635
|
-
};
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
const propsAreWithDocument = (props) => {
|
|
639
|
-
return props.hasOwnProperty('apiDescriptionDocument');
|
|
640
|
-
};
|
|
641
|
-
const APIImpl = props => {
|
|
642
|
-
const { layout = 'sidebar', apiDescriptionUrl = '', logo, hideTryItPanel, hideTryIt, hideSamples, hideSecurityInfo, hideServerInfo, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, maxRefDepth, renderExtensionAddon, basePath, outerRouter = false, } = props;
|
|
643
|
-
const location = reactRouterDom.useLocation();
|
|
644
|
-
const apiDescriptionDocument = propsAreWithDocument(props) ? props.apiDescriptionDocument : undefined;
|
|
645
|
-
const { isResponsiveLayoutEnabled } = elementsCore.useResponsiveLayout();
|
|
646
|
-
const { data: fetchedDocument, error } = reactQuery.useQuery([apiDescriptionUrl], () => fetch(apiDescriptionUrl).then(res => {
|
|
647
|
-
if (res.ok) {
|
|
648
|
-
return res.text();
|
|
649
|
-
}
|
|
650
|
-
throw new Error(`Unable to load description document, status code: ${res.status}`);
|
|
651
|
-
}), {
|
|
652
|
-
enabled: apiDescriptionUrl !== '' && !apiDescriptionDocument,
|
|
653
|
-
});
|
|
654
|
-
const document = apiDescriptionDocument || fetchedDocument || '';
|
|
655
|
-
const parsedDocument = elementsCore.useParsedValue(document);
|
|
656
|
-
const bundledDocument = elementsCore.useBundleRefsIntoDocument(parsedDocument, { baseUrl: apiDescriptionUrl });
|
|
657
|
-
const serviceNode = React__namespace.useMemo(() => transformOasToServiceNode(bundledDocument), [bundledDocument]);
|
|
658
|
-
const exportProps = useExportDocumentProps({ originalDocument: document, bundledDocument });
|
|
659
|
-
if (error) {
|
|
660
|
-
return (React__namespace.createElement(mosaic.Flex, { justify: "center", alignItems: "center", w: "full", minH: "screen" },
|
|
661
|
-
React__namespace.createElement(elementsCore.NonIdealState, { title: "Document could not be loaded", description: "The API description document could not be fetched. This could indicate connectivity problems, or issues with the server hosting the spec.", icon: "exclamation-triangle" })));
|
|
662
|
-
}
|
|
663
|
-
if (!bundledDocument) {
|
|
664
|
-
return (React__namespace.createElement(mosaic.Flex, { justify: "center", alignItems: "center", w: "full", minH: "screen", color: "light" },
|
|
665
|
-
React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, icon: ['fal', 'circle-notch'], size: "3x", spin: true })));
|
|
666
|
-
}
|
|
667
|
-
if (!serviceNode) {
|
|
668
|
-
return (React__namespace.createElement(mosaic.Flex, { justify: "center", alignItems: "center", w: "full", minH: "screen" },
|
|
669
|
-
React__namespace.createElement(elementsCore.NonIdealState, { title: "Failed to parse OpenAPI file", description: "Please make sure your OpenAPI file is valid and try again" })));
|
|
670
|
-
}
|
|
671
|
-
return (React__namespace.createElement(elementsCore.InlineRefResolverProvider, { document: parsedDocument, maxRefDepth: maxRefDepth },
|
|
672
|
-
layout === 'stacked' && (React__namespace.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideSamples: hideSamples, hideTryItPanel: hideTryItPanel, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, location: location })),
|
|
673
|
-
layout === 'sidebar' && (React__namespace.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryItPanel: hideTryItPanel, hideTryIt: hideTryIt, hideSamples: hideSamples, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, basePath: basePath, outerRouter: outerRouter })),
|
|
674
|
-
layout === 'responsive' && (React__namespace.createElement(APIWithResponsiveSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryItPanel: hideTryItPanel, hideTryIt: hideTryIt, hideSamples: hideSamples, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, compact: isResponsiveLayoutEnabled, basePath: basePath, outerRouter: outerRouter }))));
|
|
675
|
-
};
|
|
676
|
-
const API = flow(elementsCore.withRouter, elementsCore.withStyles, elementsCore.withPersistenceBoundary, elementsCore.withMosaicProvider, elementsCore.withQueryClientProvider)(APIImpl);
|
|
677
|
-
|
|
678
|
-
exports.API = API;
|
|
679
|
-
exports.APIWithStackedLayout = APIWithStackedLayout;
|
|
680
|
-
exports.transformOasToServiceNode = transformOasToServiceNode;
|
|
681
|
-
exports.useExportDocumentProps = useExportDocumentProps;
|