@stoplight/elements-core 7.3.10 → 7.5.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/components/Docs/HttpOperation/Badges.d.ts +0 -6
- package/components/Docs/HttpOperation/Body.d.ts +2 -1
- package/components/Docs/HttpOperation/Parameters.d.ts +0 -5
- package/components/Docs/HttpService/SecuritySchemes.d.ts +2 -2
- package/components/Docs/Sections.d.ts +7 -3
- package/components/MarkdownViewer/CustomComponents/CodeComponent.d.ts +2 -1
- package/components/MarkdownViewer/CustomComponents/Provider.d.ts +2 -2
- package/components/MosaicTableOfContents/types.d.ts +0 -2
- package/components/NonIdealState.d.ts +2 -2
- package/components/TryIt/Mocking/mocking-utils.d.ts +1 -2
- package/components/TryIt/Mocking/useMockingOptions.d.ts +1 -1
- package/components/TryIt/Servers/ServersDropdown.d.ts +8 -0
- package/components/TryIt/build-request.d.ts +1 -1
- package/components/TryIt/chosenServer.d.ts +18 -0
- package/components/TryIt/index.d.ts +1 -0
- package/constants.d.ts +2 -0
- package/context/Persistence.d.ts +4 -1
- package/hoc/withMosaicProvider.spec.d.ts +1 -0
- package/hoc/withQueryClientProvider.spec.d.ts +1 -0
- package/hooks/useRouter.d.ts +7 -5
- package/index.d.ts +4 -1
- package/index.esm.js +500 -349
- package/index.js +553 -379
- package/index.mjs +500 -349
- package/package.json +7 -11
- package/styles.min.css +1 -1
- package/types.d.ts +4 -1
- package/utils/http-spec/IServer.d.ts +1 -1
- package/utils/securitySchemes.d.ts +2 -0
- package/utils/string.d.ts +1 -0
package/index.js
CHANGED
|
@@ -5,7 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var React = require('react');
|
|
7
7
|
var json = require('@stoplight/json');
|
|
8
|
-
var
|
|
8
|
+
var isArray = require('lodash/isArray.js');
|
|
9
|
+
var isObject = require('lodash/isObject.js');
|
|
10
|
+
var isPlainObject = require('lodash/isPlainObject.js');
|
|
9
11
|
var markdown = require('@stoplight/markdown');
|
|
10
12
|
var types = require('@stoplight/types');
|
|
11
13
|
var yaml = require('@stoplight/yaml');
|
|
@@ -13,23 +15,42 @@ var mosaic = require('@stoplight/mosaic');
|
|
|
13
15
|
var reactErrorBoundary = require('@stoplight/react-error-boundary');
|
|
14
16
|
var markdownViewer = require('@stoplight/markdown-viewer');
|
|
15
17
|
var freeSolidSvgIcons = require('@fortawesome/free-solid-svg-icons');
|
|
16
|
-
var
|
|
18
|
+
var throttle = require('lodash/throttle.js');
|
|
17
19
|
var unistUtilSelect = require('unist-util-select');
|
|
18
20
|
var cn = require('classnames');
|
|
21
|
+
var utils = require('jotai/utils');
|
|
19
22
|
var jotai = require('jotai');
|
|
20
23
|
var URI = require('urijs');
|
|
21
24
|
var mosaicCodeViewer = require('@stoplight/mosaic-code-viewer');
|
|
22
25
|
var HTTPSnippet = require('httpsnippet');
|
|
26
|
+
var flatten = require('lodash/flatten.js');
|
|
27
|
+
var capitalize = require('lodash/capitalize.js');
|
|
28
|
+
var filter = require('lodash/filter.js');
|
|
23
29
|
var nanoid = require('nanoid');
|
|
30
|
+
var curry = require('lodash/curry.js');
|
|
31
|
+
var omit = require('lodash/omit.js');
|
|
32
|
+
var keyBy = require('lodash/keyBy.js');
|
|
33
|
+
var map = require('lodash/map.js');
|
|
34
|
+
var mapValues = require('lodash/mapValues.js');
|
|
35
|
+
var isString = require('lodash/isString.js');
|
|
36
|
+
var pickBy = require('lodash/pickBy.js');
|
|
24
37
|
var mosaicCodeEditor = require('@stoplight/mosaic-code-editor');
|
|
25
38
|
var Sampler = require('@stoplight/json-schema-sampler');
|
|
39
|
+
var compact = require('lodash/compact.js');
|
|
40
|
+
var uniq = require('lodash/uniq.js');
|
|
41
|
+
var orderBy = require('lodash/orderBy.js');
|
|
42
|
+
var uniqBy = require('lodash/uniqBy.js');
|
|
26
43
|
var formatXml = require('xml-formatter');
|
|
27
|
-
var
|
|
44
|
+
var entries = require('lodash/entries.js');
|
|
45
|
+
var keys = require('lodash/keys.js');
|
|
28
46
|
var jsonSchemaViewer = require('@stoplight/json-schema-viewer');
|
|
29
|
-
var
|
|
47
|
+
var sortBy = require('lodash/sortBy.js');
|
|
48
|
+
var reactRouterDom = require('react-router-dom');
|
|
30
49
|
var reactRouterHashLink = require('react-router-hash-link');
|
|
50
|
+
var reactQuery = require('react-query');
|
|
31
51
|
var $RefParser = require('@stoplight/json-schema-ref-parser');
|
|
32
52
|
var PropTypes = require('prop-types');
|
|
53
|
+
var isEqual = require('lodash/isEqual.js');
|
|
33
54
|
var ReactDOM = require('react-dom');
|
|
34
55
|
|
|
35
56
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -54,14 +75,35 @@ function _interopNamespace(e) {
|
|
|
54
75
|
|
|
55
76
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
56
77
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
57
|
-
var
|
|
78
|
+
var isArray__default = /*#__PURE__*/_interopDefaultLegacy(isArray);
|
|
79
|
+
var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
|
|
80
|
+
var isPlainObject__default = /*#__PURE__*/_interopDefaultLegacy(isPlainObject);
|
|
81
|
+
var throttle__default = /*#__PURE__*/_interopDefaultLegacy(throttle);
|
|
58
82
|
var cn__default = /*#__PURE__*/_interopDefaultLegacy(cn);
|
|
59
83
|
var URI__default = /*#__PURE__*/_interopDefaultLegacy(URI);
|
|
60
84
|
var HTTPSnippet__default = /*#__PURE__*/_interopDefaultLegacy(HTTPSnippet);
|
|
85
|
+
var flatten__default = /*#__PURE__*/_interopDefaultLegacy(flatten);
|
|
86
|
+
var capitalize__default = /*#__PURE__*/_interopDefaultLegacy(capitalize);
|
|
87
|
+
var filter__default = /*#__PURE__*/_interopDefaultLegacy(filter);
|
|
88
|
+
var curry__default = /*#__PURE__*/_interopDefaultLegacy(curry);
|
|
89
|
+
var omit__default = /*#__PURE__*/_interopDefaultLegacy(omit);
|
|
90
|
+
var keyBy__default = /*#__PURE__*/_interopDefaultLegacy(keyBy);
|
|
91
|
+
var map__default = /*#__PURE__*/_interopDefaultLegacy(map);
|
|
92
|
+
var mapValues__default = /*#__PURE__*/_interopDefaultLegacy(mapValues);
|
|
93
|
+
var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);
|
|
94
|
+
var pickBy__default = /*#__PURE__*/_interopDefaultLegacy(pickBy);
|
|
61
95
|
var Sampler__namespace = /*#__PURE__*/_interopNamespace(Sampler);
|
|
96
|
+
var compact__default = /*#__PURE__*/_interopDefaultLegacy(compact);
|
|
97
|
+
var uniq__default = /*#__PURE__*/_interopDefaultLegacy(uniq);
|
|
98
|
+
var orderBy__default = /*#__PURE__*/_interopDefaultLegacy(orderBy);
|
|
99
|
+
var uniqBy__default = /*#__PURE__*/_interopDefaultLegacy(uniqBy);
|
|
62
100
|
var formatXml__default = /*#__PURE__*/_interopDefaultLegacy(formatXml);
|
|
101
|
+
var entries__default = /*#__PURE__*/_interopDefaultLegacy(entries);
|
|
102
|
+
var keys__default = /*#__PURE__*/_interopDefaultLegacy(keys);
|
|
103
|
+
var sortBy__default = /*#__PURE__*/_interopDefaultLegacy(sortBy);
|
|
63
104
|
var $RefParser__default = /*#__PURE__*/_interopDefaultLegacy($RefParser);
|
|
64
105
|
var PropTypes__namespace = /*#__PURE__*/_interopNamespace(PropTypes);
|
|
106
|
+
var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
|
65
107
|
var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
|
|
66
108
|
|
|
67
109
|
const defaultResolver = (contextObject) => ({ pointer }, _, currentObject) => {
|
|
@@ -107,7 +149,7 @@ const recursivelyCreateResolvedObject = (currentObject, rootCurrentObject, prope
|
|
|
107
149
|
else {
|
|
108
150
|
resolvedValue = value;
|
|
109
151
|
}
|
|
110
|
-
if (
|
|
152
|
+
if (isPlainObject__default["default"](resolvedValue) || isArray__default["default"](resolvedValue)) {
|
|
111
153
|
return recursivelyCreateResolvedObject(resolvedValue, rootCurrentObject, newPropertyPath, objectToProxiedObjectCache, mergedOptions);
|
|
112
154
|
}
|
|
113
155
|
return resolvedValue;
|
|
@@ -122,7 +164,7 @@ const isResolvedObjectProxy = (someObject) => {
|
|
|
122
164
|
const getOriginalObject = (resolvedObject) => {
|
|
123
165
|
return resolvedObject[originalObjectSymbol] || resolvedObject;
|
|
124
166
|
};
|
|
125
|
-
const isReference = (value) =>
|
|
167
|
+
const isReference = (value) => isObject__default["default"](value) && typeof value['$ref'] === 'string';
|
|
126
168
|
|
|
127
169
|
const InlineRefResolverContext = React__namespace.createContext(undefined);
|
|
128
170
|
InlineRefResolverContext.displayName = 'InlineRefResolverContext';
|
|
@@ -143,13 +185,13 @@ const useResolvedObject = (currentObject) => {
|
|
|
143
185
|
};
|
|
144
186
|
|
|
145
187
|
function isSMDASTRoot(maybeAst) {
|
|
146
|
-
return
|
|
188
|
+
return isObject__default["default"](maybeAst) && maybeAst['type'] === 'root' && mosaic.isArray(maybeAst['children']);
|
|
147
189
|
}
|
|
148
190
|
function isJSONSchema(maybeSchema) {
|
|
149
|
-
return
|
|
191
|
+
return isPlainObject__default["default"](maybeSchema);
|
|
150
192
|
}
|
|
151
193
|
function isStoplightNode(maybeNode) {
|
|
152
|
-
return
|
|
194
|
+
return isObject__default["default"](maybeNode) && 'id' in maybeNode;
|
|
153
195
|
}
|
|
154
196
|
function isHttpService(maybeHttpService) {
|
|
155
197
|
return isStoplightNode(maybeHttpService) && 'name' in maybeHttpService && 'version' in maybeHttpService;
|
|
@@ -247,7 +289,7 @@ function useComponentSize(container) {
|
|
|
247
289
|
if (!container) {
|
|
248
290
|
return;
|
|
249
291
|
}
|
|
250
|
-
const updateComponentSize =
|
|
292
|
+
const updateComponentSize = throttle__default["default"](() => (container ? setComponentSize(container.getBoundingClientRect()) : { width: 0, height: 0 }), 1000, {
|
|
251
293
|
trailing: true,
|
|
252
294
|
});
|
|
253
295
|
updateComponentSize();
|
|
@@ -280,7 +322,7 @@ const findTitle = (parent) => {
|
|
|
280
322
|
};
|
|
281
323
|
|
|
282
324
|
function useLocationHash() {
|
|
283
|
-
const isBrowser = typeof window !== undefined;
|
|
325
|
+
const isBrowser = typeof window !== 'undefined';
|
|
284
326
|
const [locationHash, setLocationHash] = React__namespace.useState(isBrowser && window.location.hash);
|
|
285
327
|
React__namespace.useEffect(() => {
|
|
286
328
|
if (!isBrowser)
|
|
@@ -296,15 +338,15 @@ const ArticleHeadings = ({ tree, container }) => {
|
|
|
296
338
|
const { width } = useComponentSize(container);
|
|
297
339
|
const showHeadings = width >= 768;
|
|
298
340
|
const headings = useComputeMarkdownHeadings(tree);
|
|
299
|
-
return React__namespace.createElement(Headings, { className: "ArticleHeadings", headings: headings, minimal: !showHeadings });
|
|
341
|
+
return React__namespace.createElement(Headings, { className: "ArticleHeadings", headings: headings, minimal: !showHeadings, maxWidth: 300 });
|
|
300
342
|
};
|
|
301
|
-
const Headings = ({ headings, className, title = 'On This Page', minimal }) => {
|
|
343
|
+
const Headings = ({ headings, className, title = 'On This Page', minimal, maxWidth }) => {
|
|
302
344
|
const locationHash = useLocationHash();
|
|
303
345
|
if (!headings || !headings.length)
|
|
304
346
|
return null;
|
|
305
|
-
const component = (React__namespace.createElement("
|
|
347
|
+
const component = (React__namespace.createElement(mosaic.Box, { overflowY: "auto", style: { maxHeight: '85vh', maxWidth } },
|
|
306
348
|
title && (React__namespace.createElement(mosaic.Flex, { py: 2, alignItems: "center", fontSize: "sm", fontWeight: "medium", color: "muted", style: { paddingLeft: 18 } },
|
|
307
|
-
React__namespace.createElement(
|
|
349
|
+
React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, icon: freeSolidSvgIcons.faStream, mr: 2 }),
|
|
308
350
|
title)),
|
|
309
351
|
headings.map((heading, i) => (React__namespace.createElement(Heading, { key: i, item: heading, isSelected: locationHash === `#${heading.id}` })))));
|
|
310
352
|
if (minimal) {
|
|
@@ -324,59 +366,13 @@ const ArticleComponent = React__namespace.memo(({ data }) => {
|
|
|
324
366
|
const tree = React__namespace.useMemo(() => (typeof data === 'object' ? data : markdown.parse(data)), [data]);
|
|
325
367
|
if (tree === null)
|
|
326
368
|
return null;
|
|
327
|
-
return (React__namespace.createElement(mosaic.Flex, { className: "sl-elements-article", w: "full", pos: "relative", ref: setContainer },
|
|
369
|
+
return (React__namespace.createElement(mosaic.Flex, { className: "sl-elements-article", justifyContent: "evenly", w: "full", pos: "relative", ref: setContainer },
|
|
328
370
|
React__namespace.createElement(mosaic.Box, { className: "sl-elements-article-content", style: { width: 0 }, flex: 1 },
|
|
329
371
|
React__namespace.createElement(MarkdownViewer, { markdown: tree })),
|
|
330
372
|
React__namespace.createElement(ArticleHeadings, { tree: tree, container: container })));
|
|
331
373
|
});
|
|
332
374
|
const Article = reactErrorBoundary.withErrorBoundary(ArticleComponent, { recoverableProps: ['data'] });
|
|
333
375
|
|
|
334
|
-
const MockingContext = createNamedContext('MockingContext', { mockUrl: undefined, hideMocking: undefined });
|
|
335
|
-
const MockingProvider = ({ mockUrl, hideMocking, children }) => {
|
|
336
|
-
const info = {
|
|
337
|
-
mockUrl,
|
|
338
|
-
hideMocking: hideMocking || !mockUrl,
|
|
339
|
-
};
|
|
340
|
-
return React__namespace.createElement(MockingContext.Provider, { value: info }, children);
|
|
341
|
-
};
|
|
342
|
-
function createNamedContext(name, defaultValue) {
|
|
343
|
-
const context = React__namespace.createContext(defaultValue);
|
|
344
|
-
context.displayName = name;
|
|
345
|
-
return context;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
function getReadableSecurityName(securityScheme, includeKey = false) {
|
|
349
|
-
let name = '';
|
|
350
|
-
switch (securityScheme.type) {
|
|
351
|
-
case 'apiKey':
|
|
352
|
-
name = 'API Key';
|
|
353
|
-
break;
|
|
354
|
-
case 'http':
|
|
355
|
-
name = `${_.capitalize(securityScheme.scheme)} Auth`;
|
|
356
|
-
break;
|
|
357
|
-
case 'oauth2':
|
|
358
|
-
name = 'OAuth 2.0';
|
|
359
|
-
break;
|
|
360
|
-
case 'openIdConnect':
|
|
361
|
-
name = 'OpenID Connect';
|
|
362
|
-
break;
|
|
363
|
-
case 'mutualTLS':
|
|
364
|
-
name = 'Mutual TLS';
|
|
365
|
-
break;
|
|
366
|
-
}
|
|
367
|
-
return includeKey ? `${name} (${securityScheme.key})` : name;
|
|
368
|
-
}
|
|
369
|
-
function getServiceUriFromOperation(uri) {
|
|
370
|
-
const match = uri === null || uri === void 0 ? void 0 : uri.match(/(.*)\/(paths|operations)/);
|
|
371
|
-
return match && match.length > 1 ? match[1] || '/' : undefined;
|
|
372
|
-
}
|
|
373
|
-
const isOAuth2ImplicitFlow = (maybeFlow) => _.isObject(maybeFlow) && 'authorizationUrl' in maybeFlow && !('tokenUrl' in maybeFlow);
|
|
374
|
-
const isOauth2AuthorizationCodeFlow = (maybeFlow) => _.isObject(maybeFlow) && 'authorizationUrl' in maybeFlow && 'tokenUrl' in maybeFlow;
|
|
375
|
-
const isOauth2ClientCredentialsOrPasswordFlow = (maybeFlow) => _.isObject(maybeFlow) && !('authorizationUrl' in maybeFlow) && 'tokenUrl' in maybeFlow;
|
|
376
|
-
function shouldIncludeKey(schemes, type) {
|
|
377
|
-
return _.filter(schemes, { type }).length > 1;
|
|
378
|
-
}
|
|
379
|
-
|
|
380
376
|
const NodeTypeColors = {
|
|
381
377
|
http_operation: '#6a6acb',
|
|
382
378
|
http_service: '#e056fd',
|
|
@@ -493,10 +489,36 @@ const HttpCodeDescriptions = {
|
|
|
493
489
|
const badgeDefaultBackgroundColor = '#293742';
|
|
494
490
|
const badgeDefaultColor = '#FFFFFF';
|
|
495
491
|
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
|
|
492
|
+
const MockingContext = createNamedContext('MockingContext', { mockUrl: undefined, hideMocking: undefined });
|
|
493
|
+
const MockingProvider = ({ mockUrl, hideMocking, children }) => {
|
|
494
|
+
const info = {
|
|
495
|
+
mockUrl,
|
|
496
|
+
hideMocking: hideMocking || !mockUrl,
|
|
497
|
+
};
|
|
498
|
+
return React__namespace.createElement(MockingContext.Provider, { value: info }, children);
|
|
499
|
+
};
|
|
500
|
+
function createNamedContext(name, defaultValue) {
|
|
501
|
+
const context = React__namespace.createContext(defaultValue);
|
|
502
|
+
context.displayName = name;
|
|
503
|
+
return context;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
const chosenServerAtom = jotai.atom(undefined);
|
|
507
|
+
|
|
508
|
+
const getServersToDisplay = (originalServers, mockUrl) => {
|
|
509
|
+
const servers = originalServers
|
|
510
|
+
.map((server, i) => {
|
|
511
|
+
const fallbackDescription = originalServers.length === 1 ? 'Live Server' : `Server ${i + 1}`;
|
|
512
|
+
return Object.assign(Object.assign({}, server), { url: getServerUrlWithDefaultValues(server), description: server.description || fallbackDescription });
|
|
513
|
+
})
|
|
499
514
|
.filter(server => isProperUrl(server.url));
|
|
515
|
+
if (mockUrl) {
|
|
516
|
+
servers.push({
|
|
517
|
+
description: 'Mock Server',
|
|
518
|
+
url: mockUrl,
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
return servers;
|
|
500
522
|
};
|
|
501
523
|
const getServerUrlWithDefaultValues = (server) => {
|
|
502
524
|
var _a;
|
|
@@ -762,9 +784,42 @@ const RequestSamples = React__default["default"].memo(({ request, embeddedInMd =
|
|
|
762
784
|
" ",
|
|
763
785
|
selectedLibrary ? ` / ${selectedLibrary}` : '')) }))),
|
|
764
786
|
React__default["default"].createElement(mosaic.Panel.Content, { p: 0 },
|
|
765
|
-
React__default["default"].createElement(mosaicCodeViewer.CodeViewer, { "aria-label": requestSample !== null && requestSample !== void 0 ? requestSample : fallbackText, noCopyButton: true, maxHeight: "400px", language: mosaicCodeViewerLanguage, value: requestSample || fallbackText
|
|
787
|
+
React__default["default"].createElement(mosaicCodeViewer.CodeViewer, { "aria-label": requestSample !== null && requestSample !== void 0 ? requestSample : fallbackText, noCopyButton: true, maxHeight: "400px", language: mosaicCodeViewerLanguage, value: requestSample || fallbackText, style: embeddedInMd
|
|
788
|
+
? undefined
|
|
789
|
+
:
|
|
790
|
+
{
|
|
791
|
+
'--fs-code': 12,
|
|
792
|
+
} }))));
|
|
766
793
|
});
|
|
767
794
|
|
|
795
|
+
function getReadableSecurityName(securityScheme, includeKey = false) {
|
|
796
|
+
let name = '';
|
|
797
|
+
switch (securityScheme.type) {
|
|
798
|
+
case 'apiKey':
|
|
799
|
+
name = 'API Key';
|
|
800
|
+
break;
|
|
801
|
+
case 'http':
|
|
802
|
+
name = `${capitalize__default["default"](securityScheme.scheme)} Auth`;
|
|
803
|
+
break;
|
|
804
|
+
case 'oauth2':
|
|
805
|
+
name = 'OAuth 2.0';
|
|
806
|
+
break;
|
|
807
|
+
case 'openIdConnect':
|
|
808
|
+
name = 'OpenID Connect';
|
|
809
|
+
break;
|
|
810
|
+
case 'mutualTLS':
|
|
811
|
+
name = 'Mutual TLS';
|
|
812
|
+
break;
|
|
813
|
+
}
|
|
814
|
+
return includeKey ? `${name} (${securityScheme.key})` : name;
|
|
815
|
+
}
|
|
816
|
+
const isOAuth2ImplicitFlow = (maybeFlow) => isObject__default["default"](maybeFlow) && 'authorizationUrl' in maybeFlow && !('tokenUrl' in maybeFlow);
|
|
817
|
+
const isOauth2AuthorizationCodeFlow = (maybeFlow) => isObject__default["default"](maybeFlow) && 'authorizationUrl' in maybeFlow && 'tokenUrl' in maybeFlow;
|
|
818
|
+
const isOauth2ClientCredentialsOrPasswordFlow = (maybeFlow) => isObject__default["default"](maybeFlow) && !('authorizationUrl' in maybeFlow) && 'tokenUrl' in maybeFlow;
|
|
819
|
+
function shouldIncludeKey(schemes, type) {
|
|
820
|
+
return filter__default["default"](schemes, { type }).length > 1;
|
|
821
|
+
}
|
|
822
|
+
|
|
768
823
|
const useUniqueId = (prefix = 'id_') => React__namespace.useRef(`${prefix}${nanoid.nanoid(8)}`).current;
|
|
769
824
|
|
|
770
825
|
const AuthTokenInput = ({ type, name, value, onChange }) => {
|
|
@@ -837,7 +892,7 @@ const OAuth2Auth = ({ value, onChange }) => {
|
|
|
837
892
|
|
|
838
893
|
const TryItAuth = ({ operationSecurityScheme: operationAuth, onChange, value }) => {
|
|
839
894
|
var _a;
|
|
840
|
-
const operationSecurityArray =
|
|
895
|
+
const operationSecurityArray = flatten__default["default"](operationAuth);
|
|
841
896
|
const filteredSecurityItems = operationSecurityArray.filter(scheme => securitySchemeKeys.includes(scheme === null || scheme === void 0 ? void 0 : scheme.type));
|
|
842
897
|
const securityScheme = value ? value.scheme : filteredSecurityItems[0];
|
|
843
898
|
const menuName = securityScheme ? getReadableSecurityName(securityScheme) : 'Security Scheme';
|
|
@@ -899,15 +954,22 @@ const SecuritySchemeComponent = (_a) => {
|
|
|
899
954
|
};
|
|
900
955
|
const securitySchemeKeys = ['apiKey', 'http', 'oauth2', 'openIdConnect'];
|
|
901
956
|
|
|
902
|
-
const caseInsensitivelyEquals =
|
|
957
|
+
const caseInsensitivelyEquals = curry__default["default"]((a, b) => a.toUpperCase() === b.toUpperCase());
|
|
958
|
+
function slugify(name) {
|
|
959
|
+
return name
|
|
960
|
+
.replace(/\/|{|}|\s/g, '-')
|
|
961
|
+
.replace(/-{2,}/, '-')
|
|
962
|
+
.replace(/^-/, '')
|
|
963
|
+
.replace(/-$/, '');
|
|
964
|
+
}
|
|
903
965
|
|
|
904
|
-
const isApiKeySecurityScheme = (maybeIApiKey) =>
|
|
905
|
-
const isOAuth2SecurityScheme = (maybeIOAuth2) =>
|
|
906
|
-
const isBasicSecurityScheme = (maybeIBasic) =>
|
|
907
|
-
const isBearerSecurityScheme = (maybeIBearer) =>
|
|
908
|
-
const isDigestSecurityScheme = (maybeIBearer) =>
|
|
966
|
+
const isApiKeySecurityScheme = (maybeIApiKey) => isObject__default["default"](maybeIApiKey) && maybeIApiKey.type === 'apiKey';
|
|
967
|
+
const isOAuth2SecurityScheme = (maybeIOAuth2) => isObject__default["default"](maybeIOAuth2) && maybeIOAuth2.type === 'oauth2';
|
|
968
|
+
const isBasicSecurityScheme = (maybeIBasic) => isObject__default["default"](maybeIBasic) && maybeIBasic.type === 'http' && maybeIBasic.scheme === 'basic';
|
|
969
|
+
const isBearerSecurityScheme = (maybeIBearer) => isObject__default["default"](maybeIBearer) && maybeIBearer.type === 'http' && maybeIBearer.scheme === 'bearer';
|
|
970
|
+
const isDigestSecurityScheme = (maybeIBearer) => isObject__default["default"](maybeIBearer) && maybeIBearer.type === 'http' && maybeIBearer.scheme === 'digest';
|
|
909
971
|
function filterOutAuthorizationParams(queryParams, securitySchemes = []) {
|
|
910
|
-
const flattenedSecuritySchemes =
|
|
972
|
+
const flattenedSecuritySchemes = flatten__default["default"](securitySchemes);
|
|
911
973
|
const securitySchemeNames = getSecuritySchemeNames(flattenedSecuritySchemes);
|
|
912
974
|
return queryParams.filter(queryParam => !securitySchemeNames.some(caseInsensitivelyEquals(queryParam.name)));
|
|
913
975
|
}
|
|
@@ -978,7 +1040,7 @@ const booleanOptions = [
|
|
|
978
1040
|
{ label: 'True', value: 'true' },
|
|
979
1041
|
];
|
|
980
1042
|
function enumOptions(enumValues, required) {
|
|
981
|
-
const options =
|
|
1043
|
+
const options = map__default["default"](enumValues, v => ({ value: Number.isNaN(Number(v)) ? String(v) : Number(v) }));
|
|
982
1044
|
return required ? options : [{ label: 'Not Set', value: '' }, ...options];
|
|
983
1045
|
}
|
|
984
1046
|
function parameterOptions(parameter) {
|
|
@@ -1010,40 +1072,41 @@ function exampleValue(example) {
|
|
|
1010
1072
|
}
|
|
1011
1073
|
function getPlaceholderForParameter(parameter) {
|
|
1012
1074
|
var _a, _b;
|
|
1013
|
-
const parameterValue = getValueForParameter(parameter);
|
|
1075
|
+
const { value: parameterValue, isDefault } = getValueForParameter(parameter);
|
|
1014
1076
|
if (parameterValue)
|
|
1015
|
-
return
|
|
1016
|
-
return
|
|
1077
|
+
return `${isDefault ? 'defaults to' : 'example'}: ${parameterValue}`;
|
|
1078
|
+
return String((_b = (_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : '');
|
|
1017
1079
|
}
|
|
1018
1080
|
function retrieveDefaultFromSchema(parameter) {
|
|
1019
1081
|
var _a;
|
|
1020
1082
|
const defaultValue = (_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.default;
|
|
1021
|
-
return
|
|
1083
|
+
return isObject__default["default"](defaultValue) ? json.safeStringify(defaultValue) : defaultValue;
|
|
1022
1084
|
}
|
|
1023
1085
|
const getValueForParameter = (parameter) => {
|
|
1024
1086
|
var _a, _b, _c;
|
|
1025
|
-
const examples = (_a = parameter.examples) !== null && _a !== void 0 ? _a : [];
|
|
1026
|
-
if (examples.length > 0)
|
|
1027
|
-
return exampleValue(examples[0]);
|
|
1028
1087
|
const defaultValue = retrieveDefaultFromSchema(parameter);
|
|
1029
|
-
if (defaultValue)
|
|
1030
|
-
return String(defaultValue);
|
|
1088
|
+
if (typeof defaultValue !== 'undefined') {
|
|
1089
|
+
return { value: String(defaultValue), isDefault: true };
|
|
1090
|
+
}
|
|
1091
|
+
const examples = (_a = parameter.examples) !== null && _a !== void 0 ? _a : [];
|
|
1092
|
+
if (examples.length > 0) {
|
|
1093
|
+
return { value: exampleValue(examples[0]) };
|
|
1094
|
+
}
|
|
1031
1095
|
const enums = (_c = (_b = parameter.schema) === null || _b === void 0 ? void 0 : _b.enum) !== null && _c !== void 0 ? _c : [];
|
|
1032
|
-
if (enums.length > 0)
|
|
1033
|
-
return String(enums[0]);
|
|
1034
|
-
|
|
1096
|
+
if (enums.length > 0) {
|
|
1097
|
+
return { value: String(enums[0]) };
|
|
1098
|
+
}
|
|
1099
|
+
return { value: '' };
|
|
1035
1100
|
};
|
|
1036
1101
|
const getInitialValueForParameter = (parameter) => {
|
|
1037
1102
|
const isRequired = !!parameter.required;
|
|
1038
1103
|
if (!isRequired)
|
|
1039
1104
|
return '';
|
|
1040
|
-
return getValueForParameter(parameter);
|
|
1105
|
+
return getValueForParameter(parameter).value;
|
|
1041
1106
|
};
|
|
1042
1107
|
const initialParameterValues = params => {
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
.mapValues(param => getInitialValueForParameter(param))
|
|
1046
|
-
.value();
|
|
1108
|
+
const paramsByName = keyBy__default["default"](params, (param) => param.name);
|
|
1109
|
+
return mapValues__default["default"](paramsByName, param => getInitialValueForParameter(param));
|
|
1047
1110
|
};
|
|
1048
1111
|
function mapSchemaPropertiesToParameters(properties, required) {
|
|
1049
1112
|
return Object.entries(properties).map(([name, schema]) => (Object.assign({ name, schema: typeof schema !== 'boolean' ? schema : undefined, examples: typeof schema !== 'boolean' && schema.examples ? [{ key: 'example', value: schema.examples }] : undefined }, ((required === null || required === void 0 ? void 0 : required.includes(name)) && { required: true }))));
|
|
@@ -1085,7 +1148,7 @@ const FormDataBody = ({ specification, values, onChangeValues }) => {
|
|
|
1085
1148
|
if (supportsFileUpload) {
|
|
1086
1149
|
return (React__namespace.createElement(FileUploadParameterEditor, { key: parameter.name, parameter: parameter, value: value instanceof File ? value : undefined, onChange: newValue => newValue
|
|
1087
1150
|
? onChangeValues(Object.assign(Object.assign({}, values), { [parameter.name]: newValue }))
|
|
1088
|
-
: onChangeValues(
|
|
1151
|
+
: onChangeValues(omit__default["default"](values, parameter.name)) }));
|
|
1089
1152
|
}
|
|
1090
1153
|
return (React__namespace.createElement(ParameterEditor, { key: parameter.name, parameter: parameter, value: typeof value === 'string' ? value : undefined, onChange: (value) => onChangeValues(Object.assign(Object.assign({}, values), { [parameter.name]: typeof value === 'number' ? String(value) : value })) }));
|
|
1091
1154
|
}))));
|
|
@@ -1119,7 +1182,7 @@ function createRequestBody(mediaTypeContent, bodyParameterValues) {
|
|
|
1119
1182
|
});
|
|
1120
1183
|
}
|
|
1121
1184
|
const createUrlEncodedRequestBody = ({ bodyParameterValues = {} }) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
1122
|
-
const filteredValues =
|
|
1185
|
+
const filteredValues = pickBy__default["default"](bodyParameterValues, isString__default["default"]);
|
|
1123
1186
|
return new URLSearchParams(filteredValues);
|
|
1124
1187
|
});
|
|
1125
1188
|
const createMultipartRequestBody = ({ mediaTypeContent, bodyParameterValues = {} }) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1184,7 +1247,9 @@ const RequestBody = ({ examples, requestBody, onChange }) => {
|
|
|
1184
1247
|
return (React__namespace.createElement(mosaic.Panel, { defaultIsOpen: true },
|
|
1185
1248
|
React__namespace.createElement(mosaic.Panel.Titlebar, { rightComponent: examples.length > 1 && React__namespace.createElement(ExampleMenu, { examples: examples, requestBody: requestBody, onChange: onChange }) }, "Body"),
|
|
1186
1249
|
React__namespace.createElement(mosaic.Panel.Content, { className: "TextRequestBody" },
|
|
1187
|
-
React__namespace.createElement(mosaicCodeEditor.CodeEditor, { onChange: onChange, language: "json", value: requestBody, showLineNumbers: true, padding: 0
|
|
1250
|
+
React__namespace.createElement(mosaicCodeEditor.CodeEditor, { onChange: onChange, language: "json", value: requestBody, showLineNumbers: true, padding: 0, style: {
|
|
1251
|
+
fontSize: 12,
|
|
1252
|
+
} }))));
|
|
1188
1253
|
};
|
|
1189
1254
|
function ExampleMenu({ examples, requestBody, onChange }) {
|
|
1190
1255
|
const handleClick = React__namespace.useCallback((example) => {
|
|
@@ -1269,7 +1334,6 @@ const generateExamplesFromJsonSchema = (schema) => {
|
|
|
1269
1334
|
: [{ label: 'default', data: '' }];
|
|
1270
1335
|
}
|
|
1271
1336
|
catch (e) {
|
|
1272
|
-
console.error(e);
|
|
1273
1337
|
return [{ label: '', data: `Example cannot be created for this schema\n${e}` }];
|
|
1274
1338
|
}
|
|
1275
1339
|
};
|
|
@@ -1443,8 +1507,8 @@ const formatMultiValueHeader = (...keyValuePairs) => {
|
|
|
1443
1507
|
.join(', ');
|
|
1444
1508
|
};
|
|
1445
1509
|
|
|
1446
|
-
function getMockData(url, httpOperation, {
|
|
1447
|
-
return
|
|
1510
|
+
function getMockData(url, httpOperation, { code, dynamic, example }) {
|
|
1511
|
+
return url ? { url, header: buildPreferHeader({ code, dynamic, example }, httpOperation) } : undefined;
|
|
1448
1512
|
}
|
|
1449
1513
|
function buildPreferHeader({ code, example, dynamic }, httpOperation) {
|
|
1450
1514
|
if (!code) {
|
|
@@ -1452,7 +1516,7 @@ function buildPreferHeader({ code, example, dynamic }, httpOperation) {
|
|
|
1452
1516
|
}
|
|
1453
1517
|
const isCodeSupported = supportsResponseCode(httpOperation, code);
|
|
1454
1518
|
const isExampleSupported = isCodeSupported && supportsExample(httpOperation, code, example);
|
|
1455
|
-
const args =
|
|
1519
|
+
const args = compact__default["default"]([
|
|
1456
1520
|
code && isCodeSupported ? ['code', code] : undefined,
|
|
1457
1521
|
dynamic ? ['dynamic', String(dynamic)] : undefined,
|
|
1458
1522
|
example && isExampleSupported ? ['example', example] : undefined,
|
|
@@ -1473,32 +1537,23 @@ function supportsExample(httpOperation, code, exampleKey) {
|
|
|
1473
1537
|
const response = (_a = httpOperation.responses) === null || _a === void 0 ? void 0 : _a.find(response => response.code === code);
|
|
1474
1538
|
if (!response)
|
|
1475
1539
|
return false;
|
|
1476
|
-
const exampleKeys =
|
|
1540
|
+
const exampleKeys = uniq__default["default"]((_b = response.contents) === null || _b === void 0 ? void 0 : _b.flatMap(c => c.examples || []).map(example => example.key));
|
|
1477
1541
|
return exampleKeys.includes(exampleKey);
|
|
1478
1542
|
}
|
|
1479
1543
|
|
|
1480
|
-
const MockingButton = ({ operation, options: {
|
|
1481
|
-
const toggleEnabled = React__namespace.useCallback(() => {
|
|
1482
|
-
onOptionsChange({ isEnabled: !isEnabled });
|
|
1483
|
-
}, [isEnabled, onOptionsChange]);
|
|
1544
|
+
const MockingButton = ({ operation, options: { code, example, dynamic }, onOptionsChange, }) => {
|
|
1484
1545
|
const operationResponses = operation.responses;
|
|
1485
1546
|
const setMockingOptions = React__namespace.useCallback(({ code, example, dynamic }) => {
|
|
1486
|
-
onOptionsChange({
|
|
1487
|
-
}, [
|
|
1547
|
+
onOptionsChange({ code, example, dynamic });
|
|
1548
|
+
}, [onOptionsChange]);
|
|
1488
1549
|
const menuItems = React__namespace.useMemo(() => {
|
|
1489
1550
|
var _a;
|
|
1490
|
-
const items =
|
|
1491
|
-
{ id: 'mocking-enabled', title: 'Enabled', isChecked: isEnabled, onPress: toggleEnabled },
|
|
1492
|
-
{
|
|
1493
|
-
type: 'group',
|
|
1494
|
-
children: (_a = operationResponses === null || operationResponses === void 0 ? void 0 : operationResponses.filter(operationResponse => Number.isInteger(parseFloat(operationResponse.code)))) === null || _a === void 0 ? void 0 : _a.map(generateOperationResponseMenu),
|
|
1495
|
-
},
|
|
1496
|
-
];
|
|
1551
|
+
const items = (_a = operationResponses === null || operationResponses === void 0 ? void 0 : operationResponses.filter(operationResponse => Number.isInteger(parseFloat(operationResponse.code)))) === null || _a === void 0 ? void 0 : _a.map(generateOperationResponseMenu);
|
|
1497
1552
|
function generateOperationResponseMenu(operationResponse) {
|
|
1498
1553
|
var _a;
|
|
1499
1554
|
const menuId = `response-${operationResponse.code}`;
|
|
1500
1555
|
const isActive = operationResponse.code === code;
|
|
1501
|
-
const exampleKeys =
|
|
1556
|
+
const exampleKeys = uniq__default["default"]((_a = operationResponse.contents) === null || _a === void 0 ? void 0 : _a.flatMap(c => c.examples || []).map(example => example.key));
|
|
1502
1557
|
const exampleChildren = exampleKeys === null || exampleKeys === void 0 ? void 0 : exampleKeys.map(exampleKey => ({
|
|
1503
1558
|
id: `${menuId}-example-${exampleKey}`,
|
|
1504
1559
|
title: exampleKey,
|
|
@@ -1527,7 +1582,6 @@ const MockingButton = ({ operation, options: { isEnabled, code, example, dynamic
|
|
|
1527
1582
|
];
|
|
1528
1583
|
const menuItem = {
|
|
1529
1584
|
id: menuId,
|
|
1530
|
-
isDisabled: !isEnabled,
|
|
1531
1585
|
isChecked: isActive,
|
|
1532
1586
|
title: operationResponse.code,
|
|
1533
1587
|
onPress: () => {
|
|
@@ -1541,13 +1595,13 @@ const MockingButton = ({ operation, options: { isEnabled, code, example, dynamic
|
|
|
1541
1595
|
return menuItem;
|
|
1542
1596
|
}
|
|
1543
1597
|
return items;
|
|
1544
|
-
}, [code, dynamic, example,
|
|
1598
|
+
}, [code, dynamic, example, operationResponses, setMockingOptions]);
|
|
1545
1599
|
return (React__namespace.createElement(mosaic.Box, null,
|
|
1546
|
-
React__namespace.createElement(mosaic.Menu, { "aria-label": "
|
|
1600
|
+
React__namespace.createElement(mosaic.Menu, { "aria-label": "Mock settings", items: menuItems, renderTrigger: ({ isOpen }) => (React__namespace.createElement(mosaic.FieldButton, { active: isOpen, size: "sm" }, "Mock Settings")) })));
|
|
1547
1601
|
};
|
|
1548
1602
|
|
|
1549
|
-
const
|
|
1550
|
-
const useMockingOptions = () => jotai.useAtom(
|
|
1603
|
+
const mockingOptionsAtom = jotai.atom({});
|
|
1604
|
+
const useMockingOptions = () => jotai.useAtom(mockingOptionsAtom);
|
|
1551
1605
|
|
|
1552
1606
|
const OperationParameters = ({ parameters, values, onChangeValue, validate, }) => {
|
|
1553
1607
|
return (React__namespace.createElement(mosaic.Panel, { defaultIsOpen: true },
|
|
@@ -1586,10 +1640,10 @@ const useRequestParameters = (httpOperation) => {
|
|
|
1586
1640
|
function extractAllParameters(httpOperation) {
|
|
1587
1641
|
var _a, _b, _c, _d, _e, _f;
|
|
1588
1642
|
const getRequired = (obj) => { var _a; return (_a = obj.required) !== null && _a !== void 0 ? _a : false; };
|
|
1589
|
-
const pathParameters =
|
|
1590
|
-
const queryParameters = filterOutAuthorizationParams(
|
|
1591
|
-
const headerParameters = filterOutAuthorizationParams(
|
|
1592
|
-
return
|
|
1643
|
+
const pathParameters = orderBy__default["default"]((_b = (_a = httpOperation.request) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : [], [getRequired, 'name'], ['desc', 'asc']);
|
|
1644
|
+
const queryParameters = filterOutAuthorizationParams(orderBy__default["default"]((_d = (_c = httpOperation.request) === null || _c === void 0 ? void 0 : _c.query) !== null && _d !== void 0 ? _d : [], [getRequired, 'name'], ['desc', 'asc']), httpOperation.security);
|
|
1645
|
+
const headerParameters = filterOutAuthorizationParams(orderBy__default["default"]((_f = (_e = httpOperation.request) === null || _e === void 0 ? void 0 : _e.headers) !== null && _f !== void 0 ? _f : [], [getRequired, 'name'], ['desc', 'asc']), httpOperation.security);
|
|
1646
|
+
return uniqBy__default["default"]([...pathParameters, ...queryParameters, ...headerParameters], p => p.name);
|
|
1593
1647
|
}
|
|
1594
1648
|
|
|
1595
1649
|
function getHttpCodeColor(code) {
|
|
@@ -1645,19 +1699,19 @@ const TryItResponse = ({ response }) => {
|
|
|
1645
1699
|
? parseBody(response.bodyText, responseType)
|
|
1646
1700
|
: response.bodyText })) : response.blob && responseType === 'image' ? (React__namespace.createElement(mosaic.Flex, { justifyContent: "center" },
|
|
1647
1701
|
React__namespace.createElement(mosaic.Image, { src: URL.createObjectURL(response.blob), alt: "response image" }))) : (React__namespace.createElement("p", null,
|
|
1648
|
-
React__namespace.createElement(
|
|
1702
|
+
React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, icon: freeSolidSvgIcons.faExclamationCircle, mr: 2 }),
|
|
1649
1703
|
"No supported response body returned"))))));
|
|
1650
1704
|
};
|
|
1651
1705
|
const ResponseMenu = ({ types, type, onChange }) => {
|
|
1652
1706
|
const menuItems = React__namespace.useMemo(() => {
|
|
1653
1707
|
const items = types.map(type => ({
|
|
1654
1708
|
id: type,
|
|
1655
|
-
title:
|
|
1709
|
+
title: capitalize__default["default"](type),
|
|
1656
1710
|
onPress: () => onChange(type),
|
|
1657
1711
|
}));
|
|
1658
1712
|
return items;
|
|
1659
1713
|
}, [types, onChange]);
|
|
1660
|
-
return (React__namespace.createElement(mosaic.Menu, { "aria-label": "Body Format", items: menuItems, renderTrigger: ({ isOpen }) => (React__namespace.createElement(mosaic.Button, { appearance: "minimal", size: "sm", iconRight: ['fas', 'sort'], active: isOpen },
|
|
1714
|
+
return (React__namespace.createElement(mosaic.Menu, { "aria-label": "Body Format", items: menuItems, renderTrigger: ({ isOpen }) => (React__namespace.createElement(mosaic.Button, { appearance: "minimal", size: "sm", iconRight: ['fas', 'sort'], active: isOpen }, capitalize__default["default"](type))) }));
|
|
1661
1715
|
};
|
|
1662
1716
|
const ResponseError = ({ state: { error } }) => (React__namespace.createElement(mosaic.Panel, { defaultIsOpen: true },
|
|
1663
1717
|
React__namespace.createElement(mosaic.Panel.Titlebar, null, "Error"),
|
|
@@ -1676,7 +1730,32 @@ class NetworkError extends Error {
|
|
|
1676
1730
|
}
|
|
1677
1731
|
const isNetworkError = (error) => error instanceof NetworkError;
|
|
1678
1732
|
|
|
1679
|
-
const
|
|
1733
|
+
const ServersDropdown = ({ servers }) => {
|
|
1734
|
+
const [chosenServer, setChosenServer] = jotai.useAtom(chosenServerAtom);
|
|
1735
|
+
const serverItems = [
|
|
1736
|
+
{
|
|
1737
|
+
type: 'option_group',
|
|
1738
|
+
title: 'Servers',
|
|
1739
|
+
value: (chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.url) || '',
|
|
1740
|
+
onChange: url => {
|
|
1741
|
+
const server = servers.find(server => server.url === url);
|
|
1742
|
+
setChosenServer(server);
|
|
1743
|
+
},
|
|
1744
|
+
children: [
|
|
1745
|
+
...servers.map((server, i) => ({
|
|
1746
|
+
id: server.url,
|
|
1747
|
+
title: server.name || server.description,
|
|
1748
|
+
description: server.name ? server.description || server.url : server.description ? server.url : undefined,
|
|
1749
|
+
value: server.url,
|
|
1750
|
+
})),
|
|
1751
|
+
],
|
|
1752
|
+
},
|
|
1753
|
+
];
|
|
1754
|
+
return (React__namespace.createElement(mosaic.Menu, { "aria-label": "Server", items: serverItems, closeOnPress: true, renderTrigger: ({ isOpen }) => (React__namespace.createElement(mosaic.FieldButton, { icon: freeSolidSvgIcons.faServer, size: "sm", active: isOpen }, (chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.name) || (chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.description) || 'Server')) }));
|
|
1755
|
+
};
|
|
1756
|
+
ServersDropdown.displayName = 'ServersDropdown';
|
|
1757
|
+
|
|
1758
|
+
const defaultServers = [];
|
|
1680
1759
|
const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embeddedInMd = false, tryItCredentialsPolicy, corsProxy, }) => {
|
|
1681
1760
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1682
1761
|
const isDark = mosaic.useThemeIsDark();
|
|
@@ -1690,27 +1769,41 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
|
|
|
1690
1769
|
const [bodyParameterValues, setBodyParameterValues, formDataState] = useBodyParameterState(mediaTypeContent);
|
|
1691
1770
|
const [textRequestBody, setTextRequestBody] = useTextRequestBodyState(mediaTypeContent);
|
|
1692
1771
|
const [operationAuthValue, setOperationAuthValue] = usePersistedSecuritySchemeWithValues();
|
|
1693
|
-
const servers =
|
|
1772
|
+
const servers = React__namespace.useMemo(() => {
|
|
1773
|
+
const toDisplay = getServersToDisplay(httpOperation.servers || defaultServers, mockUrl);
|
|
1774
|
+
return toDisplay;
|
|
1775
|
+
}, [httpOperation.servers, mockUrl]);
|
|
1776
|
+
const firstServer = servers[0] || null;
|
|
1694
1777
|
const [chosenServer, setChosenServer] = jotai.useAtom(chosenServerAtom);
|
|
1778
|
+
const isMockingEnabled = mockUrl && (chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.url) === mockUrl;
|
|
1695
1779
|
const hasRequiredButEmptyParameters = allParameters.some(parameter => parameter.required && !parameterValuesWithDefaults[parameter.name]);
|
|
1696
1780
|
React__namespace.useEffect(() => {
|
|
1697
|
-
|
|
1698
|
-
|
|
1781
|
+
const currentUrl = chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.url;
|
|
1782
|
+
const exists = currentUrl && servers.find(s => s.url === currentUrl);
|
|
1783
|
+
if (!exists) {
|
|
1784
|
+
setChosenServer(firstServer);
|
|
1699
1785
|
}
|
|
1700
|
-
|
|
1786
|
+
else if (exists !== chosenServer) {
|
|
1787
|
+
setChosenServer(exists);
|
|
1788
|
+
}
|
|
1789
|
+
}, [servers, firstServer, chosenServer, setChosenServer]);
|
|
1701
1790
|
React__namespace.useEffect(() => {
|
|
1702
|
-
let
|
|
1791
|
+
let isMounted = true;
|
|
1703
1792
|
if (onRequestChange || embeddedInMd) {
|
|
1704
|
-
buildHarRequest(Object.assign(Object.assign({ mediaTypeContent, parameterValues: parameterValuesWithDefaults, httpOperation, bodyInput: formDataState.isFormDataBody ? bodyParameterValues : textRequestBody, auth: operationAuthValue }, (
|
|
1793
|
+
buildHarRequest(Object.assign(Object.assign({ mediaTypeContent, parameterValues: parameterValuesWithDefaults, httpOperation, bodyInput: formDataState.isFormDataBody ? bodyParameterValues : textRequestBody, auth: operationAuthValue }, (isMockingEnabled && { mockData: getMockData(mockUrl, httpOperation, mockingOptions) })), { chosenServer,
|
|
1705
1794
|
corsProxy })).then(request => {
|
|
1706
|
-
if (
|
|
1707
|
-
onRequestChange
|
|
1708
|
-
|
|
1709
|
-
|
|
1795
|
+
if (isMounted) {
|
|
1796
|
+
if (onRequestChange) {
|
|
1797
|
+
onRequestChange(request);
|
|
1798
|
+
}
|
|
1799
|
+
if (embeddedInMd) {
|
|
1800
|
+
setRequestData(request);
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1710
1803
|
});
|
|
1711
1804
|
}
|
|
1712
1805
|
return () => {
|
|
1713
|
-
|
|
1806
|
+
isMounted = false;
|
|
1714
1807
|
};
|
|
1715
1808
|
}, [
|
|
1716
1809
|
httpOperation,
|
|
@@ -1724,13 +1817,13 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
|
|
|
1724
1817
|
corsProxy,
|
|
1725
1818
|
embeddedInMd,
|
|
1726
1819
|
]);
|
|
1727
|
-
const
|
|
1820
|
+
const handleSendRequest = () => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
1728
1821
|
setValidateParameters(true);
|
|
1729
1822
|
if (hasRequiredButEmptyParameters)
|
|
1730
1823
|
return;
|
|
1731
1824
|
try {
|
|
1732
1825
|
setLoading(true);
|
|
1733
|
-
const mockData = getMockData(mockUrl, httpOperation, mockingOptions);
|
|
1826
|
+
const mockData = isMockingEnabled ? getMockData(mockUrl, httpOperation, mockingOptions) : undefined;
|
|
1734
1827
|
const request = yield buildFetchRequest({
|
|
1735
1828
|
parameterValues: parameterValuesWithDefaults,
|
|
1736
1829
|
httpOperation,
|
|
@@ -1767,29 +1860,32 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
|
|
|
1767
1860
|
setLoading(false);
|
|
1768
1861
|
}
|
|
1769
1862
|
});
|
|
1770
|
-
const
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1863
|
+
const isOnlySendButton = !((_d = httpOperation.security) === null || _d === void 0 ? void 0 : _d.length) && !allParameters.length && !formDataState.isFormDataBody && !mediaTypeContent;
|
|
1864
|
+
const tryItPanelContents = (React__namespace.createElement(React__namespace.Fragment, null,
|
|
1865
|
+
((_e = httpOperation.security) === null || _e === void 0 ? void 0 : _e.length) ? (React__namespace.createElement(TryItAuth, { onChange: setOperationAuthValue, operationSecurityScheme: (_f = httpOperation.security) !== null && _f !== void 0 ? _f : [], value: operationAuthValue })) : null,
|
|
1866
|
+
allParameters.length > 0 && (React__namespace.createElement(OperationParameters, { parameters: allParameters, values: parameterValuesWithDefaults, onChangeValue: updateParameterValue, validate: validateParameters })),
|
|
1867
|
+
formDataState.isFormDataBody ? (React__namespace.createElement(FormDataBody, { specification: formDataState.bodySpecification, values: bodyParameterValues, onChangeValues: setBodyParameterValues })) : mediaTypeContent ? (React__namespace.createElement(RequestBody, { examples: (_g = mediaTypeContent.examples) !== null && _g !== void 0 ? _g : [], requestBody: textRequestBody, onChange: setTextRequestBody })) : null,
|
|
1868
|
+
React__namespace.createElement(mosaic.Panel.Content, { className: "SendButtonHolder", mt: 4, pt: !isOnlySendButton && !embeddedInMd ? 0 : undefined },
|
|
1869
|
+
React__namespace.createElement(mosaic.HStack, { alignItems: "center", spacing: 2 },
|
|
1870
|
+
React__namespace.createElement(mosaic.Button, { appearance: "primary", loading: loading, disabled: loading, onPress: handleSendRequest, size: "sm" }, "Send API Request"),
|
|
1871
|
+
servers.length > 1 && React__namespace.createElement(ServersDropdown, { servers: servers }),
|
|
1872
|
+
isMockingEnabled && (React__namespace.createElement(MockingButton, { options: mockingOptions, onOptionsChange: setMockingOptions, operation: httpOperation }))),
|
|
1873
|
+
validateParameters && hasRequiredButEmptyParameters && (React__namespace.createElement(mosaic.Box, { mt: 4, color: "danger-light", fontSize: "sm" },
|
|
1874
|
+
React__namespace.createElement(mosaic.Icon, { icon: freeSolidSvgIcons.faExclamationTriangle, className: "sl-mr-1" }),
|
|
1875
|
+
"You didn't provide all of the required parameters!")))));
|
|
1876
|
+
let tryItPanelElem;
|
|
1877
|
+
if (embeddedInMd) {
|
|
1878
|
+
tryItPanelElem = (React__namespace.createElement(mosaic.Panel, { isCollapsible: false, p: 0, className: "TryItPanel" },
|
|
1879
|
+
React__namespace.createElement(mosaic.Panel.Titlebar, { bg: "canvas-300" },
|
|
1880
|
+
React__namespace.createElement(mosaic.Box, { fontWeight: "bold", color: !isDark ? HttpMethodColors[httpOperation.method] : undefined }, httpOperation.method.toUpperCase()),
|
|
1881
|
+
React__namespace.createElement(mosaic.Box, { fontWeight: "medium", ml: 2, textOverflow: "truncate", overflowX: "hidden" }, `${(chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.url) || ''}${httpOperation.path}`)),
|
|
1882
|
+
tryItPanelContents));
|
|
1883
|
+
}
|
|
1884
|
+
else {
|
|
1885
|
+
tryItPanelElem = (React__namespace.createElement(mosaic.Box, { className: "TryItPanel", bg: "canvas-100", rounded: "lg" }, tryItPanelContents));
|
|
1886
|
+
}
|
|
1777
1887
|
return (React__namespace.createElement(mosaic.Box, { rounded: "lg", overflowY: "hidden" },
|
|
1778
|
-
|
|
1779
|
-
React__namespace.createElement(mosaic.Panel.Titlebar, { rightComponent: servers.length > 1 ? serversSelect : serverDescription, bg: "canvas-300" },
|
|
1780
|
-
React__namespace.createElement("div", { role: "heading", className: "sl-font-bold" },
|
|
1781
|
-
React__namespace.createElement(mosaic.Text, { color: !isDark ? HttpMethodColors[httpOperation.method] : undefined }, httpOperation.method.toUpperCase()),
|
|
1782
|
-
React__namespace.createElement(mosaic.Text, { ml: 2 }, httpOperation.path))),
|
|
1783
|
-
React__namespace.createElement(TryItAuth, { onChange: setOperationAuthValue, operationSecurityScheme: (_f = httpOperation.security) !== null && _f !== void 0 ? _f : [], value: operationAuthValue }),
|
|
1784
|
-
allParameters.length > 0 && (React__namespace.createElement(OperationParameters, { parameters: allParameters, values: parameterValuesWithDefaults, onChangeValue: updateParameterValue, validate: validateParameters })),
|
|
1785
|
-
formDataState.isFormDataBody ? (React__namespace.createElement(FormDataBody, { specification: formDataState.bodySpecification, values: bodyParameterValues, onChangeValues: setBodyParameterValues })) : mediaTypeContent ? (React__namespace.createElement(RequestBody, { examples: (_g = mediaTypeContent.examples) !== null && _g !== void 0 ? _g : [], requestBody: textRequestBody, onChange: setTextRequestBody })) : null,
|
|
1786
|
-
React__namespace.createElement(mosaic.Panel.Content, { className: "SendButtonHolder" },
|
|
1787
|
-
React__namespace.createElement(mosaic.Flex, { alignItems: "center" },
|
|
1788
|
-
React__namespace.createElement(mosaic.Button, { appearance: "primary", loading: loading, disabled: loading, onPress: handleClick, size: "sm" }, "Send Request"),
|
|
1789
|
-
mockUrl && (React__namespace.createElement(MockingButton, { options: mockingOptions, onOptionsChange: setMockingOptions, operation: httpOperation }))),
|
|
1790
|
-
validateParameters && hasRequiredButEmptyParameters && (React__namespace.createElement(mosaic.Box, { mt: 4, color: "danger-light", fontSize: "sm" },
|
|
1791
|
-
React__namespace.createElement(mosaic.Icon, { icon: freeSolidSvgIcons.faExclamationTriangle, className: "sl-mr-1" }),
|
|
1792
|
-
"You didn't provide all of the required parameters!")))),
|
|
1888
|
+
tryItPanelElem,
|
|
1793
1889
|
requestData && embeddedInMd && React__namespace.createElement(RequestSamples, { request: requestData, embeddedInMd: true }),
|
|
1794
1890
|
response && !('error' in response) && React__namespace.createElement(TryItResponse, { response: response }),
|
|
1795
1891
|
response && 'error' in response && React__namespace.createElement(ResponseError, { state: response })));
|
|
@@ -1826,7 +1922,9 @@ const ResponseExamples = ({ httpOperation, responseMediaType, responseStatusCode
|
|
|
1826
1922
|
const examplesSelect = userDefinedExamples && userDefinedExamples.length > 1 && (React__default["default"].createElement(mosaic.Select, { "aria-label": "Response Example", value: String(chosenExampleIndex), options: userDefinedExamples.map((example, index) => ({ value: index, label: example.key })), onChange: (value) => setChosenExampleIndex(parseInt(String(value), 10)), size: "sm", triggerTextPrefix: "Response Example: " }));
|
|
1827
1923
|
return (React__default["default"].createElement(mosaic.Panel, { rounded: true, isCollapsible: false },
|
|
1828
1924
|
React__default["default"].createElement(mosaic.Panel.Titlebar, null, examplesSelect || React__default["default"].createElement(mosaic.Text, { color: "body" }, "Response Example")),
|
|
1829
|
-
React__default["default"].createElement(mosaic.Panel.Content, { p: 0 }, show || !exceedsSize(responseExample) ? (React__default["default"].createElement(mosaicCodeViewer.CodeViewer, { "aria-label": responseExample, noCopyButton: true, maxHeight: "
|
|
1925
|
+
React__default["default"].createElement(mosaic.Panel.Content, { p: 0 }, show || !exceedsSize(responseExample) ? (React__default["default"].createElement(mosaicCodeViewer.CodeViewer, { "aria-label": responseExample, noCopyButton: true, maxHeight: "500px", language: "json", value: responseExample, showLineNumbers: true, style: {
|
|
1926
|
+
'--fs-code': 12,
|
|
1927
|
+
} })) : (React__default["default"].createElement(LoadMore, { loading: loading, onClick: handleLoadMore })))));
|
|
1830
1928
|
};
|
|
1831
1929
|
|
|
1832
1930
|
const TryItWithRequestSamples = (_a) => {
|
|
@@ -1840,21 +1938,16 @@ const TryItWithRequestSamples = (_a) => {
|
|
|
1840
1938
|
React__namespace.createElement(ResponseExamples, Object.assign({}, props))));
|
|
1841
1939
|
};
|
|
1842
1940
|
|
|
1843
|
-
const TwoColumnLayout = ({ header, right, left, className }) => (React__default["default"].createElement(mosaic.
|
|
1941
|
+
const TwoColumnLayout = ({ header, right, left, className }) => (React__default["default"].createElement(mosaic.VStack, { w: "full", className: className, spacing: 8 },
|
|
1844
1942
|
header,
|
|
1845
|
-
React__default["default"].createElement(mosaic.Flex,
|
|
1846
|
-
React__default["default"].createElement(mosaic.Box, {
|
|
1943
|
+
React__default["default"].createElement(mosaic.Flex, null,
|
|
1944
|
+
React__default["default"].createElement(mosaic.Box, { w: 0, flex: 1 }, left),
|
|
1847
1945
|
right && (React__default["default"].createElement(mosaic.Box, { ml: 16, pos: "relative", w: "2/5", style: { maxWidth: 500 } }, right)))));
|
|
1848
1946
|
|
|
1849
1947
|
const DeprecatedBadge = () => (React__default["default"].createElement(mosaic.Tooltip, { renderTrigger: React__default["default"].createElement(mosaic.Badge, { intent: "warning", icon: freeSolidSvgIcons.faExclamationCircle, "data-testid": "badge-deprecated" }, "Deprecated") }, "This operation has been marked as deprecated, which means it could be removed at some point in the future."));
|
|
1850
|
-
const InternalBadge = ({ isHttpService }) => (React__default["default"].createElement(mosaic.Tooltip, { renderTrigger: React__default["default"].createElement(mosaic.Badge, { icon: freeSolidSvgIcons.faEye, "data-testid": "badge-internal",
|
|
1851
|
-
const
|
|
1852
|
-
const badge = (React__default["default"].createElement(mosaic.Badge, { icon: freeSolidSvgIcons.faLock, "data-testid": "badge-security", className: "sl-truncate", style: { backgroundColor: badgeDefaultBackgroundColor, color: badgeDefaultColor } }, getReadableSecurityName(scheme, includeKey)));
|
|
1853
|
-
return httpServiceUri ? (React__default["default"].createElement(reactRouterDom.Link, { to: `${httpServiceUri}?security=${scheme.key}`, className: "sl-no-underline sl-block" }, badge)) : (badge);
|
|
1854
|
-
};
|
|
1855
|
-
const VersionBadge = ({ value, backgroundColor }) => (React__default["default"].createElement(mosaic.Badge, { appearance: "solid", size: "sm", style: {
|
|
1948
|
+
const InternalBadge = ({ isHttpService }) => (React__default["default"].createElement(mosaic.Tooltip, { renderTrigger: React__default["default"].createElement(mosaic.Badge, { icon: freeSolidSvgIcons.faEye, "data-testid": "badge-internal", bg: "danger" }, "Internal") }, `This ${isHttpService ? 'operation' : 'model'} is marked as internal and won't be visible in public docs.`));
|
|
1949
|
+
const VersionBadge = ({ value, backgroundColor }) => (React__default["default"].createElement(mosaic.Badge, { appearance: "solid", size: "sm", border: 0, style: {
|
|
1856
1950
|
backgroundColor: backgroundColor || badgeDefaultBackgroundColor,
|
|
1857
|
-
border: 'none',
|
|
1858
1951
|
color: badgeDefaultColor,
|
|
1859
1952
|
} }, enhanceVersionString(value)));
|
|
1860
1953
|
const enhanceVersionString = (version) => {
|
|
@@ -1863,32 +1956,112 @@ const enhanceVersionString = (version) => {
|
|
|
1863
1956
|
return `v${version}`;
|
|
1864
1957
|
};
|
|
1865
1958
|
|
|
1866
|
-
const
|
|
1867
|
-
|
|
1868
|
-
|
|
1959
|
+
const oauthFlowNames = {
|
|
1960
|
+
implicit: 'Implicit',
|
|
1961
|
+
authorizationCode: 'Authorization Code',
|
|
1962
|
+
clientCredentials: 'Client Credentials',
|
|
1963
|
+
password: 'Password',
|
|
1964
|
+
};
|
|
1965
|
+
function getDefaultDescription(scheme) {
|
|
1966
|
+
switch (scheme.type) {
|
|
1967
|
+
case 'apiKey':
|
|
1968
|
+
return getApiKeyDescription(scheme.in, scheme.name);
|
|
1969
|
+
case 'http':
|
|
1970
|
+
switch (scheme.scheme) {
|
|
1971
|
+
case 'basic':
|
|
1972
|
+
return getBasicAuthDescription();
|
|
1973
|
+
case 'bearer':
|
|
1974
|
+
return getBearerAuthDescription();
|
|
1975
|
+
case 'digest':
|
|
1976
|
+
return getDigestAuthDescription();
|
|
1977
|
+
}
|
|
1978
|
+
case 'oauth2':
|
|
1979
|
+
return getOAuthDescription(scheme);
|
|
1980
|
+
}
|
|
1981
|
+
return '';
|
|
1982
|
+
}
|
|
1983
|
+
function getApiKeyDescription(inProperty, name) {
|
|
1984
|
+
return `An API key is a token that you provide when making API calls. Include the token in a ${inProperty} parameter called \`${name}\`.
|
|
1985
|
+
|
|
1986
|
+
Example: ${inProperty === 'query' ? `\`?${name}=123\`` : `\`${name}: 123\``}`;
|
|
1987
|
+
}
|
|
1988
|
+
function getBasicAuthDescription() {
|
|
1989
|
+
return `Basic authentication is a simple authentication scheme built into the HTTP protocol.
|
|
1990
|
+
To use it, send your HTTP requests with an Authorization header that contains the word Basic
|
|
1991
|
+
followed by a space and a base64-encoded string \`username:password\`.
|
|
1992
|
+
|
|
1993
|
+
Example: \`Authorization: Basic ZGVtbzpwQDU1dzByZA==\``;
|
|
1994
|
+
}
|
|
1995
|
+
function getBearerAuthDescription() {
|
|
1996
|
+
return `Provide your bearer token in the Authorization header when making requests to protected resources.
|
|
1997
|
+
|
|
1998
|
+
Example: \`Authorization: Bearer 123\``;
|
|
1999
|
+
}
|
|
2000
|
+
function getDigestAuthDescription() {
|
|
2001
|
+
return `Provide your encrypted digest scheme data in the Authorization header when making requests to protected resources.
|
|
2002
|
+
|
|
2003
|
+
Example: \`Authorization: Digest username=guest, realm="test", nonce="2", uri="/uri", response="123"\``;
|
|
2004
|
+
}
|
|
2005
|
+
function getOAuthDescription(scheme) {
|
|
2006
|
+
const flows = keys__default["default"](scheme.flows);
|
|
2007
|
+
return flows.map(flow => getOAuthFlowDescription(oauthFlowNames[flow], scheme.flows[flow])).join('\n\n');
|
|
2008
|
+
}
|
|
2009
|
+
function getOAuthFlowDescription(title, flow) {
|
|
2010
|
+
let description = `**${title} OAuth Flow**`;
|
|
2011
|
+
description +=
|
|
2012
|
+
isOAuth2ImplicitFlow(flow) || isOauth2AuthorizationCodeFlow(flow)
|
|
2013
|
+
? `\n\nAuthorize URL: ${flow.authorizationUrl}`
|
|
2014
|
+
: '';
|
|
2015
|
+
description +=
|
|
2016
|
+
isOauth2AuthorizationCodeFlow(flow) || isOauth2ClientCredentialsOrPasswordFlow(flow)
|
|
2017
|
+
? `\n\nToken URL: ${flow.tokenUrl}`
|
|
2018
|
+
: '';
|
|
2019
|
+
description += flow.refreshUrl ? `\n\nRefresh URL: ${flow.refreshUrl}` : '';
|
|
2020
|
+
const scopes = entries__default["default"](flow.scopes);
|
|
2021
|
+
if (scopes.length) {
|
|
2022
|
+
description += `\n\nScopes:
|
|
2023
|
+
${scopes.map(([key, value]) => `- \`${key}\` - ${value}`).join('\n')}`;
|
|
2024
|
+
}
|
|
2025
|
+
return description;
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
const SectionTitle = ({ title, id, size = 2, children }) => {
|
|
2029
|
+
return (React__namespace.createElement(mosaic.HStack, { spacing: 6 },
|
|
2030
|
+
React__namespace.createElement(mosaic.Box, { as: mosaic.LinkHeading, size: size, "aria-label": title, id: id || slugify(title) }, title),
|
|
1869
2031
|
children));
|
|
1870
2032
|
};
|
|
1871
|
-
const
|
|
1872
|
-
return
|
|
2033
|
+
const SectionSubtitle = props => {
|
|
2034
|
+
return React__namespace.createElement(SectionTitle, Object.assign({}, props, { size: 3 }));
|
|
2035
|
+
};
|
|
2036
|
+
const SubSectionPanel = ({ title, children, hasContent, rightComponent, defaultIsOpen = true, onChange, }) => {
|
|
2037
|
+
return (React__namespace.createElement(mosaic.Panel, { isCollapsible: hasContent, defaultIsOpen: defaultIsOpen, onChange: onChange, appearance: "outlined" },
|
|
1873
2038
|
React__namespace.createElement(mosaic.Panel.Titlebar, { fontWeight: "medium", rightComponent: rightComponent },
|
|
1874
2039
|
React__namespace.createElement("div", { role: "heading" }, title)),
|
|
1875
|
-
hasContent !== false &&
|
|
2040
|
+
hasContent !== false && React__namespace.createElement(mosaic.Panel.Content, null, children)));
|
|
1876
2041
|
};
|
|
1877
2042
|
|
|
1878
|
-
const
|
|
2043
|
+
const isBodyEmpty = (body) => {
|
|
2044
|
+
if (!body)
|
|
2045
|
+
return true;
|
|
2046
|
+
const { contents = [], description } = body;
|
|
2047
|
+
return contents.length === 0 && !(description === null || description === void 0 ? void 0 : description.trim());
|
|
2048
|
+
};
|
|
2049
|
+
const Body = ({ body, onChange }) => {
|
|
1879
2050
|
var _a;
|
|
1880
2051
|
const refResolver = useInlineRefResolver();
|
|
1881
2052
|
const [chosenContent, setChosenContent] = React__namespace.useState(0);
|
|
1882
2053
|
React__namespace.useEffect(() => {
|
|
1883
2054
|
onChange(chosenContent);
|
|
1884
2055
|
}, [chosenContent]);
|
|
1885
|
-
if (
|
|
2056
|
+
if (isBodyEmpty(body))
|
|
1886
2057
|
return null;
|
|
2058
|
+
const { contents = [], description } = body;
|
|
1887
2059
|
const schema = (_a = contents[chosenContent]) === null || _a === void 0 ? void 0 : _a.schema;
|
|
1888
|
-
return (React__namespace.createElement(
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
2060
|
+
return (React__namespace.createElement(mosaic.VStack, { spacing: 6 },
|
|
2061
|
+
React__namespace.createElement(SectionSubtitle, { title: "Body", id: "request-body" }, contents.length > 0 && (React__namespace.createElement(mosaic.Flex, { flex: 1, justify: "end" },
|
|
2062
|
+
React__namespace.createElement(mosaic.Select, { "aria-label": "Request Body Content Type", value: String(chosenContent), onChange: (value) => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" })))),
|
|
2063
|
+
description && React__namespace.createElement(MarkdownViewer, { markdown: description }),
|
|
2064
|
+
isJSONSchema(schema) && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: refResolver, schema: getOriginalObject(schema), viewMode: "write", hideExamples: true, renderRootTreeLines: true }))));
|
|
1892
2065
|
};
|
|
1893
2066
|
Body.displayName = 'HttpOperation.Body';
|
|
1894
2067
|
|
|
@@ -1912,87 +2085,100 @@ const defaultStyle = {
|
|
|
1912
2085
|
cookie: types.HttpParamStyles.Form,
|
|
1913
2086
|
};
|
|
1914
2087
|
const Parameters = ({ parameters, parameterType }) => {
|
|
1915
|
-
|
|
2088
|
+
const schema = React__namespace.useMemo(() => httpOperationParamsToSchema({ parameters, parameterType }), [parameters, parameterType]);
|
|
2089
|
+
if (!schema)
|
|
1916
2090
|
return null;
|
|
1917
|
-
return
|
|
1918
|
-
return React__namespace.createElement(Parameter, { key: parameter.name, parameter: parameter, parameterType: parameterType });
|
|
1919
|
-
})));
|
|
2091
|
+
return React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { schema: schema, disableCrumbs: true });
|
|
1920
2092
|
};
|
|
1921
2093
|
Parameters.displayName = 'HttpOperation.Parameters';
|
|
1922
|
-
const
|
|
1923
|
-
var _a
|
|
1924
|
-
if (!
|
|
2094
|
+
const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
2095
|
+
var _a;
|
|
2096
|
+
if (!parameters || !parameters.length)
|
|
1925
2097
|
return null;
|
|
1926
|
-
const
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
const
|
|
1931
|
-
const
|
|
1932
|
-
if (
|
|
1933
|
-
|
|
2098
|
+
const schema = {
|
|
2099
|
+
properties: {},
|
|
2100
|
+
required: [],
|
|
2101
|
+
};
|
|
2102
|
+
const sortedParams = sortBy__default["default"](parameters, ['required', 'name']);
|
|
2103
|
+
for (const p of sortedParams) {
|
|
2104
|
+
if (!p.schema)
|
|
2105
|
+
continue;
|
|
2106
|
+
const { name, description, required, deprecated, examples, style } = p;
|
|
2107
|
+
const paramExamples = (examples === null || examples === void 0 ? void 0 : examples.map(example => {
|
|
2108
|
+
if (isNodeExample(example)) {
|
|
2109
|
+
return example.value;
|
|
2110
|
+
}
|
|
2111
|
+
return example.externalValue;
|
|
2112
|
+
})) || [];
|
|
2113
|
+
const schemaExamples = (_a = p.schema) === null || _a === void 0 ? void 0 : _a.examples;
|
|
2114
|
+
const schemaExamplesArray = Array.isArray(schemaExamples) ? schemaExamples : [];
|
|
2115
|
+
const paramDescription = description || p.schema.description;
|
|
2116
|
+
const paramDeprecated = deprecated || p.schema.deprecated;
|
|
2117
|
+
const paramStyle = style && defaultStyle[parameterType] !== style ? readableStyles[style] || style : undefined;
|
|
2118
|
+
schema.properties[p.name] = Object.assign(Object.assign({}, p.schema), { description: paramDescription, examples: [...paramExamples, ...schemaExamplesArray], deprecated: paramDeprecated, style: paramStyle });
|
|
2119
|
+
if (required) {
|
|
2120
|
+
schema.required.push(name);
|
|
1934
2121
|
}
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
const schemaExamplesArray = Array.isArray(schemaExamples) ? schemaExamples : [];
|
|
1939
|
-
const validations = _.omitBy(Object.assign(Object.assign(Object.assign(Object.assign({}, _.omit(parameter, ['name', 'required', 'deprecated', 'description', 'schema', 'style', 'examples'])), _.omit(_.get(parameter, 'schema'), ['description', 'type', 'deprecated'])), _.omit(_.get(parameter, 'schema.items'), ['description', 'type', 'deprecated'])), { examples: [...parameterExamples, ...schemaExamplesArray] }), value => (typeof value === 'object' && _.isEmpty(value)) || typeof value === 'undefined');
|
|
1940
|
-
return (React__namespace.createElement("div", { className: "HttpOperation__Parameters" },
|
|
1941
|
-
React__namespace.createElement("div", { className: "sl-flex sl-items-center sl-my-2" },
|
|
1942
|
-
React__namespace.createElement("div", { className: "sl-flex sl-items-baseline sl-text-base sl-flex-1" },
|
|
1943
|
-
React__namespace.createElement("div", { className: "sl-font-mono sl-font-bold" }, parameter.name),
|
|
1944
|
-
React__namespace.createElement("div", { className: 'sl-ml-2 sl-text-muted' }, format ? `${type}<${format}>` : type)),
|
|
1945
|
-
React__namespace.createElement("div", { className: "sl-text-sm sl-text-warning" },
|
|
1946
|
-
deprecated && React__namespace.createElement("span", { className: "sl-ml-2" }, "deprecated"),
|
|
1947
|
-
parameter.required && React__namespace.createElement("span", { className: "sl-ml-2" }, "required"))),
|
|
1948
|
-
description && (React__namespace.createElement("div", { className: "sl-w-full sl-text-muted sl-text-sm sl-my-2" },
|
|
1949
|
-
React__namespace.createElement(markdownViewer.MarkdownViewer, { markdown: description }))),
|
|
1950
|
-
React__namespace.createElement("div", { className: "sl-text-sm" },
|
|
1951
|
-
React__namespace.createElement(jsonSchemaViewer.Validations, { validations: validations })),
|
|
1952
|
-
parameter.style && defaultStyle[parameterType] !== parameter.style && (React__namespace.createElement("div", { className: "sl-flex sl-my-2" },
|
|
1953
|
-
React__namespace.createElement("span", { className: "sl-px-1 sl-text-muted sl-font-mono sl-border sl-rounded-lg sl-text-sm sl-capitalize", style: { backgroundColor: '#EDF2F7' } }, readableStyles[parameter.style] || parameter.style)))));
|
|
1954
|
-
};
|
|
1955
|
-
Parameter.displayName = 'HttpOperation.Parameter';
|
|
2122
|
+
}
|
|
2123
|
+
return schema;
|
|
2124
|
+
};
|
|
1956
2125
|
|
|
1957
|
-
const Request = ({ operation: {
|
|
2126
|
+
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, onChange, }) => {
|
|
1958
2127
|
if (!request || typeof request !== 'object')
|
|
1959
2128
|
return null;
|
|
1960
|
-
const
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
2129
|
+
const bodyIsEmpty = isBodyEmpty(body);
|
|
2130
|
+
const securitySchemes = flatten__default["default"](security);
|
|
2131
|
+
const hasRequestData = Boolean(securitySchemes.length ||
|
|
2132
|
+
pathParams.length ||
|
|
2133
|
+
queryParams.length ||
|
|
2134
|
+
headerParams.length ||
|
|
2135
|
+
cookieParams.length ||
|
|
2136
|
+
!bodyIsEmpty);
|
|
2137
|
+
if (!hasRequestData)
|
|
2138
|
+
return null;
|
|
2139
|
+
return (React__namespace.createElement(mosaic.VStack, { spacing: 8 },
|
|
1965
2140
|
React__namespace.createElement(SectionTitle, { title: "Request" }),
|
|
1966
|
-
React__namespace.createElement(
|
|
1967
|
-
|
|
1968
|
-
|
|
2141
|
+
securitySchemes.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 3 }, securitySchemes.map((scheme, i) => (React__namespace.createElement(SecurityPanel, { key: i, scheme: scheme, includeKey: shouldIncludeKey(securitySchemes, scheme.type) }))))),
|
|
2142
|
+
pathParams.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2143
|
+
React__namespace.createElement(SectionSubtitle, { title: "Path Parameters" }),
|
|
2144
|
+
React__namespace.createElement(Parameters, { parameterType: "path", parameters: pathParams }))),
|
|
2145
|
+
queryParams.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2146
|
+
React__namespace.createElement(SectionSubtitle, { title: "Query Parameters" }),
|
|
1969
2147
|
React__namespace.createElement(Parameters, { parameterType: "query", parameters: queryParams }))),
|
|
1970
|
-
headerParams.length > 0 && (React__namespace.createElement(
|
|
2148
|
+
headerParams.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2149
|
+
React__namespace.createElement(SectionSubtitle, { title: "Headers", id: "request-headers" }),
|
|
1971
2150
|
React__namespace.createElement(Parameters, { parameterType: "header", parameters: headerParams }))),
|
|
1972
|
-
cookieParams.length > 0 && (React__namespace.createElement(
|
|
2151
|
+
cookieParams.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2152
|
+
React__namespace.createElement(SectionSubtitle, { title: "Cookies", id: "request-cookies" }),
|
|
1973
2153
|
React__namespace.createElement(Parameters, { parameterType: "cookie", parameters: cookieParams }))),
|
|
1974
2154
|
body && React__namespace.createElement(Body, { onChange: onChange, body: body })));
|
|
1975
2155
|
};
|
|
1976
|
-
Request.displayName = 'HttpOperation.Request';
|
|
2156
|
+
Request.displayName = 'HttpOperation.Request';
|
|
2157
|
+
const schemeExpandedState = utils.atomWithStorage('HttpOperation_security_expanded', {});
|
|
2158
|
+
const SecurityPanel = ({ scheme, includeKey }) => {
|
|
2159
|
+
const [expandedState, setExpanded] = jotai.useAtom(schemeExpandedState);
|
|
2160
|
+
return (React__namespace.createElement(SubSectionPanel, { title: `Security: ${getReadableSecurityName(scheme, includeKey)}`, defaultIsOpen: !!expandedState[scheme.key], onChange: isOpen => setExpanded(Object.assign(Object.assign({}, expandedState), { [scheme.key]: isOpen })) },
|
|
2161
|
+
React__namespace.createElement(MarkdownViewer, { style: { fontSize: 12 }, markdown: `${scheme.description || ''}\n\n` + getDefaultDescription(scheme) })));
|
|
2162
|
+
};
|
|
1977
2163
|
|
|
1978
2164
|
const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange }) => {
|
|
1979
2165
|
var _a, _b;
|
|
1980
|
-
const responses =
|
|
2166
|
+
const responses = sortBy__default["default"](uniqBy__default["default"](unsortedResponses, r => r.code), r => r.code);
|
|
1981
2167
|
const [activeResponseId, setActiveResponseId] = React__namespace.useState((_b = (_a = responses[0]) === null || _a === void 0 ? void 0 : _a.code) !== null && _b !== void 0 ? _b : '');
|
|
1982
2168
|
React__namespace.useEffect(() => {
|
|
1983
2169
|
onStatusCodeChange(activeResponseId);
|
|
1984
2170
|
}, [activeResponseId]);
|
|
1985
2171
|
if (!responses.length)
|
|
1986
2172
|
return null;
|
|
1987
|
-
return (React__namespace.createElement(mosaic.
|
|
1988
|
-
React__namespace.createElement(
|
|
1989
|
-
React__namespace.createElement(
|
|
1990
|
-
|
|
1991
|
-
React__namespace.createElement(
|
|
1992
|
-
React__namespace.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange }))))))));
|
|
2173
|
+
return (React__namespace.createElement(mosaic.VStack, { spacing: 8, as: mosaic.Tabs, selectedId: activeResponseId, onChange: setActiveResponseId, appearance: "pill" },
|
|
2174
|
+
React__namespace.createElement(SectionTitle, { title: "Responses" },
|
|
2175
|
+
React__namespace.createElement(mosaic.TabList, { density: "compact" }, responses.map(({ code }) => (React__namespace.createElement(mosaic.Tab, { key: code, id: code, intent: codeToIntentVal(code) }, code))))),
|
|
2176
|
+
React__namespace.createElement(mosaic.TabPanels, { p: 0 }, responses.map(response => (React__namespace.createElement(mosaic.TabPanel, { key: response.code, id: response.code },
|
|
2177
|
+
React__namespace.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange })))))));
|
|
1993
2178
|
};
|
|
1994
2179
|
Responses.displayName = 'HttpOperation.Responses';
|
|
1995
|
-
const Response = ({ response
|
|
2180
|
+
const Response = ({ response, onMediaTypeChange }) => {
|
|
2181
|
+
const { contents = [], headers = [], description } = response;
|
|
1996
2182
|
const [chosenContent, setChosenContent] = React__namespace.useState(0);
|
|
1997
2183
|
const refResolver = useInlineRefResolver();
|
|
1998
2184
|
const responseContent = contents[chosenContent];
|
|
@@ -2000,16 +2186,33 @@ const Response = ({ response: { contents = [], headers = [], description }, onMe
|
|
|
2000
2186
|
React__namespace.useEffect(() => {
|
|
2001
2187
|
responseContent && onMediaTypeChange(responseContent.mediaType);
|
|
2002
2188
|
}, [responseContent]);
|
|
2003
|
-
return (React__namespace.createElement(mosaic.
|
|
2004
|
-
description && React__namespace.createElement(MarkdownViewer, {
|
|
2005
|
-
headers.length > 0 && (React__namespace.createElement(
|
|
2189
|
+
return (React__namespace.createElement(mosaic.VStack, { spacing: 8, pt: 8 },
|
|
2190
|
+
description && React__namespace.createElement(MarkdownViewer, { markdown: description }),
|
|
2191
|
+
headers.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2192
|
+
React__namespace.createElement(SectionSubtitle, { title: "Headers", id: "response-headers" }),
|
|
2006
2193
|
React__namespace.createElement(Parameters, { parameterType: "header", parameters: headers }))),
|
|
2007
|
-
contents.length > 0 && (React__namespace.createElement(
|
|
2008
|
-
React__namespace.createElement(
|
|
2194
|
+
contents.length > 0 && (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2195
|
+
React__namespace.createElement(SectionSubtitle, { title: "Body", id: "response-body" },
|
|
2196
|
+
React__namespace.createElement(mosaic.Flex, { flex: 1, justify: "end" },
|
|
2197
|
+
React__namespace.createElement(mosaic.Select, { "aria-label": "Response Body Content Type", value: String(chosenContent), onChange: (value) => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" }))),
|
|
2198
|
+
schema && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, viewMode: "read", hideExamples: true, parentCrumbs: ['responses', response.code], renderRootTreeLines: true }))))));
|
|
2009
2199
|
};
|
|
2010
|
-
Response.displayName = 'HttpOperation.Response';
|
|
2200
|
+
Response.displayName = 'HttpOperation.Response';
|
|
2201
|
+
const codeToIntentVal = (code) => {
|
|
2202
|
+
const firstChar = code.charAt(0);
|
|
2203
|
+
switch (firstChar) {
|
|
2204
|
+
case '2':
|
|
2205
|
+
return 'success';
|
|
2206
|
+
case '4':
|
|
2207
|
+
return 'warning';
|
|
2208
|
+
case '5':
|
|
2209
|
+
return 'danger';
|
|
2210
|
+
default:
|
|
2211
|
+
return 'default';
|
|
2212
|
+
}
|
|
2213
|
+
};
|
|
2011
2214
|
|
|
2012
|
-
const HttpOperationComponent = React__namespace.memo(({ className, data: unresolvedData,
|
|
2215
|
+
const HttpOperationComponent = React__namespace.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy }) => {
|
|
2013
2216
|
const data = useResolvedObject(unresolvedData);
|
|
2014
2217
|
const mocking = React__namespace.useContext(MockingContext);
|
|
2015
2218
|
const isDeprecated = !!data.deprecated;
|
|
@@ -2017,32 +2220,50 @@ const HttpOperationComponent = React__namespace.memo(({ className, data: unresol
|
|
|
2017
2220
|
const [responseMediaType, setResponseMediaType] = React__namespace.useState('');
|
|
2018
2221
|
const [responseStatusCode, setResponseStatusCode] = React__namespace.useState('');
|
|
2019
2222
|
const [requestBodyIndex, setTextRequestBodyIndex] = React__namespace.useState(0);
|
|
2020
|
-
const
|
|
2021
|
-
const
|
|
2022
|
-
const
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
const description = (React__namespace.createElement(
|
|
2030
|
-
data.description &&
|
|
2223
|
+
const prettyName = (data.summary || data.iid || '').trim();
|
|
2224
|
+
const hasBadges = isDeprecated || isInternal;
|
|
2225
|
+
const header = (!(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) || hasBadges) && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2226
|
+
React__namespace.createElement(mosaic.HStack, { spacing: 5 },
|
|
2227
|
+
!(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) && prettyName ? (React__namespace.createElement(mosaic.Heading, { size: 1, fontWeight: "semibold" }, prettyName)) : null,
|
|
2228
|
+
React__namespace.createElement(mosaic.HStack, { spacing: 2 },
|
|
2229
|
+
isDeprecated && React__namespace.createElement(DeprecatedBadge, null),
|
|
2230
|
+
isInternal && React__namespace.createElement(InternalBadge, { isHttpService: true }))),
|
|
2231
|
+
React__namespace.createElement(MethodPath, { method: data.method, path: data.path })));
|
|
2232
|
+
const description = (React__namespace.createElement(mosaic.VStack, { spacing: 10 },
|
|
2233
|
+
data.description && React__namespace.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
|
|
2031
2234
|
React__namespace.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data }),
|
|
2032
2235
|
data.responses && (React__namespace.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode }))));
|
|
2033
|
-
const tryItPanel = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideTryItPanel) && (React__namespace.createElement(
|
|
2034
|
-
React__namespace.createElement(TryItWithRequestSamples, { httpOperation: data, responseMediaType: responseMediaType, responseStatusCode: responseStatusCode, requestBodyIndex: requestBodyIndex, hideTryIt: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideTryIt, tryItCredentialsPolicy: tryItCredentialsPolicy, mockUrl: mocking.hideMocking ? undefined : mocking.mockUrl, corsProxy: tryItCorsProxy })));
|
|
2236
|
+
const tryItPanel = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideTryItPanel) && (React__namespace.createElement(TryItWithRequestSamples, { httpOperation: data, responseMediaType: responseMediaType, responseStatusCode: responseStatusCode, requestBodyIndex: requestBodyIndex, hideTryIt: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideTryIt, tryItCredentialsPolicy: tryItCredentialsPolicy, mockUrl: mocking.hideMocking ? undefined : mocking.mockUrl, corsProxy: tryItCorsProxy }));
|
|
2035
2237
|
return (React__namespace.createElement(TwoColumnLayout, { className: cn__default["default"]('HttpOperation', className), header: header, left: description, right: tryItPanel }));
|
|
2036
2238
|
});
|
|
2037
2239
|
HttpOperationComponent.displayName = 'HttpOperation.Component';
|
|
2038
2240
|
const HttpOperation = reactErrorBoundary.withErrorBoundary(HttpOperationComponent, {
|
|
2039
2241
|
recoverableProps: ['data'],
|
|
2040
|
-
});
|
|
2242
|
+
});
|
|
2243
|
+
function MethodPath({ method, path }) {
|
|
2244
|
+
const chosenServer = utils.useAtomValue(chosenServerAtom);
|
|
2245
|
+
let chosenServerUrl = '';
|
|
2246
|
+
if (chosenServer) {
|
|
2247
|
+
chosenServerUrl = chosenServer.url.endsWith('/') ? chosenServer.url.slice(0, -1) : chosenServer.url;
|
|
2248
|
+
}
|
|
2249
|
+
return (React__namespace.createElement(mosaic.Box, null,
|
|
2250
|
+
React__namespace.createElement(MethodPathInner, { method: method, path: path, chosenServerUrl: chosenServerUrl })));
|
|
2251
|
+
}
|
|
2252
|
+
function MethodPathInner({ method, path, chosenServerUrl }) {
|
|
2253
|
+
const isDark = mosaic.useThemeIsDark();
|
|
2254
|
+
const fullUrl = `${chosenServerUrl}${path}`;
|
|
2255
|
+
const pathElem = (React__namespace.createElement(mosaic.Flex, { overflowX: "hidden" },
|
|
2256
|
+
chosenServerUrl ? (React__namespace.createElement(mosaic.Box, { dir: "rtl", color: "muted", fontSize: "lg", textOverflow: "truncate", overflowX: "hidden" }, chosenServerUrl)) : null,
|
|
2257
|
+
React__namespace.createElement(mosaic.Box, { fontSize: "lg", fontWeight: "semibold", flex: 1 }, path)));
|
|
2258
|
+
return (React__namespace.createElement(mosaic.HStack, { spacing: 3, pl: 2.5, pr: 4, py: 2, bg: "canvas-50", rounded: "lg", fontFamily: "mono", display: "inline-flex", maxW: "full", title: fullUrl },
|
|
2259
|
+
React__namespace.createElement(mosaic.Box, { py: 1, px: 2.5, rounded: "lg", bg: !isDark ? HttpMethodColors[method] : 'canvas-100', color: !isDark ? 'on-primary' : 'body', fontSize: "lg", fontWeight: "semibold", textTransform: "uppercase" }, method),
|
|
2260
|
+
pathElem));
|
|
2261
|
+
}
|
|
2041
2262
|
|
|
2042
2263
|
const PoweredByLink = ({ source, pathname, packageType, layout = 'sidebar' }) => {
|
|
2043
2264
|
return (React__namespace.createElement(mosaic.Flex, { as: "a", align: "center", borderT: layout === 'stacked' ? undefined : true, px: layout === 'stacked' ? 1 : 4, py: 3, justify: layout === 'stacked' ? 'end' : undefined, href: `https://stoplight.io/?utm_source=${packageType}&utm_medium=${source}&utm_campaign=powered_by&utm_content=${pathname}`, target: "_blank", rel: "noopener noreferrer" },
|
|
2044
|
-
React__namespace.createElement(
|
|
2045
|
-
React__namespace.createElement(
|
|
2265
|
+
React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, icon: freeSolidSvgIcons.faBolt, mr: 1, className: "fa-fw", style: { color: 'rgba(144, 97, 249, 1)' } }),
|
|
2266
|
+
React__namespace.createElement(mosaic.Box, null,
|
|
2046
2267
|
"powered by\u00A0",
|
|
2047
2268
|
React__namespace.createElement("strong", null, "Stoplight"))));
|
|
2048
2269
|
};
|
|
@@ -2073,91 +2294,28 @@ const ExportButton = ({ original, bundled }) => {
|
|
|
2073
2294
|
return items;
|
|
2074
2295
|
}, [original, bundled]);
|
|
2075
2296
|
return (React__namespace.createElement(mosaic.Box, null,
|
|
2076
|
-
React__namespace.createElement(mosaic.Menu, { "aria-label": "Export", items: menuItems, renderTrigger: ({ isOpen }) => (React__namespace.createElement(mosaic.Button, { iconRight: "chevron-down", appearance: "default", ml: 2, active: isOpen, size: "sm" }, "Export")) })));
|
|
2297
|
+
React__namespace.createElement(mosaic.Menu, { "aria-label": "Export", items: menuItems, placement: "bottom right", renderTrigger: ({ isOpen }) => (React__namespace.createElement(mosaic.Button, { iconRight: "chevron-down", appearance: "default", ml: 2, active: isOpen, size: "sm" }, "Export")) })));
|
|
2077
2298
|
};
|
|
2078
2299
|
|
|
2079
|
-
const
|
|
2080
|
-
|
|
2081
|
-
authorizationCode: 'Authorization Code',
|
|
2082
|
-
clientCredentials: 'Client Credentials',
|
|
2083
|
-
password: 'Password',
|
|
2084
|
-
};
|
|
2085
|
-
const SecuritySchemes = ({ schemes, defaultScheme }) => {
|
|
2086
|
-
return (React__default["default"].createElement(mosaic.Panel, { rounded: true, isCollapsible: false },
|
|
2300
|
+
const SecuritySchemes = ({ schemes, defaultScheme, defaultCollapsed = false, }) => {
|
|
2301
|
+
return (React__default["default"].createElement(mosaic.Panel, { rounded: true, isCollapsible: defaultCollapsed },
|
|
2087
2302
|
React__default["default"].createElement(mosaic.Panel.Titlebar, { bg: "canvas-300" },
|
|
2088
|
-
React__default["default"].createElement("span",
|
|
2089
|
-
React__default["default"].createElement(mosaic.Panel.Content, { p: 0 },
|
|
2090
|
-
React__default["default"].createElement(mosaic.Panel.Titlebar, null,
|
|
2091
|
-
React__default["default"].createElement("span", { role: "heading" }, getReadableSecurityName(scheme, shouldIncludeKey(schemes, scheme.type)))),
|
|
2092
|
-
React__default["default"].createElement(mosaic.Panel.Content, null,
|
|
2093
|
-
React__default["default"].createElement(MarkdownViewer, { style: { fontSize: 12 }, markdown: `${scheme.description || ''}\n\n` + getDefaultDescription(scheme) }))))))));
|
|
2303
|
+
React__default["default"].createElement(mosaic.Box, { as: "span", role: "heading" }, "Security")),
|
|
2304
|
+
React__default["default"].createElement(mosaic.Panel.Content, { p: 0 }, sortBy__default["default"](schemes, 'type').map((scheme, i) => (React__default["default"].createElement(SecurityScheme, { key: i, scheme: scheme, defaultIsOpen: defaultScheme ? scheme.key === defaultScheme : i === 0, isCollapsible: schemes.length > 1, showSchemeKey: shouldIncludeKey(schemes, scheme.type) }))))));
|
|
2094
2305
|
};
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
return getBasicAuthDescription();
|
|
2103
|
-
case 'bearer':
|
|
2104
|
-
return getBearerAuthDescription();
|
|
2105
|
-
case 'digest':
|
|
2106
|
-
return getDigestAuthDescription();
|
|
2107
|
-
}
|
|
2108
|
-
case 'oauth2':
|
|
2109
|
-
return getOAuthDescription(scheme);
|
|
2110
|
-
}
|
|
2111
|
-
return '';
|
|
2112
|
-
}
|
|
2113
|
-
function getApiKeyDescription(inProperty, name) {
|
|
2114
|
-
return `An API key is a token that you provide when making API calls. Include the token in a ${inProperty} parameter called \`${name}\`.
|
|
2115
|
-
|
|
2116
|
-
Example: ${inProperty === 'query' ? `\`?${name}=123\`` : `\`${name}: 123\``}`;
|
|
2117
|
-
}
|
|
2118
|
-
function getBasicAuthDescription() {
|
|
2119
|
-
return `Basic authentication is a simple authentication scheme built into the HTTP protocol.
|
|
2120
|
-
To use it, send your HTTP requests with an Authorization header that contains the word Basic
|
|
2121
|
-
followed by a space and a base64-encoded string \`username:password\`.
|
|
2122
|
-
|
|
2123
|
-
Example: \`Authorization: Basic ZGVtbzpwQDU1dzByZA==\``;
|
|
2124
|
-
}
|
|
2125
|
-
function getBearerAuthDescription() {
|
|
2126
|
-
return `Provide your bearer token in the Authorization header when making requests to protected resources.
|
|
2127
|
-
|
|
2128
|
-
Example: \`Authorization: Bearer 123\``;
|
|
2129
|
-
}
|
|
2130
|
-
function getDigestAuthDescription() {
|
|
2131
|
-
return `Provide your encrypted digest scheme data in the Authorization header when making requests to protected resources.
|
|
2132
|
-
|
|
2133
|
-
Example: \`Authorization: Digest username=guest, realm="test", nonce="2", uri="/uri", response="123"\``;
|
|
2134
|
-
}
|
|
2135
|
-
function getOAuthDescription(scheme) {
|
|
2136
|
-
const flows = _.keys(scheme.flows);
|
|
2137
|
-
return flows.map(flow => getOAuthFlowDescription(oauthFlowNames[flow], scheme.flows[flow])).join('\n\n');
|
|
2138
|
-
}
|
|
2139
|
-
function getOAuthFlowDescription(title, flow) {
|
|
2140
|
-
let description = `**${title} OAuth Flow**`;
|
|
2141
|
-
description +=
|
|
2142
|
-
isOAuth2ImplicitFlow(flow) || isOauth2AuthorizationCodeFlow(flow)
|
|
2143
|
-
? `\n\nAuthorize URL: ${flow.authorizationUrl}`
|
|
2144
|
-
: '';
|
|
2145
|
-
description +=
|
|
2146
|
-
isOauth2AuthorizationCodeFlow(flow) || isOauth2ClientCredentialsOrPasswordFlow(flow)
|
|
2147
|
-
? `\n\nToken URL: ${flow.tokenUrl}`
|
|
2148
|
-
: '';
|
|
2149
|
-
description += flow.refreshUrl ? `\n\nRefresh URL: ${flow.refreshUrl}` : '';
|
|
2150
|
-
description += `\n\nScopes:
|
|
2151
|
-
${_.entries(flow.scopes)
|
|
2152
|
-
.map(([key, value]) => `- \`${key}\` - ${value}`)
|
|
2153
|
-
.join('\n')}`;
|
|
2154
|
-
return description;
|
|
2155
|
-
}
|
|
2306
|
+
const SecurityScheme = ({ scheme, defaultIsOpen, isCollapsible, showSchemeKey }) => {
|
|
2307
|
+
return (React__default["default"].createElement(mosaic.Panel, { defaultIsOpen: defaultIsOpen, isCollapsible: isCollapsible },
|
|
2308
|
+
React__default["default"].createElement(mosaic.Panel.Titlebar, null,
|
|
2309
|
+
React__default["default"].createElement(mosaic.Box, { as: "span", role: "heading" }, getReadableSecurityName(scheme, showSchemeKey))),
|
|
2310
|
+
React__default["default"].createElement(mosaic.Panel.Content, null,
|
|
2311
|
+
React__default["default"].createElement(MarkdownViewer, { style: { fontSize: 12 }, markdown: `${scheme.description || ''}\n\n` + getDefaultDescription(scheme) }))));
|
|
2312
|
+
};
|
|
2156
2313
|
|
|
2157
2314
|
const ServerInfo = ({ servers, mockUrl }) => {
|
|
2158
2315
|
const mocking = React__namespace.useContext(MockingContext);
|
|
2159
2316
|
const showMocking = !mocking.hideMocking && mockUrl && isProperUrl(mockUrl);
|
|
2160
|
-
const
|
|
2317
|
+
const $mockUrl = showMocking ? mockUrl || mocking.mockUrl : undefined;
|
|
2318
|
+
const serversToDisplay = getServersToDisplay(servers, $mockUrl);
|
|
2161
2319
|
if (!showMocking && serversToDisplay.length === 0) {
|
|
2162
2320
|
return null;
|
|
2163
2321
|
}
|
|
@@ -2166,14 +2324,11 @@ const ServerInfo = ({ servers, mockUrl }) => {
|
|
|
2166
2324
|
React__namespace.createElement(mosaic.Panel.Titlebar, { whitespace: "nowrap" }, "API Base URL"),
|
|
2167
2325
|
React__namespace.createElement(mosaic.Box, { overflowX: "auto" },
|
|
2168
2326
|
React__namespace.createElement(mosaic.Panel.Content, { w: "full", className: "sl-flex sl-flex-col" },
|
|
2169
|
-
serversToDisplay.map((server, index) => (React__namespace.createElement(ServerUrl, Object.assign({}, server, { key: index }))))
|
|
2170
|
-
showMocking && (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2171
|
-
React__namespace.createElement(mosaic.Box, { borderT: 2, pt: 2, borderColor: "light", w: "full" }),
|
|
2172
|
-
React__namespace.createElement(ServerUrl, { description: "Mock Server", url: mockUrl || '', marginBottom: false }))))))));
|
|
2327
|
+
React__namespace.createElement(mosaic.VStack, { spacing: 1, divider: true }, serversToDisplay.map((server, index) => (React__namespace.createElement(ServerUrl, Object.assign({}, server, { key: index }))))))))));
|
|
2173
2328
|
};
|
|
2174
2329
|
const ServerUrl = ({ description, url, marginBottom = true }) => {
|
|
2175
2330
|
const { onCopy, hasCopied } = mosaic.useClipboard(url);
|
|
2176
|
-
return (React__namespace.createElement(mosaic.Box, { whitespace: "nowrap"
|
|
2331
|
+
return (React__namespace.createElement(mosaic.Box, { whitespace: "nowrap" },
|
|
2177
2332
|
React__namespace.createElement(mosaic.Text, { pr: 2, fontWeight: "bold" },
|
|
2178
2333
|
description,
|
|
2179
2334
|
":"),
|
|
@@ -2222,14 +2377,13 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
2222
2377
|
};
|
|
2223
2378
|
const examples = React__namespace.useMemo(() => generateExamplesFromJsonSchema(data), [data]);
|
|
2224
2379
|
const shouldDisplayHeader = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) && (title !== undefined || (exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport)));
|
|
2225
|
-
const header = (shouldDisplayHeader || isInternal) && (React__namespace.createElement(
|
|
2226
|
-
|
|
2227
|
-
React__namespace.createElement(mosaic.Heading, { size: 1,
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
data.description && data.type === 'object' && (React__namespace.createElement(MarkdownViewer, { className: "sl-mb-6", role: "textbox", markdown: data.description })),
|
|
2380
|
+
const header = (shouldDisplayHeader || isInternal) && (React__namespace.createElement(mosaic.Flex, { justifyContent: "between", alignItems: "center" },
|
|
2381
|
+
React__namespace.createElement(mosaic.HStack, { spacing: 5 },
|
|
2382
|
+
title && (React__namespace.createElement(mosaic.Heading, { size: 1, fontWeight: "semibold" }, title)),
|
|
2383
|
+
React__namespace.createElement(mosaic.HStack, { spacing: 2 }, isInternal && React__namespace.createElement(InternalBadge, null))),
|
|
2384
|
+
exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && React__namespace.createElement(ExportButton, Object.assign({}, exportProps))));
|
|
2385
|
+
const description = (React__namespace.createElement(mosaic.VStack, { spacing: 10 },
|
|
2386
|
+
data.description && data.type === 'object' && React__namespace.createElement(MarkdownViewer, { role: "textbox", markdown: data.description }),
|
|
2233
2387
|
React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: resolveRef, schema: getOriginalObject(data) })));
|
|
2234
2388
|
const examplesSelect = examples.length > 1 && (React__namespace.createElement(mosaic.Select, { "aria-label": "Example", value: String(chosenExampleIndex), options: examples.map(({ label }, index) => ({ value: index, label })), onChange: (value) => setChosenExampleIndex(parseInt(String(value), 10)), size: "sm", triggerTextPrefix: "Example: " }));
|
|
2235
2389
|
const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && (React__namespace.createElement(mosaic.Panel, { rounded: true, isCollapsible: false },
|
|
@@ -2307,7 +2461,7 @@ function useParsedValue(value) {
|
|
|
2307
2461
|
}
|
|
2308
2462
|
|
|
2309
2463
|
function isPartialHttpRequest(maybeHttpRequest) {
|
|
2310
|
-
return (
|
|
2464
|
+
return (isObject__default["default"](maybeHttpRequest) &&
|
|
2311
2465
|
'method' in maybeHttpRequest &&
|
|
2312
2466
|
typeof maybeHttpRequest['method'] === 'string' &&
|
|
2313
2467
|
'url' in maybeHttpRequest &&
|
|
@@ -2318,7 +2472,7 @@ const SchemaAndDescription = ({ title: titleProp, schema }) => {
|
|
|
2318
2472
|
const title = titleProp !== null && titleProp !== void 0 ? titleProp : schema.title;
|
|
2319
2473
|
return (React__default["default"].createElement(mosaic.Box, { py: 2 },
|
|
2320
2474
|
title && (React__default["default"].createElement(mosaic.Flex, { alignItems: "center", p: 2 },
|
|
2321
|
-
React__default["default"].createElement(
|
|
2475
|
+
React__default["default"].createElement(mosaic.Icon, { icon: NodeTypeIconDefs[types.NodeType.Model], color: NodeTypeColors[types.NodeType.Model] }),
|
|
2322
2476
|
React__default["default"].createElement(mosaic.Box, { color: "muted", px: 2 }, title))),
|
|
2323
2477
|
React__default["default"].createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: resolveRef, schema: getOriginalObject(schema) })));
|
|
2324
2478
|
};
|
|
@@ -2333,7 +2487,7 @@ const CodeComponent = props => {
|
|
|
2333
2487
|
return React__default["default"].createElement(SchemaAndDescription, { title: title, schema: parsedValue });
|
|
2334
2488
|
}
|
|
2335
2489
|
if (http) {
|
|
2336
|
-
if (!
|
|
2490
|
+
if (!isObject__default["default"](parsedValue) || (!isPartialHttpRequest(parsedValue) && !isHttpOperation(parsedValue))) {
|
|
2337
2491
|
return null;
|
|
2338
2492
|
}
|
|
2339
2493
|
return (React__default["default"].createElement(TryIt, { httpOperation: isHttpOperation(parsedValue) ? parsedValue : parseHttpRequest(parsedValue), embeddedInMd: true }));
|
|
@@ -2372,6 +2526,15 @@ const MarkdownComponentsProvider = ({ value, children }) => {
|
|
|
2372
2526
|
return React__namespace.createElement(markdownViewer.MarkdownViewerProvider, { components: Object.assign({ code: CodeComponent }, value) }, children);
|
|
2373
2527
|
};
|
|
2374
2528
|
|
|
2529
|
+
const externalRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
2530
|
+
const ReactRouterMarkdownLink = ({ title, href, children }) => {
|
|
2531
|
+
const isExternal = href !== undefined && externalRegex.test(href);
|
|
2532
|
+
if (isExternal) {
|
|
2533
|
+
return (React__default["default"].createElement("a", { target: "_blank", rel: "noreferrer noopener", href: href, title: title }, children));
|
|
2534
|
+
}
|
|
2535
|
+
return (React__default["default"].createElement(reactRouterHashLink.HashLink, { to: href, title: title }, children));
|
|
2536
|
+
};
|
|
2537
|
+
|
|
2375
2538
|
const NODE_TYPE_TITLE_ICON = {
|
|
2376
2539
|
http_service: freeSolidSvgIcons.faCloud,
|
|
2377
2540
|
};
|
|
@@ -2563,6 +2726,14 @@ function withPersistenceBoundary(WrappedComponent) {
|
|
|
2563
2726
|
|
|
2564
2727
|
function withMosaicProvider(WrappedComponent) {
|
|
2565
2728
|
const WithMosaicProvider = (props) => {
|
|
2729
|
+
try {
|
|
2730
|
+
const mosaicContext = mosaic.useMosaicContext();
|
|
2731
|
+
if (mosaicContext === null || mosaicContext === void 0 ? void 0 : mosaicContext.providerId) {
|
|
2732
|
+
return React__default["default"].createElement(WrappedComponent, Object.assign({}, props));
|
|
2733
|
+
}
|
|
2734
|
+
}
|
|
2735
|
+
catch (_a) {
|
|
2736
|
+
}
|
|
2566
2737
|
return (React__default["default"].createElement(mosaic.Provider, { style: { height: '100%' } },
|
|
2567
2738
|
React__default["default"].createElement(WrappedComponent, Object.assign({}, props))));
|
|
2568
2739
|
};
|
|
@@ -2580,6 +2751,12 @@ const queryClient = new reactQuery.QueryClient({
|
|
|
2580
2751
|
});
|
|
2581
2752
|
function withQueryClientProvider(WrappedComponent) {
|
|
2582
2753
|
const WithQueryClientProvider = (props) => {
|
|
2754
|
+
try {
|
|
2755
|
+
reactQuery.useQueryClient();
|
|
2756
|
+
return React__default["default"].createElement(WrappedComponent, Object.assign({}, props));
|
|
2757
|
+
}
|
|
2758
|
+
catch (_a) {
|
|
2759
|
+
}
|
|
2583
2760
|
return (React__default["default"].createElement(reactQuery.QueryClientProvider, { client: queryClient },
|
|
2584
2761
|
React__default["default"].createElement(WrappedComponent, Object.assign({}, props))));
|
|
2585
2762
|
};
|
|
@@ -2587,23 +2764,15 @@ function withQueryClientProvider(WrappedComponent) {
|
|
|
2587
2764
|
return WithQueryClientProvider;
|
|
2588
2765
|
}
|
|
2589
2766
|
|
|
2590
|
-
const externalRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
2591
|
-
const ReactRouterMarkdownLink = ({ title, href, children }) => {
|
|
2592
|
-
const isExternal = href !== undefined && externalRegex.test(href);
|
|
2593
|
-
if (isExternal) {
|
|
2594
|
-
return (React__default["default"].createElement("a", { target: "_blank", rel: "noreferrer noopener", href: href, title: title }, children));
|
|
2595
|
-
}
|
|
2596
|
-
return (React__default["default"].createElement(reactRouterHashLink.HashLink, { to: href, title: title }, children));
|
|
2597
|
-
};
|
|
2598
|
-
|
|
2599
2767
|
const RouterComponent = {
|
|
2600
2768
|
history: reactRouterDom.BrowserRouter,
|
|
2601
2769
|
memory: reactRouterDom.MemoryRouter,
|
|
2602
2770
|
hash: reactRouterDom.HashRouter,
|
|
2771
|
+
static: reactRouterDom.StaticRouter,
|
|
2603
2772
|
};
|
|
2604
|
-
const useRouter = (router, basePath) => {
|
|
2773
|
+
const useRouter = (router, basePath, staticRouterPath) => {
|
|
2605
2774
|
const Router = RouterComponent[router];
|
|
2606
|
-
const routerProps = Object.assign({}, (router !== 'memory' && { basename: basePath }));
|
|
2775
|
+
const routerProps = Object.assign(Object.assign({}, (router !== 'memory' && { basename: basePath })), (router === 'static' && { location: staticRouterPath }));
|
|
2607
2776
|
return {
|
|
2608
2777
|
Router,
|
|
2609
2778
|
routerProps,
|
|
@@ -2612,9 +2781,10 @@ const useRouter = (router, basePath) => {
|
|
|
2612
2781
|
|
|
2613
2782
|
function withRouter(WrappedComponent) {
|
|
2614
2783
|
const WithRouter = (props) => {
|
|
2615
|
-
var _a, _b;
|
|
2784
|
+
var _a, _b, _c;
|
|
2616
2785
|
const basePath = (_a = props.basePath) !== null && _a !== void 0 ? _a : '/';
|
|
2617
|
-
const
|
|
2786
|
+
const staticRouterPath = (_b = props.staticRouterPath) !== null && _b !== void 0 ? _b : '';
|
|
2787
|
+
const { Router, routerProps } = useRouter((_c = props.router) !== null && _c !== void 0 ? _c : 'history', basePath, staticRouterPath);
|
|
2618
2788
|
return (React__namespace.createElement(Router, Object.assign({}, routerProps, { key: basePath }),
|
|
2619
2789
|
React__namespace.createElement(reactRouterDom.Route, { path: "/" },
|
|
2620
2790
|
React__namespace.createElement(MarkdownComponentsProvider, { value: { link: ReactRouterMarkdownLink } },
|
|
@@ -2628,28 +2798,30 @@ function useBundleRefsIntoDocument(document, options) {
|
|
|
2628
2798
|
const [bundledData, setBundledData] = React__namespace.useState(document);
|
|
2629
2799
|
const baseUrl = options === null || options === void 0 ? void 0 : options.baseUrl;
|
|
2630
2800
|
React__namespace.useEffect(() => {
|
|
2631
|
-
if (!
|
|
2801
|
+
if (!isObject__default["default"](document)) {
|
|
2632
2802
|
setBundledData(document);
|
|
2633
2803
|
return;
|
|
2634
2804
|
}
|
|
2635
|
-
let
|
|
2805
|
+
let isMounted = true;
|
|
2636
2806
|
doBundle(document, baseUrl)
|
|
2637
2807
|
.then(res => {
|
|
2638
|
-
if (
|
|
2808
|
+
if (isMounted) {
|
|
2639
2809
|
setBundledData(Object.assign({}, res));
|
|
2640
2810
|
}
|
|
2641
2811
|
})
|
|
2642
2812
|
.catch(reason => {
|
|
2643
2813
|
var _a;
|
|
2644
2814
|
if (typeof reason === 'object' && reason !== null && 'files' in reason) {
|
|
2645
|
-
|
|
2815
|
+
if (isMounted) {
|
|
2816
|
+
setBundledData(Object.assign({}, reason.files.schema));
|
|
2817
|
+
}
|
|
2646
2818
|
}
|
|
2647
2819
|
else {
|
|
2648
2820
|
console.warn(`Could bundle: ${(_a = reason === null || reason === void 0 ? void 0 : reason.message) !== null && _a !== void 0 ? _a : 'Unknown error'}`);
|
|
2649
2821
|
}
|
|
2650
2822
|
});
|
|
2651
2823
|
return () => {
|
|
2652
|
-
|
|
2824
|
+
isMounted = false;
|
|
2653
2825
|
};
|
|
2654
2826
|
}, [document, baseUrl]);
|
|
2655
2827
|
return bundledData;
|
|
@@ -2692,7 +2864,7 @@ const createElementClass = (Component, propDescriptors) => {
|
|
|
2692
2864
|
constructor() {
|
|
2693
2865
|
super();
|
|
2694
2866
|
this._props = {};
|
|
2695
|
-
Object.defineProperties(this,
|
|
2867
|
+
Object.defineProperties(this, mapValues__default["default"](propDescriptors, (_, key) => ({
|
|
2696
2868
|
get: () => {
|
|
2697
2869
|
return this._props[key];
|
|
2698
2870
|
},
|
|
@@ -2713,7 +2885,7 @@ const createElementClass = (Component, propDescriptors) => {
|
|
|
2713
2885
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
2714
2886
|
if (propDescriptors[name]) {
|
|
2715
2887
|
const newPropValue = this._safeReadAttribute(name);
|
|
2716
|
-
if (!
|
|
2888
|
+
if (!isEqual__default["default"](this._props[name], newPropValue)) {
|
|
2717
2889
|
this._props[name] = newPropValue;
|
|
2718
2890
|
this._renderComponent();
|
|
2719
2891
|
}
|
|
@@ -2779,7 +2951,7 @@ const createElementClass = (Component, propDescriptors) => {
|
|
|
2779
2951
|
}
|
|
2780
2952
|
_renderComponent() {
|
|
2781
2953
|
if (this._mountPoint) {
|
|
2782
|
-
const props =
|
|
2954
|
+
const props = mapValues__default["default"](propDescriptors, (descriptor, key) => { var _a; return (_a = this._props[key]) !== null && _a !== void 0 ? _a : descriptor.defaultValue; });
|
|
2783
2955
|
ReactDOM__namespace.render(React__namespace.createElement(Component, props), this._mountPoint);
|
|
2784
2956
|
}
|
|
2785
2957
|
}
|
|
@@ -2805,6 +2977,7 @@ exports.NonIdealState = NonIdealState;
|
|
|
2805
2977
|
exports.ParsedDocs = ParsedDocs;
|
|
2806
2978
|
exports.PersistenceContextProvider = PersistenceContextProvider;
|
|
2807
2979
|
exports.PoweredByLink = PoweredByLink;
|
|
2980
|
+
exports.ReactRouterMarkdownLink = ReactRouterMarkdownLink;
|
|
2808
2981
|
exports.SidebarLayout = SidebarLayout;
|
|
2809
2982
|
exports.Styled = Styled;
|
|
2810
2983
|
exports.TableOfContents = TableOfContents;
|
|
@@ -2815,6 +2988,7 @@ exports.createResolvedObject = createResolvedObject;
|
|
|
2815
2988
|
exports.findFirstNode = findFirstNode;
|
|
2816
2989
|
exports.isHttpOperation = isHttpOperation;
|
|
2817
2990
|
exports.isHttpService = isHttpService;
|
|
2991
|
+
exports.slugify = slugify;
|
|
2818
2992
|
exports.useBundleRefsIntoDocument = useBundleRefsIntoDocument;
|
|
2819
2993
|
exports.useParsedData = useParsedData;
|
|
2820
2994
|
exports.useParsedValue = useParsedValue;
|