@stoplight/elements-core 7.3.11 → 7.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 -1
- 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/hooks/useRouter.d.ts +7 -5
- package/index.d.ts +3 -1
- package/index.esm.js +480 -342
- package/index.js +532 -372
- package/index.mjs +480 -342
- 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');
|
|
47
|
+
var sortBy = require('lodash/sortBy.js');
|
|
48
|
+
var reactRouterDom = require('react-router-dom');
|
|
29
49
|
var reactRouterHashLink = require('react-router-hash-link');
|
|
30
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,20 +338,21 @@ 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}` })))));
|
|
352
|
+
const button = React__namespace.createElement(mosaic.Button, { pos: "sticky", size: "sm", borderColor: "light", icon: freeSolidSvgIcons.faStream, style: { top: 10 } });
|
|
310
353
|
if (minimal) {
|
|
311
|
-
return (React__namespace.createElement(mosaic.Box, { pos: "
|
|
312
|
-
React__namespace.createElement(mosaic.Popover, { renderTrigger:
|
|
354
|
+
return (React__namespace.createElement(mosaic.Box, { pos: "sticky", top: 0, right: 0, style: { top: 10 } },
|
|
355
|
+
React__namespace.createElement(mosaic.Popover, { renderTrigger: button, placement: "bottom" },
|
|
313
356
|
React__namespace.createElement(mosaic.Box, { className: className }, component))));
|
|
314
357
|
}
|
|
315
358
|
return (React__namespace.createElement(mosaic.Box, { pos: "sticky", pr: 4, pl: 16, h: "full", overflowX: "auto", overflowY: "auto", className: className, style: { top: 30 } },
|
|
@@ -324,59 +367,13 @@ const ArticleComponent = React__namespace.memo(({ data }) => {
|
|
|
324
367
|
const tree = React__namespace.useMemo(() => (typeof data === 'object' ? data : markdown.parse(data)), [data]);
|
|
325
368
|
if (tree === null)
|
|
326
369
|
return null;
|
|
327
|
-
return (React__namespace.createElement(mosaic.Flex, { className: "sl-elements-article", w: "full", pos: "relative", ref: setContainer },
|
|
370
|
+
return (React__namespace.createElement(mosaic.Flex, { className: "sl-elements-article", justifyContent: "evenly", w: "full", pos: "relative", ref: setContainer },
|
|
328
371
|
React__namespace.createElement(mosaic.Box, { className: "sl-elements-article-content", style: { width: 0 }, flex: 1 },
|
|
329
372
|
React__namespace.createElement(MarkdownViewer, { markdown: tree })),
|
|
330
373
|
React__namespace.createElement(ArticleHeadings, { tree: tree, container: container })));
|
|
331
374
|
});
|
|
332
375
|
const Article = reactErrorBoundary.withErrorBoundary(ArticleComponent, { recoverableProps: ['data'] });
|
|
333
376
|
|
|
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
377
|
const NodeTypeColors = {
|
|
381
378
|
http_operation: '#6a6acb',
|
|
382
379
|
http_service: '#e056fd',
|
|
@@ -493,10 +490,36 @@ const HttpCodeDescriptions = {
|
|
|
493
490
|
const badgeDefaultBackgroundColor = '#293742';
|
|
494
491
|
const badgeDefaultColor = '#FFFFFF';
|
|
495
492
|
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
|
|
493
|
+
const MockingContext = createNamedContext('MockingContext', { mockUrl: undefined, hideMocking: undefined });
|
|
494
|
+
const MockingProvider = ({ mockUrl, hideMocking, children }) => {
|
|
495
|
+
const info = {
|
|
496
|
+
mockUrl,
|
|
497
|
+
hideMocking: hideMocking || !mockUrl,
|
|
498
|
+
};
|
|
499
|
+
return React__namespace.createElement(MockingContext.Provider, { value: info }, children);
|
|
500
|
+
};
|
|
501
|
+
function createNamedContext(name, defaultValue) {
|
|
502
|
+
const context = React__namespace.createContext(defaultValue);
|
|
503
|
+
context.displayName = name;
|
|
504
|
+
return context;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
const chosenServerAtom = jotai.atom(undefined);
|
|
508
|
+
|
|
509
|
+
const getServersToDisplay = (originalServers, mockUrl) => {
|
|
510
|
+
const servers = originalServers
|
|
511
|
+
.map((server, i) => {
|
|
512
|
+
const fallbackDescription = originalServers.length === 1 ? 'Live Server' : `Server ${i + 1}`;
|
|
513
|
+
return Object.assign(Object.assign({}, server), { url: getServerUrlWithDefaultValues(server), description: server.description || fallbackDescription });
|
|
514
|
+
})
|
|
499
515
|
.filter(server => isProperUrl(server.url));
|
|
516
|
+
if (mockUrl) {
|
|
517
|
+
servers.push({
|
|
518
|
+
description: 'Mock Server',
|
|
519
|
+
url: mockUrl,
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
return servers;
|
|
500
523
|
};
|
|
501
524
|
const getServerUrlWithDefaultValues = (server) => {
|
|
502
525
|
var _a;
|
|
@@ -762,9 +785,42 @@ const RequestSamples = React__default["default"].memo(({ request, embeddedInMd =
|
|
|
762
785
|
" ",
|
|
763
786
|
selectedLibrary ? ` / ${selectedLibrary}` : '')) }))),
|
|
764
787
|
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
|
|
788
|
+
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
|
|
789
|
+
? undefined
|
|
790
|
+
:
|
|
791
|
+
{
|
|
792
|
+
'--fs-code': 12,
|
|
793
|
+
} }))));
|
|
766
794
|
});
|
|
767
795
|
|
|
796
|
+
function getReadableSecurityName(securityScheme, includeKey = false) {
|
|
797
|
+
let name = '';
|
|
798
|
+
switch (securityScheme.type) {
|
|
799
|
+
case 'apiKey':
|
|
800
|
+
name = 'API Key';
|
|
801
|
+
break;
|
|
802
|
+
case 'http':
|
|
803
|
+
name = `${capitalize__default["default"](securityScheme.scheme)} Auth`;
|
|
804
|
+
break;
|
|
805
|
+
case 'oauth2':
|
|
806
|
+
name = 'OAuth 2.0';
|
|
807
|
+
break;
|
|
808
|
+
case 'openIdConnect':
|
|
809
|
+
name = 'OpenID Connect';
|
|
810
|
+
break;
|
|
811
|
+
case 'mutualTLS':
|
|
812
|
+
name = 'Mutual TLS';
|
|
813
|
+
break;
|
|
814
|
+
}
|
|
815
|
+
return includeKey ? `${name} (${securityScheme.key})` : name;
|
|
816
|
+
}
|
|
817
|
+
const isOAuth2ImplicitFlow = (maybeFlow) => isObject__default["default"](maybeFlow) && 'authorizationUrl' in maybeFlow && !('tokenUrl' in maybeFlow);
|
|
818
|
+
const isOauth2AuthorizationCodeFlow = (maybeFlow) => isObject__default["default"](maybeFlow) && 'authorizationUrl' in maybeFlow && 'tokenUrl' in maybeFlow;
|
|
819
|
+
const isOauth2ClientCredentialsOrPasswordFlow = (maybeFlow) => isObject__default["default"](maybeFlow) && !('authorizationUrl' in maybeFlow) && 'tokenUrl' in maybeFlow;
|
|
820
|
+
function shouldIncludeKey(schemes, type) {
|
|
821
|
+
return filter__default["default"](schemes, { type }).length > 1;
|
|
822
|
+
}
|
|
823
|
+
|
|
768
824
|
const useUniqueId = (prefix = 'id_') => React__namespace.useRef(`${prefix}${nanoid.nanoid(8)}`).current;
|
|
769
825
|
|
|
770
826
|
const AuthTokenInput = ({ type, name, value, onChange }) => {
|
|
@@ -837,7 +893,7 @@ const OAuth2Auth = ({ value, onChange }) => {
|
|
|
837
893
|
|
|
838
894
|
const TryItAuth = ({ operationSecurityScheme: operationAuth, onChange, value }) => {
|
|
839
895
|
var _a;
|
|
840
|
-
const operationSecurityArray =
|
|
896
|
+
const operationSecurityArray = flatten__default["default"](operationAuth);
|
|
841
897
|
const filteredSecurityItems = operationSecurityArray.filter(scheme => securitySchemeKeys.includes(scheme === null || scheme === void 0 ? void 0 : scheme.type));
|
|
842
898
|
const securityScheme = value ? value.scheme : filteredSecurityItems[0];
|
|
843
899
|
const menuName = securityScheme ? getReadableSecurityName(securityScheme) : 'Security Scheme';
|
|
@@ -899,15 +955,22 @@ const SecuritySchemeComponent = (_a) => {
|
|
|
899
955
|
};
|
|
900
956
|
const securitySchemeKeys = ['apiKey', 'http', 'oauth2', 'openIdConnect'];
|
|
901
957
|
|
|
902
|
-
const caseInsensitivelyEquals =
|
|
958
|
+
const caseInsensitivelyEquals = curry__default["default"]((a, b) => a.toUpperCase() === b.toUpperCase());
|
|
959
|
+
function slugify(name) {
|
|
960
|
+
return name
|
|
961
|
+
.replace(/\/|{|}|\s/g, '-')
|
|
962
|
+
.replace(/-{2,}/, '-')
|
|
963
|
+
.replace(/^-/, '')
|
|
964
|
+
.replace(/-$/, '');
|
|
965
|
+
}
|
|
903
966
|
|
|
904
|
-
const isApiKeySecurityScheme = (maybeIApiKey) =>
|
|
905
|
-
const isOAuth2SecurityScheme = (maybeIOAuth2) =>
|
|
906
|
-
const isBasicSecurityScheme = (maybeIBasic) =>
|
|
907
|
-
const isBearerSecurityScheme = (maybeIBearer) =>
|
|
908
|
-
const isDigestSecurityScheme = (maybeIBearer) =>
|
|
967
|
+
const isApiKeySecurityScheme = (maybeIApiKey) => isObject__default["default"](maybeIApiKey) && maybeIApiKey.type === 'apiKey';
|
|
968
|
+
const isOAuth2SecurityScheme = (maybeIOAuth2) => isObject__default["default"](maybeIOAuth2) && maybeIOAuth2.type === 'oauth2';
|
|
969
|
+
const isBasicSecurityScheme = (maybeIBasic) => isObject__default["default"](maybeIBasic) && maybeIBasic.type === 'http' && maybeIBasic.scheme === 'basic';
|
|
970
|
+
const isBearerSecurityScheme = (maybeIBearer) => isObject__default["default"](maybeIBearer) && maybeIBearer.type === 'http' && maybeIBearer.scheme === 'bearer';
|
|
971
|
+
const isDigestSecurityScheme = (maybeIBearer) => isObject__default["default"](maybeIBearer) && maybeIBearer.type === 'http' && maybeIBearer.scheme === 'digest';
|
|
909
972
|
function filterOutAuthorizationParams(queryParams, securitySchemes = []) {
|
|
910
|
-
const flattenedSecuritySchemes =
|
|
973
|
+
const flattenedSecuritySchemes = flatten__default["default"](securitySchemes);
|
|
911
974
|
const securitySchemeNames = getSecuritySchemeNames(flattenedSecuritySchemes);
|
|
912
975
|
return queryParams.filter(queryParam => !securitySchemeNames.some(caseInsensitivelyEquals(queryParam.name)));
|
|
913
976
|
}
|
|
@@ -978,7 +1041,7 @@ const booleanOptions = [
|
|
|
978
1041
|
{ label: 'True', value: 'true' },
|
|
979
1042
|
];
|
|
980
1043
|
function enumOptions(enumValues, required) {
|
|
981
|
-
const options =
|
|
1044
|
+
const options = map__default["default"](enumValues, v => ({ value: Number.isNaN(Number(v)) ? String(v) : Number(v) }));
|
|
982
1045
|
return required ? options : [{ label: 'Not Set', value: '' }, ...options];
|
|
983
1046
|
}
|
|
984
1047
|
function parameterOptions(parameter) {
|
|
@@ -1010,40 +1073,41 @@ function exampleValue(example) {
|
|
|
1010
1073
|
}
|
|
1011
1074
|
function getPlaceholderForParameter(parameter) {
|
|
1012
1075
|
var _a, _b;
|
|
1013
|
-
const parameterValue = getValueForParameter(parameter);
|
|
1076
|
+
const { value: parameterValue, isDefault } = getValueForParameter(parameter);
|
|
1014
1077
|
if (parameterValue)
|
|
1015
|
-
return
|
|
1016
|
-
return
|
|
1078
|
+
return `${isDefault ? 'defaults to' : 'example'}: ${parameterValue}`;
|
|
1079
|
+
return String((_b = (_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : '');
|
|
1017
1080
|
}
|
|
1018
1081
|
function retrieveDefaultFromSchema(parameter) {
|
|
1019
1082
|
var _a;
|
|
1020
1083
|
const defaultValue = (_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.default;
|
|
1021
|
-
return
|
|
1084
|
+
return isObject__default["default"](defaultValue) ? json.safeStringify(defaultValue) : defaultValue;
|
|
1022
1085
|
}
|
|
1023
1086
|
const getValueForParameter = (parameter) => {
|
|
1024
1087
|
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
1088
|
const defaultValue = retrieveDefaultFromSchema(parameter);
|
|
1029
|
-
if (defaultValue)
|
|
1030
|
-
return String(defaultValue);
|
|
1089
|
+
if (typeof defaultValue !== 'undefined') {
|
|
1090
|
+
return { value: String(defaultValue), isDefault: true };
|
|
1091
|
+
}
|
|
1092
|
+
const examples = (_a = parameter.examples) !== null && _a !== void 0 ? _a : [];
|
|
1093
|
+
if (examples.length > 0) {
|
|
1094
|
+
return { value: exampleValue(examples[0]) };
|
|
1095
|
+
}
|
|
1031
1096
|
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
|
-
|
|
1097
|
+
if (enums.length > 0) {
|
|
1098
|
+
return { value: String(enums[0]) };
|
|
1099
|
+
}
|
|
1100
|
+
return { value: '' };
|
|
1035
1101
|
};
|
|
1036
1102
|
const getInitialValueForParameter = (parameter) => {
|
|
1037
1103
|
const isRequired = !!parameter.required;
|
|
1038
1104
|
if (!isRequired)
|
|
1039
1105
|
return '';
|
|
1040
|
-
return getValueForParameter(parameter);
|
|
1106
|
+
return getValueForParameter(parameter).value;
|
|
1041
1107
|
};
|
|
1042
1108
|
const initialParameterValues = params => {
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
.mapValues(param => getInitialValueForParameter(param))
|
|
1046
|
-
.value();
|
|
1109
|
+
const paramsByName = keyBy__default["default"](params, (param) => param.name);
|
|
1110
|
+
return mapValues__default["default"](paramsByName, param => getInitialValueForParameter(param));
|
|
1047
1111
|
};
|
|
1048
1112
|
function mapSchemaPropertiesToParameters(properties, required) {
|
|
1049
1113
|
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 +1149,7 @@ const FormDataBody = ({ specification, values, onChangeValues }) => {
|
|
|
1085
1149
|
if (supportsFileUpload) {
|
|
1086
1150
|
return (React__namespace.createElement(FileUploadParameterEditor, { key: parameter.name, parameter: parameter, value: value instanceof File ? value : undefined, onChange: newValue => newValue
|
|
1087
1151
|
? onChangeValues(Object.assign(Object.assign({}, values), { [parameter.name]: newValue }))
|
|
1088
|
-
: onChangeValues(
|
|
1152
|
+
: onChangeValues(omit__default["default"](values, parameter.name)) }));
|
|
1089
1153
|
}
|
|
1090
1154
|
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
1155
|
}))));
|
|
@@ -1119,7 +1183,7 @@ function createRequestBody(mediaTypeContent, bodyParameterValues) {
|
|
|
1119
1183
|
});
|
|
1120
1184
|
}
|
|
1121
1185
|
const createUrlEncodedRequestBody = ({ bodyParameterValues = {} }) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
1122
|
-
const filteredValues =
|
|
1186
|
+
const filteredValues = pickBy__default["default"](bodyParameterValues, isString__default["default"]);
|
|
1123
1187
|
return new URLSearchParams(filteredValues);
|
|
1124
1188
|
});
|
|
1125
1189
|
const createMultipartRequestBody = ({ mediaTypeContent, bodyParameterValues = {} }) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1184,7 +1248,9 @@ const RequestBody = ({ examples, requestBody, onChange }) => {
|
|
|
1184
1248
|
return (React__namespace.createElement(mosaic.Panel, { defaultIsOpen: true },
|
|
1185
1249
|
React__namespace.createElement(mosaic.Panel.Titlebar, { rightComponent: examples.length > 1 && React__namespace.createElement(ExampleMenu, { examples: examples, requestBody: requestBody, onChange: onChange }) }, "Body"),
|
|
1186
1250
|
React__namespace.createElement(mosaic.Panel.Content, { className: "TextRequestBody" },
|
|
1187
|
-
React__namespace.createElement(mosaicCodeEditor.CodeEditor, { onChange: onChange, language: "json", value: requestBody, showLineNumbers: true, padding: 0
|
|
1251
|
+
React__namespace.createElement(mosaicCodeEditor.CodeEditor, { onChange: onChange, language: "json", value: requestBody, showLineNumbers: true, padding: 0, style: {
|
|
1252
|
+
fontSize: 12,
|
|
1253
|
+
} }))));
|
|
1188
1254
|
};
|
|
1189
1255
|
function ExampleMenu({ examples, requestBody, onChange }) {
|
|
1190
1256
|
const handleClick = React__namespace.useCallback((example) => {
|
|
@@ -1269,7 +1335,6 @@ const generateExamplesFromJsonSchema = (schema) => {
|
|
|
1269
1335
|
: [{ label: 'default', data: '' }];
|
|
1270
1336
|
}
|
|
1271
1337
|
catch (e) {
|
|
1272
|
-
console.error(e);
|
|
1273
1338
|
return [{ label: '', data: `Example cannot be created for this schema\n${e}` }];
|
|
1274
1339
|
}
|
|
1275
1340
|
};
|
|
@@ -1443,8 +1508,8 @@ const formatMultiValueHeader = (...keyValuePairs) => {
|
|
|
1443
1508
|
.join(', ');
|
|
1444
1509
|
};
|
|
1445
1510
|
|
|
1446
|
-
function getMockData(url, httpOperation, {
|
|
1447
|
-
return
|
|
1511
|
+
function getMockData(url, httpOperation, { code, dynamic, example }) {
|
|
1512
|
+
return url ? { url, header: buildPreferHeader({ code, dynamic, example }, httpOperation) } : undefined;
|
|
1448
1513
|
}
|
|
1449
1514
|
function buildPreferHeader({ code, example, dynamic }, httpOperation) {
|
|
1450
1515
|
if (!code) {
|
|
@@ -1452,7 +1517,7 @@ function buildPreferHeader({ code, example, dynamic }, httpOperation) {
|
|
|
1452
1517
|
}
|
|
1453
1518
|
const isCodeSupported = supportsResponseCode(httpOperation, code);
|
|
1454
1519
|
const isExampleSupported = isCodeSupported && supportsExample(httpOperation, code, example);
|
|
1455
|
-
const args =
|
|
1520
|
+
const args = compact__default["default"]([
|
|
1456
1521
|
code && isCodeSupported ? ['code', code] : undefined,
|
|
1457
1522
|
dynamic ? ['dynamic', String(dynamic)] : undefined,
|
|
1458
1523
|
example && isExampleSupported ? ['example', example] : undefined,
|
|
@@ -1473,32 +1538,23 @@ function supportsExample(httpOperation, code, exampleKey) {
|
|
|
1473
1538
|
const response = (_a = httpOperation.responses) === null || _a === void 0 ? void 0 : _a.find(response => response.code === code);
|
|
1474
1539
|
if (!response)
|
|
1475
1540
|
return false;
|
|
1476
|
-
const exampleKeys =
|
|
1541
|
+
const exampleKeys = uniq__default["default"]((_b = response.contents) === null || _b === void 0 ? void 0 : _b.flatMap(c => c.examples || []).map(example => example.key));
|
|
1477
1542
|
return exampleKeys.includes(exampleKey);
|
|
1478
1543
|
}
|
|
1479
1544
|
|
|
1480
|
-
const MockingButton = ({ operation, options: {
|
|
1481
|
-
const toggleEnabled = React__namespace.useCallback(() => {
|
|
1482
|
-
onOptionsChange({ isEnabled: !isEnabled });
|
|
1483
|
-
}, [isEnabled, onOptionsChange]);
|
|
1545
|
+
const MockingButton = ({ operation, options: { code, example, dynamic }, onOptionsChange, }) => {
|
|
1484
1546
|
const operationResponses = operation.responses;
|
|
1485
1547
|
const setMockingOptions = React__namespace.useCallback(({ code, example, dynamic }) => {
|
|
1486
|
-
onOptionsChange({
|
|
1487
|
-
}, [
|
|
1548
|
+
onOptionsChange({ code, example, dynamic });
|
|
1549
|
+
}, [onOptionsChange]);
|
|
1488
1550
|
const menuItems = React__namespace.useMemo(() => {
|
|
1489
1551
|
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
|
-
];
|
|
1552
|
+
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
1553
|
function generateOperationResponseMenu(operationResponse) {
|
|
1498
1554
|
var _a;
|
|
1499
1555
|
const menuId = `response-${operationResponse.code}`;
|
|
1500
1556
|
const isActive = operationResponse.code === code;
|
|
1501
|
-
const exampleKeys =
|
|
1557
|
+
const exampleKeys = uniq__default["default"]((_a = operationResponse.contents) === null || _a === void 0 ? void 0 : _a.flatMap(c => c.examples || []).map(example => example.key));
|
|
1502
1558
|
const exampleChildren = exampleKeys === null || exampleKeys === void 0 ? void 0 : exampleKeys.map(exampleKey => ({
|
|
1503
1559
|
id: `${menuId}-example-${exampleKey}`,
|
|
1504
1560
|
title: exampleKey,
|
|
@@ -1527,7 +1583,6 @@ const MockingButton = ({ operation, options: { isEnabled, code, example, dynamic
|
|
|
1527
1583
|
];
|
|
1528
1584
|
const menuItem = {
|
|
1529
1585
|
id: menuId,
|
|
1530
|
-
isDisabled: !isEnabled,
|
|
1531
1586
|
isChecked: isActive,
|
|
1532
1587
|
title: operationResponse.code,
|
|
1533
1588
|
onPress: () => {
|
|
@@ -1541,13 +1596,13 @@ const MockingButton = ({ operation, options: { isEnabled, code, example, dynamic
|
|
|
1541
1596
|
return menuItem;
|
|
1542
1597
|
}
|
|
1543
1598
|
return items;
|
|
1544
|
-
}, [code, dynamic, example,
|
|
1599
|
+
}, [code, dynamic, example, operationResponses, setMockingOptions]);
|
|
1545
1600
|
return (React__namespace.createElement(mosaic.Box, null,
|
|
1546
|
-
React__namespace.createElement(mosaic.Menu, { "aria-label": "
|
|
1601
|
+
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
1602
|
};
|
|
1548
1603
|
|
|
1549
|
-
const
|
|
1550
|
-
const useMockingOptions = () => jotai.useAtom(
|
|
1604
|
+
const mockingOptionsAtom = jotai.atom({});
|
|
1605
|
+
const useMockingOptions = () => jotai.useAtom(mockingOptionsAtom);
|
|
1551
1606
|
|
|
1552
1607
|
const OperationParameters = ({ parameters, values, onChangeValue, validate, }) => {
|
|
1553
1608
|
return (React__namespace.createElement(mosaic.Panel, { defaultIsOpen: true },
|
|
@@ -1586,10 +1641,10 @@ const useRequestParameters = (httpOperation) => {
|
|
|
1586
1641
|
function extractAllParameters(httpOperation) {
|
|
1587
1642
|
var _a, _b, _c, _d, _e, _f;
|
|
1588
1643
|
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
|
|
1644
|
+
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']);
|
|
1645
|
+
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);
|
|
1646
|
+
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);
|
|
1647
|
+
return uniqBy__default["default"]([...pathParameters, ...queryParameters, ...headerParameters], p => p.name);
|
|
1593
1648
|
}
|
|
1594
1649
|
|
|
1595
1650
|
function getHttpCodeColor(code) {
|
|
@@ -1645,19 +1700,19 @@ const TryItResponse = ({ response }) => {
|
|
|
1645
1700
|
? parseBody(response.bodyText, responseType)
|
|
1646
1701
|
: response.bodyText })) : response.blob && responseType === 'image' ? (React__namespace.createElement(mosaic.Flex, { justifyContent: "center" },
|
|
1647
1702
|
React__namespace.createElement(mosaic.Image, { src: URL.createObjectURL(response.blob), alt: "response image" }))) : (React__namespace.createElement("p", null,
|
|
1648
|
-
React__namespace.createElement(
|
|
1703
|
+
React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, icon: freeSolidSvgIcons.faExclamationCircle, mr: 2 }),
|
|
1649
1704
|
"No supported response body returned"))))));
|
|
1650
1705
|
};
|
|
1651
1706
|
const ResponseMenu = ({ types, type, onChange }) => {
|
|
1652
1707
|
const menuItems = React__namespace.useMemo(() => {
|
|
1653
1708
|
const items = types.map(type => ({
|
|
1654
1709
|
id: type,
|
|
1655
|
-
title:
|
|
1710
|
+
title: capitalize__default["default"](type),
|
|
1656
1711
|
onPress: () => onChange(type),
|
|
1657
1712
|
}));
|
|
1658
1713
|
return items;
|
|
1659
1714
|
}, [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 },
|
|
1715
|
+
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
1716
|
};
|
|
1662
1717
|
const ResponseError = ({ state: { error } }) => (React__namespace.createElement(mosaic.Panel, { defaultIsOpen: true },
|
|
1663
1718
|
React__namespace.createElement(mosaic.Panel.Titlebar, null, "Error"),
|
|
@@ -1676,7 +1731,32 @@ class NetworkError extends Error {
|
|
|
1676
1731
|
}
|
|
1677
1732
|
const isNetworkError = (error) => error instanceof NetworkError;
|
|
1678
1733
|
|
|
1679
|
-
const
|
|
1734
|
+
const ServersDropdown = ({ servers }) => {
|
|
1735
|
+
const [chosenServer, setChosenServer] = jotai.useAtom(chosenServerAtom);
|
|
1736
|
+
const serverItems = [
|
|
1737
|
+
{
|
|
1738
|
+
type: 'option_group',
|
|
1739
|
+
title: 'Servers',
|
|
1740
|
+
value: (chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.url) || '',
|
|
1741
|
+
onChange: url => {
|
|
1742
|
+
const server = servers.find(server => server.url === url);
|
|
1743
|
+
setChosenServer(server);
|
|
1744
|
+
},
|
|
1745
|
+
children: [
|
|
1746
|
+
...servers.map((server, i) => ({
|
|
1747
|
+
id: server.url,
|
|
1748
|
+
title: server.name || server.description,
|
|
1749
|
+
description: server.name ? server.description || server.url : server.description ? server.url : undefined,
|
|
1750
|
+
value: server.url,
|
|
1751
|
+
})),
|
|
1752
|
+
],
|
|
1753
|
+
},
|
|
1754
|
+
];
|
|
1755
|
+
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')) }));
|
|
1756
|
+
};
|
|
1757
|
+
ServersDropdown.displayName = 'ServersDropdown';
|
|
1758
|
+
|
|
1759
|
+
const defaultServers = [];
|
|
1680
1760
|
const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embeddedInMd = false, tryItCredentialsPolicy, corsProxy, }) => {
|
|
1681
1761
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1682
1762
|
const isDark = mosaic.useThemeIsDark();
|
|
@@ -1690,27 +1770,41 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
|
|
|
1690
1770
|
const [bodyParameterValues, setBodyParameterValues, formDataState] = useBodyParameterState(mediaTypeContent);
|
|
1691
1771
|
const [textRequestBody, setTextRequestBody] = useTextRequestBodyState(mediaTypeContent);
|
|
1692
1772
|
const [operationAuthValue, setOperationAuthValue] = usePersistedSecuritySchemeWithValues();
|
|
1693
|
-
const servers =
|
|
1773
|
+
const servers = React__namespace.useMemo(() => {
|
|
1774
|
+
const toDisplay = getServersToDisplay(httpOperation.servers || defaultServers, mockUrl);
|
|
1775
|
+
return toDisplay;
|
|
1776
|
+
}, [httpOperation.servers, mockUrl]);
|
|
1777
|
+
const firstServer = servers[0] || null;
|
|
1694
1778
|
const [chosenServer, setChosenServer] = jotai.useAtom(chosenServerAtom);
|
|
1779
|
+
const isMockingEnabled = mockUrl && (chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.url) === mockUrl;
|
|
1695
1780
|
const hasRequiredButEmptyParameters = allParameters.some(parameter => parameter.required && !parameterValuesWithDefaults[parameter.name]);
|
|
1696
1781
|
React__namespace.useEffect(() => {
|
|
1697
|
-
|
|
1698
|
-
|
|
1782
|
+
const currentUrl = chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.url;
|
|
1783
|
+
const exists = currentUrl && servers.find(s => s.url === currentUrl);
|
|
1784
|
+
if (!exists) {
|
|
1785
|
+
setChosenServer(firstServer);
|
|
1699
1786
|
}
|
|
1700
|
-
|
|
1787
|
+
else if (exists !== chosenServer) {
|
|
1788
|
+
setChosenServer(exists);
|
|
1789
|
+
}
|
|
1790
|
+
}, [servers, firstServer, chosenServer, setChosenServer]);
|
|
1701
1791
|
React__namespace.useEffect(() => {
|
|
1702
|
-
let
|
|
1792
|
+
let isMounted = true;
|
|
1703
1793
|
if (onRequestChange || embeddedInMd) {
|
|
1704
|
-
buildHarRequest(Object.assign(Object.assign({ mediaTypeContent, parameterValues: parameterValuesWithDefaults, httpOperation, bodyInput: formDataState.isFormDataBody ? bodyParameterValues : textRequestBody, auth: operationAuthValue }, (
|
|
1794
|
+
buildHarRequest(Object.assign(Object.assign({ mediaTypeContent, parameterValues: parameterValuesWithDefaults, httpOperation, bodyInput: formDataState.isFormDataBody ? bodyParameterValues : textRequestBody, auth: operationAuthValue }, (isMockingEnabled && { mockData: getMockData(mockUrl, httpOperation, mockingOptions) })), { chosenServer,
|
|
1705
1795
|
corsProxy })).then(request => {
|
|
1706
|
-
if (
|
|
1707
|
-
onRequestChange
|
|
1708
|
-
|
|
1709
|
-
|
|
1796
|
+
if (isMounted) {
|
|
1797
|
+
if (onRequestChange) {
|
|
1798
|
+
onRequestChange(request);
|
|
1799
|
+
}
|
|
1800
|
+
if (embeddedInMd) {
|
|
1801
|
+
setRequestData(request);
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1710
1804
|
});
|
|
1711
1805
|
}
|
|
1712
1806
|
return () => {
|
|
1713
|
-
|
|
1807
|
+
isMounted = false;
|
|
1714
1808
|
};
|
|
1715
1809
|
}, [
|
|
1716
1810
|
httpOperation,
|
|
@@ -1724,13 +1818,13 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
|
|
|
1724
1818
|
corsProxy,
|
|
1725
1819
|
embeddedInMd,
|
|
1726
1820
|
]);
|
|
1727
|
-
const
|
|
1821
|
+
const handleSendRequest = () => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
1728
1822
|
setValidateParameters(true);
|
|
1729
1823
|
if (hasRequiredButEmptyParameters)
|
|
1730
1824
|
return;
|
|
1731
1825
|
try {
|
|
1732
1826
|
setLoading(true);
|
|
1733
|
-
const mockData = getMockData(mockUrl, httpOperation, mockingOptions);
|
|
1827
|
+
const mockData = isMockingEnabled ? getMockData(mockUrl, httpOperation, mockingOptions) : undefined;
|
|
1734
1828
|
const request = yield buildFetchRequest({
|
|
1735
1829
|
parameterValues: parameterValuesWithDefaults,
|
|
1736
1830
|
httpOperation,
|
|
@@ -1767,29 +1861,32 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
|
|
|
1767
1861
|
setLoading(false);
|
|
1768
1862
|
}
|
|
1769
1863
|
});
|
|
1770
|
-
const
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1864
|
+
const isOnlySendButton = !((_d = httpOperation.security) === null || _d === void 0 ? void 0 : _d.length) && !allParameters.length && !formDataState.isFormDataBody && !mediaTypeContent;
|
|
1865
|
+
const tryItPanelContents = (React__namespace.createElement(React__namespace.Fragment, null,
|
|
1866
|
+
((_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,
|
|
1867
|
+
allParameters.length > 0 && (React__namespace.createElement(OperationParameters, { parameters: allParameters, values: parameterValuesWithDefaults, onChangeValue: updateParameterValue, validate: validateParameters })),
|
|
1868
|
+
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,
|
|
1869
|
+
React__namespace.createElement(mosaic.Panel.Content, { className: "SendButtonHolder", mt: 4, pt: !isOnlySendButton && !embeddedInMd ? 0 : undefined },
|
|
1870
|
+
React__namespace.createElement(mosaic.HStack, { alignItems: "center", spacing: 2 },
|
|
1871
|
+
React__namespace.createElement(mosaic.Button, { appearance: "primary", loading: loading, disabled: loading, onPress: handleSendRequest, size: "sm" }, "Send API Request"),
|
|
1872
|
+
servers.length > 1 && React__namespace.createElement(ServersDropdown, { servers: servers }),
|
|
1873
|
+
isMockingEnabled && (React__namespace.createElement(MockingButton, { options: mockingOptions, onOptionsChange: setMockingOptions, operation: httpOperation }))),
|
|
1874
|
+
validateParameters && hasRequiredButEmptyParameters && (React__namespace.createElement(mosaic.Box, { mt: 4, color: "danger-light", fontSize: "sm" },
|
|
1875
|
+
React__namespace.createElement(mosaic.Icon, { icon: freeSolidSvgIcons.faExclamationTriangle, className: "sl-mr-1" }),
|
|
1876
|
+
"You didn't provide all of the required parameters!")))));
|
|
1877
|
+
let tryItPanelElem;
|
|
1878
|
+
if (embeddedInMd) {
|
|
1879
|
+
tryItPanelElem = (React__namespace.createElement(mosaic.Panel, { isCollapsible: false, p: 0, className: "TryItPanel" },
|
|
1880
|
+
React__namespace.createElement(mosaic.Panel.Titlebar, { bg: "canvas-300" },
|
|
1881
|
+
React__namespace.createElement(mosaic.Box, { fontWeight: "bold", color: !isDark ? HttpMethodColors[httpOperation.method] : undefined }, httpOperation.method.toUpperCase()),
|
|
1882
|
+
React__namespace.createElement(mosaic.Box, { fontWeight: "medium", ml: 2, textOverflow: "truncate", overflowX: "hidden" }, `${(chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.url) || ''}${httpOperation.path}`)),
|
|
1883
|
+
tryItPanelContents));
|
|
1884
|
+
}
|
|
1885
|
+
else {
|
|
1886
|
+
tryItPanelElem = (React__namespace.createElement(mosaic.Box, { className: "TryItPanel", bg: "canvas-100", rounded: "lg" }, tryItPanelContents));
|
|
1887
|
+
}
|
|
1777
1888
|
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!")))),
|
|
1889
|
+
tryItPanelElem,
|
|
1793
1890
|
requestData && embeddedInMd && React__namespace.createElement(RequestSamples, { request: requestData, embeddedInMd: true }),
|
|
1794
1891
|
response && !('error' in response) && React__namespace.createElement(TryItResponse, { response: response }),
|
|
1795
1892
|
response && 'error' in response && React__namespace.createElement(ResponseError, { state: response })));
|
|
@@ -1826,7 +1923,9 @@ const ResponseExamples = ({ httpOperation, responseMediaType, responseStatusCode
|
|
|
1826
1923
|
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
1924
|
return (React__default["default"].createElement(mosaic.Panel, { rounded: true, isCollapsible: false },
|
|
1828
1925
|
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: "
|
|
1926
|
+
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: {
|
|
1927
|
+
'--fs-code': 12,
|
|
1928
|
+
} })) : (React__default["default"].createElement(LoadMore, { loading: loading, onClick: handleLoadMore })))));
|
|
1830
1929
|
};
|
|
1831
1930
|
|
|
1832
1931
|
const TryItWithRequestSamples = (_a) => {
|
|
@@ -1840,21 +1939,16 @@ const TryItWithRequestSamples = (_a) => {
|
|
|
1840
1939
|
React__namespace.createElement(ResponseExamples, Object.assign({}, props))));
|
|
1841
1940
|
};
|
|
1842
1941
|
|
|
1843
|
-
const TwoColumnLayout = ({ header, right, left, className }) => (React__default["default"].createElement(mosaic.
|
|
1942
|
+
const TwoColumnLayout = ({ header, right, left, className }) => (React__default["default"].createElement(mosaic.VStack, { w: "full", className: className, spacing: 8 },
|
|
1844
1943
|
header,
|
|
1845
|
-
React__default["default"].createElement(mosaic.Flex,
|
|
1846
|
-
React__default["default"].createElement(mosaic.Box, {
|
|
1944
|
+
React__default["default"].createElement(mosaic.Flex, null,
|
|
1945
|
+
React__default["default"].createElement(mosaic.Box, { w: 0, flex: 1 }, left),
|
|
1847
1946
|
right && (React__default["default"].createElement(mosaic.Box, { ml: 16, pos: "relative", w: "2/5", style: { maxWidth: 500 } }, right)))));
|
|
1848
1947
|
|
|
1849
1948
|
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: {
|
|
1949
|
+
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.`));
|
|
1950
|
+
const VersionBadge = ({ value, backgroundColor }) => (React__default["default"].createElement(mosaic.Badge, { appearance: "solid", size: "sm", border: 0, style: {
|
|
1856
1951
|
backgroundColor: backgroundColor || badgeDefaultBackgroundColor,
|
|
1857
|
-
border: 'none',
|
|
1858
1952
|
color: badgeDefaultColor,
|
|
1859
1953
|
} }, enhanceVersionString(value)));
|
|
1860
1954
|
const enhanceVersionString = (version) => {
|
|
@@ -1863,32 +1957,112 @@ const enhanceVersionString = (version) => {
|
|
|
1863
1957
|
return `v${version}`;
|
|
1864
1958
|
};
|
|
1865
1959
|
|
|
1866
|
-
const
|
|
1867
|
-
|
|
1868
|
-
|
|
1960
|
+
const oauthFlowNames = {
|
|
1961
|
+
implicit: 'Implicit',
|
|
1962
|
+
authorizationCode: 'Authorization Code',
|
|
1963
|
+
clientCredentials: 'Client Credentials',
|
|
1964
|
+
password: 'Password',
|
|
1965
|
+
};
|
|
1966
|
+
function getDefaultDescription(scheme) {
|
|
1967
|
+
switch (scheme.type) {
|
|
1968
|
+
case 'apiKey':
|
|
1969
|
+
return getApiKeyDescription(scheme.in, scheme.name);
|
|
1970
|
+
case 'http':
|
|
1971
|
+
switch (scheme.scheme) {
|
|
1972
|
+
case 'basic':
|
|
1973
|
+
return getBasicAuthDescription();
|
|
1974
|
+
case 'bearer':
|
|
1975
|
+
return getBearerAuthDescription();
|
|
1976
|
+
case 'digest':
|
|
1977
|
+
return getDigestAuthDescription();
|
|
1978
|
+
}
|
|
1979
|
+
case 'oauth2':
|
|
1980
|
+
return getOAuthDescription(scheme);
|
|
1981
|
+
}
|
|
1982
|
+
return '';
|
|
1983
|
+
}
|
|
1984
|
+
function getApiKeyDescription(inProperty, name) {
|
|
1985
|
+
return `An API key is a token that you provide when making API calls. Include the token in a ${inProperty} parameter called \`${name}\`.
|
|
1986
|
+
|
|
1987
|
+
Example: ${inProperty === 'query' ? `\`?${name}=123\`` : `\`${name}: 123\``}`;
|
|
1988
|
+
}
|
|
1989
|
+
function getBasicAuthDescription() {
|
|
1990
|
+
return `Basic authentication is a simple authentication scheme built into the HTTP protocol.
|
|
1991
|
+
To use it, send your HTTP requests with an Authorization header that contains the word Basic
|
|
1992
|
+
followed by a space and a base64-encoded string \`username:password\`.
|
|
1993
|
+
|
|
1994
|
+
Example: \`Authorization: Basic ZGVtbzpwQDU1dzByZA==\``;
|
|
1995
|
+
}
|
|
1996
|
+
function getBearerAuthDescription() {
|
|
1997
|
+
return `Provide your bearer token in the Authorization header when making requests to protected resources.
|
|
1998
|
+
|
|
1999
|
+
Example: \`Authorization: Bearer 123\``;
|
|
2000
|
+
}
|
|
2001
|
+
function getDigestAuthDescription() {
|
|
2002
|
+
return `Provide your encrypted digest scheme data in the Authorization header when making requests to protected resources.
|
|
2003
|
+
|
|
2004
|
+
Example: \`Authorization: Digest username=guest, realm="test", nonce="2", uri="/uri", response="123"\``;
|
|
2005
|
+
}
|
|
2006
|
+
function getOAuthDescription(scheme) {
|
|
2007
|
+
const flows = keys__default["default"](scheme.flows);
|
|
2008
|
+
return flows.map(flow => getOAuthFlowDescription(oauthFlowNames[flow], scheme.flows[flow])).join('\n\n');
|
|
2009
|
+
}
|
|
2010
|
+
function getOAuthFlowDescription(title, flow) {
|
|
2011
|
+
let description = `**${title} OAuth Flow**`;
|
|
2012
|
+
description +=
|
|
2013
|
+
isOAuth2ImplicitFlow(flow) || isOauth2AuthorizationCodeFlow(flow)
|
|
2014
|
+
? `\n\nAuthorize URL: ${flow.authorizationUrl}`
|
|
2015
|
+
: '';
|
|
2016
|
+
description +=
|
|
2017
|
+
isOauth2AuthorizationCodeFlow(flow) || isOauth2ClientCredentialsOrPasswordFlow(flow)
|
|
2018
|
+
? `\n\nToken URL: ${flow.tokenUrl}`
|
|
2019
|
+
: '';
|
|
2020
|
+
description += flow.refreshUrl ? `\n\nRefresh URL: ${flow.refreshUrl}` : '';
|
|
2021
|
+
const scopes = entries__default["default"](flow.scopes);
|
|
2022
|
+
if (scopes.length) {
|
|
2023
|
+
description += `\n\nScopes:
|
|
2024
|
+
${scopes.map(([key, value]) => `- \`${key}\` - ${value}`).join('\n')}`;
|
|
2025
|
+
}
|
|
2026
|
+
return description;
|
|
2027
|
+
}
|
|
2028
|
+
|
|
2029
|
+
const SectionTitle = ({ title, id, size = 2, children }) => {
|
|
2030
|
+
return (React__namespace.createElement(mosaic.HStack, { spacing: 6 },
|
|
2031
|
+
React__namespace.createElement(mosaic.Box, { as: mosaic.LinkHeading, size: size, "aria-label": title, id: id || slugify(title) }, title),
|
|
1869
2032
|
children));
|
|
1870
2033
|
};
|
|
1871
|
-
const
|
|
1872
|
-
return
|
|
2034
|
+
const SectionSubtitle = props => {
|
|
2035
|
+
return React__namespace.createElement(SectionTitle, Object.assign({}, props, { size: 3 }));
|
|
2036
|
+
};
|
|
2037
|
+
const SubSectionPanel = ({ title, children, hasContent, rightComponent, defaultIsOpen = true, onChange, }) => {
|
|
2038
|
+
return (React__namespace.createElement(mosaic.Panel, { isCollapsible: hasContent, defaultIsOpen: defaultIsOpen, onChange: onChange, appearance: "outlined" },
|
|
1873
2039
|
React__namespace.createElement(mosaic.Panel.Titlebar, { fontWeight: "medium", rightComponent: rightComponent },
|
|
1874
2040
|
React__namespace.createElement("div", { role: "heading" }, title)),
|
|
1875
|
-
hasContent !== false &&
|
|
2041
|
+
hasContent !== false && React__namespace.createElement(mosaic.Panel.Content, null, children)));
|
|
1876
2042
|
};
|
|
1877
2043
|
|
|
1878
|
-
const
|
|
2044
|
+
const isBodyEmpty = (body) => {
|
|
2045
|
+
if (!body)
|
|
2046
|
+
return true;
|
|
2047
|
+
const { contents = [], description } = body;
|
|
2048
|
+
return contents.length === 0 && !(description === null || description === void 0 ? void 0 : description.trim());
|
|
2049
|
+
};
|
|
2050
|
+
const Body = ({ body, onChange }) => {
|
|
1879
2051
|
var _a;
|
|
1880
2052
|
const refResolver = useInlineRefResolver();
|
|
1881
2053
|
const [chosenContent, setChosenContent] = React__namespace.useState(0);
|
|
1882
2054
|
React__namespace.useEffect(() => {
|
|
1883
2055
|
onChange(chosenContent);
|
|
1884
2056
|
}, [chosenContent]);
|
|
1885
|
-
if (
|
|
2057
|
+
if (isBodyEmpty(body))
|
|
1886
2058
|
return null;
|
|
2059
|
+
const { contents = [], description } = body;
|
|
1887
2060
|
const schema = (_a = contents[chosenContent]) === null || _a === void 0 ? void 0 : _a.schema;
|
|
1888
|
-
return (React__namespace.createElement(
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
2061
|
+
return (React__namespace.createElement(mosaic.VStack, { spacing: 6 },
|
|
2062
|
+
React__namespace.createElement(SectionSubtitle, { title: "Body", id: "request-body" }, contents.length > 0 && (React__namespace.createElement(mosaic.Flex, { flex: 1, justify: "end" },
|
|
2063
|
+
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" })))),
|
|
2064
|
+
description && React__namespace.createElement(MarkdownViewer, { markdown: description }),
|
|
2065
|
+
isJSONSchema(schema) && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: refResolver, schema: getOriginalObject(schema), viewMode: "write", hideExamples: true, renderRootTreeLines: true }))));
|
|
1892
2066
|
};
|
|
1893
2067
|
Body.displayName = 'HttpOperation.Body';
|
|
1894
2068
|
|
|
@@ -1912,87 +2086,100 @@ const defaultStyle = {
|
|
|
1912
2086
|
cookie: types.HttpParamStyles.Form,
|
|
1913
2087
|
};
|
|
1914
2088
|
const Parameters = ({ parameters, parameterType }) => {
|
|
1915
|
-
|
|
2089
|
+
const schema = React__namespace.useMemo(() => httpOperationParamsToSchema({ parameters, parameterType }), [parameters, parameterType]);
|
|
2090
|
+
if (!schema)
|
|
1916
2091
|
return null;
|
|
1917
|
-
return
|
|
1918
|
-
return React__namespace.createElement(Parameter, { key: parameter.name, parameter: parameter, parameterType: parameterType });
|
|
1919
|
-
})));
|
|
2092
|
+
return React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { schema: schema, disableCrumbs: true });
|
|
1920
2093
|
};
|
|
1921
2094
|
Parameters.displayName = 'HttpOperation.Parameters';
|
|
1922
|
-
const
|
|
1923
|
-
var _a
|
|
1924
|
-
if (!
|
|
2095
|
+
const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
2096
|
+
var _a;
|
|
2097
|
+
if (!parameters || !parameters.length)
|
|
1925
2098
|
return null;
|
|
1926
|
-
const
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
const
|
|
1931
|
-
const
|
|
1932
|
-
if (
|
|
1933
|
-
|
|
2099
|
+
const schema = {
|
|
2100
|
+
properties: {},
|
|
2101
|
+
required: [],
|
|
2102
|
+
};
|
|
2103
|
+
const sortedParams = sortBy__default["default"](parameters, ['required', 'name']);
|
|
2104
|
+
for (const p of sortedParams) {
|
|
2105
|
+
if (!p.schema)
|
|
2106
|
+
continue;
|
|
2107
|
+
const { name, description, required, deprecated, examples, style } = p;
|
|
2108
|
+
const paramExamples = (examples === null || examples === void 0 ? void 0 : examples.map(example => {
|
|
2109
|
+
if (isNodeExample(example)) {
|
|
2110
|
+
return example.value;
|
|
2111
|
+
}
|
|
2112
|
+
return example.externalValue;
|
|
2113
|
+
})) || [];
|
|
2114
|
+
const schemaExamples = (_a = p.schema) === null || _a === void 0 ? void 0 : _a.examples;
|
|
2115
|
+
const schemaExamplesArray = Array.isArray(schemaExamples) ? schemaExamples : [];
|
|
2116
|
+
const paramDescription = description || p.schema.description;
|
|
2117
|
+
const paramDeprecated = deprecated || p.schema.deprecated;
|
|
2118
|
+
const paramStyle = style && defaultStyle[parameterType] !== style ? readableStyles[style] || style : undefined;
|
|
2119
|
+
schema.properties[p.name] = Object.assign(Object.assign({}, p.schema), { description: paramDescription, examples: [...paramExamples, ...schemaExamplesArray], deprecated: paramDeprecated, style: paramStyle });
|
|
2120
|
+
if (required) {
|
|
2121
|
+
schema.required.push(name);
|
|
1934
2122
|
}
|
|
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';
|
|
2123
|
+
}
|
|
2124
|
+
return schema;
|
|
2125
|
+
};
|
|
1956
2126
|
|
|
1957
|
-
const Request = ({ operation: {
|
|
2127
|
+
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, onChange, }) => {
|
|
1958
2128
|
if (!request || typeof request !== 'object')
|
|
1959
2129
|
return null;
|
|
1960
|
-
const
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
2130
|
+
const bodyIsEmpty = isBodyEmpty(body);
|
|
2131
|
+
const securitySchemes = flatten__default["default"](security);
|
|
2132
|
+
const hasRequestData = Boolean(securitySchemes.length ||
|
|
2133
|
+
pathParams.length ||
|
|
2134
|
+
queryParams.length ||
|
|
2135
|
+
headerParams.length ||
|
|
2136
|
+
cookieParams.length ||
|
|
2137
|
+
!bodyIsEmpty);
|
|
2138
|
+
if (!hasRequestData)
|
|
2139
|
+
return null;
|
|
2140
|
+
return (React__namespace.createElement(mosaic.VStack, { spacing: 8 },
|
|
1965
2141
|
React__namespace.createElement(SectionTitle, { title: "Request" }),
|
|
1966
|
-
React__namespace.createElement(
|
|
1967
|
-
|
|
1968
|
-
|
|
2142
|
+
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) }))))),
|
|
2143
|
+
pathParams.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2144
|
+
React__namespace.createElement(SectionSubtitle, { title: "Path Parameters" }),
|
|
2145
|
+
React__namespace.createElement(Parameters, { parameterType: "path", parameters: pathParams }))),
|
|
2146
|
+
queryParams.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2147
|
+
React__namespace.createElement(SectionSubtitle, { title: "Query Parameters" }),
|
|
1969
2148
|
React__namespace.createElement(Parameters, { parameterType: "query", parameters: queryParams }))),
|
|
1970
|
-
headerParams.length > 0 && (React__namespace.createElement(
|
|
2149
|
+
headerParams.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2150
|
+
React__namespace.createElement(SectionSubtitle, { title: "Headers", id: "request-headers" }),
|
|
1971
2151
|
React__namespace.createElement(Parameters, { parameterType: "header", parameters: headerParams }))),
|
|
1972
|
-
cookieParams.length > 0 && (React__namespace.createElement(
|
|
2152
|
+
cookieParams.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2153
|
+
React__namespace.createElement(SectionSubtitle, { title: "Cookies", id: "request-cookies" }),
|
|
1973
2154
|
React__namespace.createElement(Parameters, { parameterType: "cookie", parameters: cookieParams }))),
|
|
1974
2155
|
body && React__namespace.createElement(Body, { onChange: onChange, body: body })));
|
|
1975
2156
|
};
|
|
1976
|
-
Request.displayName = 'HttpOperation.Request';
|
|
2157
|
+
Request.displayName = 'HttpOperation.Request';
|
|
2158
|
+
const schemeExpandedState = utils.atomWithStorage('HttpOperation_security_expanded', {});
|
|
2159
|
+
const SecurityPanel = ({ scheme, includeKey }) => {
|
|
2160
|
+
const [expandedState, setExpanded] = jotai.useAtom(schemeExpandedState);
|
|
2161
|
+
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 })) },
|
|
2162
|
+
React__namespace.createElement(MarkdownViewer, { style: { fontSize: 12 }, markdown: `${scheme.description || ''}\n\n` + getDefaultDescription(scheme) })));
|
|
2163
|
+
};
|
|
1977
2164
|
|
|
1978
2165
|
const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange }) => {
|
|
1979
2166
|
var _a, _b;
|
|
1980
|
-
const responses =
|
|
2167
|
+
const responses = sortBy__default["default"](uniqBy__default["default"](unsortedResponses, r => r.code), r => r.code);
|
|
1981
2168
|
const [activeResponseId, setActiveResponseId] = React__namespace.useState((_b = (_a = responses[0]) === null || _a === void 0 ? void 0 : _a.code) !== null && _b !== void 0 ? _b : '');
|
|
1982
2169
|
React__namespace.useEffect(() => {
|
|
1983
2170
|
onStatusCodeChange(activeResponseId);
|
|
1984
2171
|
}, [activeResponseId]);
|
|
1985
2172
|
if (!responses.length)
|
|
1986
2173
|
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 }))))))));
|
|
2174
|
+
return (React__namespace.createElement(mosaic.VStack, { spacing: 8, as: mosaic.Tabs, selectedId: activeResponseId, onChange: setActiveResponseId, appearance: "pill" },
|
|
2175
|
+
React__namespace.createElement(SectionTitle, { title: "Responses" },
|
|
2176
|
+
React__namespace.createElement(mosaic.TabList, { density: "compact" }, responses.map(({ code }) => (React__namespace.createElement(mosaic.Tab, { key: code, id: code, intent: codeToIntentVal(code) }, code))))),
|
|
2177
|
+
React__namespace.createElement(mosaic.TabPanels, { p: 0 }, responses.map(response => (React__namespace.createElement(mosaic.TabPanel, { key: response.code, id: response.code },
|
|
2178
|
+
React__namespace.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange })))))));
|
|
1993
2179
|
};
|
|
1994
2180
|
Responses.displayName = 'HttpOperation.Responses';
|
|
1995
|
-
const Response = ({ response
|
|
2181
|
+
const Response = ({ response, onMediaTypeChange }) => {
|
|
2182
|
+
const { contents = [], headers = [], description } = response;
|
|
1996
2183
|
const [chosenContent, setChosenContent] = React__namespace.useState(0);
|
|
1997
2184
|
const refResolver = useInlineRefResolver();
|
|
1998
2185
|
const responseContent = contents[chosenContent];
|
|
@@ -2000,16 +2187,33 @@ const Response = ({ response: { contents = [], headers = [], description }, onMe
|
|
|
2000
2187
|
React__namespace.useEffect(() => {
|
|
2001
2188
|
responseContent && onMediaTypeChange(responseContent.mediaType);
|
|
2002
2189
|
}, [responseContent]);
|
|
2003
|
-
return (React__namespace.createElement(mosaic.
|
|
2004
|
-
description && React__namespace.createElement(MarkdownViewer, {
|
|
2005
|
-
headers.length > 0 && (React__namespace.createElement(
|
|
2190
|
+
return (React__namespace.createElement(mosaic.VStack, { spacing: 8, pt: 8 },
|
|
2191
|
+
description && React__namespace.createElement(MarkdownViewer, { markdown: description }),
|
|
2192
|
+
headers.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2193
|
+
React__namespace.createElement(SectionSubtitle, { title: "Headers", id: "response-headers" }),
|
|
2006
2194
|
React__namespace.createElement(Parameters, { parameterType: "header", parameters: headers }))),
|
|
2007
|
-
contents.length > 0 && (React__namespace.createElement(
|
|
2008
|
-
React__namespace.createElement(
|
|
2195
|
+
contents.length > 0 && (React__namespace.createElement(React__namespace.Fragment, null,
|
|
2196
|
+
React__namespace.createElement(SectionSubtitle, { title: "Body", id: "response-body" },
|
|
2197
|
+
React__namespace.createElement(mosaic.Flex, { flex: 1, justify: "end" },
|
|
2198
|
+
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" }))),
|
|
2199
|
+
schema && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, viewMode: "read", hideExamples: true, parentCrumbs: ['responses', response.code], renderRootTreeLines: true }))))));
|
|
2009
2200
|
};
|
|
2010
|
-
Response.displayName = 'HttpOperation.Response';
|
|
2201
|
+
Response.displayName = 'HttpOperation.Response';
|
|
2202
|
+
const codeToIntentVal = (code) => {
|
|
2203
|
+
const firstChar = code.charAt(0);
|
|
2204
|
+
switch (firstChar) {
|
|
2205
|
+
case '2':
|
|
2206
|
+
return 'success';
|
|
2207
|
+
case '4':
|
|
2208
|
+
return 'warning';
|
|
2209
|
+
case '5':
|
|
2210
|
+
return 'danger';
|
|
2211
|
+
default:
|
|
2212
|
+
return 'default';
|
|
2213
|
+
}
|
|
2214
|
+
};
|
|
2011
2215
|
|
|
2012
|
-
const HttpOperationComponent = React__namespace.memo(({ className, data: unresolvedData,
|
|
2216
|
+
const HttpOperationComponent = React__namespace.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy }) => {
|
|
2013
2217
|
const data = useResolvedObject(unresolvedData);
|
|
2014
2218
|
const mocking = React__namespace.useContext(MockingContext);
|
|
2015
2219
|
const isDeprecated = !!data.deprecated;
|
|
@@ -2017,32 +2221,50 @@ const HttpOperationComponent = React__namespace.memo(({ className, data: unresol
|
|
|
2017
2221
|
const [responseMediaType, setResponseMediaType] = React__namespace.useState('');
|
|
2018
2222
|
const [responseStatusCode, setResponseStatusCode] = React__namespace.useState('');
|
|
2019
2223
|
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 &&
|
|
2224
|
+
const prettyName = (data.summary || data.iid || '').trim();
|
|
2225
|
+
const hasBadges = isDeprecated || isInternal;
|
|
2226
|
+
const header = (!(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) || hasBadges) && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2227
|
+
React__namespace.createElement(mosaic.HStack, { spacing: 5 },
|
|
2228
|
+
!(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) && prettyName ? (React__namespace.createElement(mosaic.Heading, { size: 1, fontWeight: "semibold" }, prettyName)) : null,
|
|
2229
|
+
React__namespace.createElement(mosaic.HStack, { spacing: 2 },
|
|
2230
|
+
isDeprecated && React__namespace.createElement(DeprecatedBadge, null),
|
|
2231
|
+
isInternal && React__namespace.createElement(InternalBadge, { isHttpService: true }))),
|
|
2232
|
+
React__namespace.createElement(MethodPath, { method: data.method, path: data.path })));
|
|
2233
|
+
const description = (React__namespace.createElement(mosaic.VStack, { spacing: 10 },
|
|
2234
|
+
data.description && React__namespace.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
|
|
2031
2235
|
React__namespace.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data }),
|
|
2032
2236
|
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 })));
|
|
2237
|
+
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
2238
|
return (React__namespace.createElement(TwoColumnLayout, { className: cn__default["default"]('HttpOperation', className), header: header, left: description, right: tryItPanel }));
|
|
2036
2239
|
});
|
|
2037
2240
|
HttpOperationComponent.displayName = 'HttpOperation.Component';
|
|
2038
2241
|
const HttpOperation = reactErrorBoundary.withErrorBoundary(HttpOperationComponent, {
|
|
2039
2242
|
recoverableProps: ['data'],
|
|
2040
|
-
});
|
|
2243
|
+
});
|
|
2244
|
+
function MethodPath({ method, path }) {
|
|
2245
|
+
const chosenServer = utils.useAtomValue(chosenServerAtom);
|
|
2246
|
+
let chosenServerUrl = '';
|
|
2247
|
+
if (chosenServer) {
|
|
2248
|
+
chosenServerUrl = chosenServer.url.endsWith('/') ? chosenServer.url.slice(0, -1) : chosenServer.url;
|
|
2249
|
+
}
|
|
2250
|
+
return (React__namespace.createElement(mosaic.Box, null,
|
|
2251
|
+
React__namespace.createElement(MethodPathInner, { method: method, path: path, chosenServerUrl: chosenServerUrl })));
|
|
2252
|
+
}
|
|
2253
|
+
function MethodPathInner({ method, path, chosenServerUrl }) {
|
|
2254
|
+
const isDark = mosaic.useThemeIsDark();
|
|
2255
|
+
const fullUrl = `${chosenServerUrl}${path}`;
|
|
2256
|
+
const pathElem = (React__namespace.createElement(mosaic.Flex, { overflowX: "hidden" },
|
|
2257
|
+
chosenServerUrl ? (React__namespace.createElement(mosaic.Box, { dir: "rtl", color: "muted", fontSize: "lg", textOverflow: "truncate", overflowX: "hidden" }, chosenServerUrl)) : null,
|
|
2258
|
+
React__namespace.createElement(mosaic.Box, { fontSize: "lg", fontWeight: "semibold", flex: 1 }, path)));
|
|
2259
|
+
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 },
|
|
2260
|
+
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),
|
|
2261
|
+
pathElem));
|
|
2262
|
+
}
|
|
2041
2263
|
|
|
2042
2264
|
const PoweredByLink = ({ source, pathname, packageType, layout = 'sidebar' }) => {
|
|
2043
2265
|
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(
|
|
2266
|
+
React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, icon: freeSolidSvgIcons.faBolt, mr: 1, className: "fa-fw", style: { color: 'rgba(144, 97, 249, 1)' } }),
|
|
2267
|
+
React__namespace.createElement(mosaic.Box, null,
|
|
2046
2268
|
"powered by\u00A0",
|
|
2047
2269
|
React__namespace.createElement("strong", null, "Stoplight"))));
|
|
2048
2270
|
};
|
|
@@ -2073,91 +2295,28 @@ const ExportButton = ({ original, bundled }) => {
|
|
|
2073
2295
|
return items;
|
|
2074
2296
|
}, [original, bundled]);
|
|
2075
2297
|
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")) })));
|
|
2298
|
+
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
2299
|
};
|
|
2078
2300
|
|
|
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 },
|
|
2301
|
+
const SecuritySchemes = ({ schemes, defaultScheme, defaultCollapsed = false, }) => {
|
|
2302
|
+
return (React__default["default"].createElement(mosaic.Panel, { rounded: true, isCollapsible: defaultCollapsed },
|
|
2087
2303
|
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) }))))))));
|
|
2304
|
+
React__default["default"].createElement(mosaic.Box, { as: "span", role: "heading" }, "Security")),
|
|
2305
|
+
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
2306
|
};
|
|
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
|
-
}
|
|
2307
|
+
const SecurityScheme = ({ scheme, defaultIsOpen, isCollapsible, showSchemeKey }) => {
|
|
2308
|
+
return (React__default["default"].createElement(mosaic.Panel, { defaultIsOpen: defaultIsOpen, isCollapsible: isCollapsible },
|
|
2309
|
+
React__default["default"].createElement(mosaic.Panel.Titlebar, null,
|
|
2310
|
+
React__default["default"].createElement(mosaic.Box, { as: "span", role: "heading" }, getReadableSecurityName(scheme, showSchemeKey))),
|
|
2311
|
+
React__default["default"].createElement(mosaic.Panel.Content, null,
|
|
2312
|
+
React__default["default"].createElement(MarkdownViewer, { style: { fontSize: 12 }, markdown: `${scheme.description || ''}\n\n` + getDefaultDescription(scheme) }))));
|
|
2313
|
+
};
|
|
2156
2314
|
|
|
2157
2315
|
const ServerInfo = ({ servers, mockUrl }) => {
|
|
2158
2316
|
const mocking = React__namespace.useContext(MockingContext);
|
|
2159
2317
|
const showMocking = !mocking.hideMocking && mockUrl && isProperUrl(mockUrl);
|
|
2160
|
-
const
|
|
2318
|
+
const $mockUrl = showMocking ? mockUrl || mocking.mockUrl : undefined;
|
|
2319
|
+
const serversToDisplay = getServersToDisplay(servers, $mockUrl);
|
|
2161
2320
|
if (!showMocking && serversToDisplay.length === 0) {
|
|
2162
2321
|
return null;
|
|
2163
2322
|
}
|
|
@@ -2166,14 +2325,11 @@ const ServerInfo = ({ servers, mockUrl }) => {
|
|
|
2166
2325
|
React__namespace.createElement(mosaic.Panel.Titlebar, { whitespace: "nowrap" }, "API Base URL"),
|
|
2167
2326
|
React__namespace.createElement(mosaic.Box, { overflowX: "auto" },
|
|
2168
2327
|
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 }))))))));
|
|
2328
|
+
React__namespace.createElement(mosaic.VStack, { spacing: 1, divider: true }, serversToDisplay.map((server, index) => (React__namespace.createElement(ServerUrl, Object.assign({}, server, { key: index }))))))))));
|
|
2173
2329
|
};
|
|
2174
2330
|
const ServerUrl = ({ description, url, marginBottom = true }) => {
|
|
2175
2331
|
const { onCopy, hasCopied } = mosaic.useClipboard(url);
|
|
2176
|
-
return (React__namespace.createElement(mosaic.Box, { whitespace: "nowrap"
|
|
2332
|
+
return (React__namespace.createElement(mosaic.Box, { whitespace: "nowrap" },
|
|
2177
2333
|
React__namespace.createElement(mosaic.Text, { pr: 2, fontWeight: "bold" },
|
|
2178
2334
|
description,
|
|
2179
2335
|
":"),
|
|
@@ -2222,14 +2378,13 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
2222
2378
|
};
|
|
2223
2379
|
const examples = React__namespace.useMemo(() => generateExamplesFromJsonSchema(data), [data]);
|
|
2224
2380
|
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 })),
|
|
2381
|
+
const header = (shouldDisplayHeader || isInternal) && (React__namespace.createElement(mosaic.Flex, { justifyContent: "between", alignItems: "center" },
|
|
2382
|
+
React__namespace.createElement(mosaic.HStack, { spacing: 5 },
|
|
2383
|
+
title && (React__namespace.createElement(mosaic.Heading, { size: 1, fontWeight: "semibold" }, title)),
|
|
2384
|
+
React__namespace.createElement(mosaic.HStack, { spacing: 2 }, isInternal && React__namespace.createElement(InternalBadge, null))),
|
|
2385
|
+
exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && React__namespace.createElement(ExportButton, Object.assign({}, exportProps))));
|
|
2386
|
+
const description = (React__namespace.createElement(mosaic.VStack, { spacing: 10 },
|
|
2387
|
+
data.description && data.type === 'object' && React__namespace.createElement(MarkdownViewer, { role: "textbox", markdown: data.description }),
|
|
2233
2388
|
React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: resolveRef, schema: getOriginalObject(data) })));
|
|
2234
2389
|
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
2390
|
const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && (React__namespace.createElement(mosaic.Panel, { rounded: true, isCollapsible: false },
|
|
@@ -2282,7 +2437,7 @@ const SidebarLayout = React__namespace.forwardRef(({ sidebar, children, maxConte
|
|
|
2282
2437
|
paddingLeft: `calc((100% - ${maxContentWidth}px) / 2)`,
|
|
2283
2438
|
minWidth: `${sidebarWidth}px`,
|
|
2284
2439
|
} }, sidebar),
|
|
2285
|
-
React__namespace.createElement(mosaic.Box, { ref: scrollRef, bg: "canvas", px: 24, flex: 1,
|
|
2440
|
+
React__namespace.createElement(mosaic.Box, { ref: scrollRef, bg: "canvas", px: 24, flex: 1, w: "full" },
|
|
2286
2441
|
React__namespace.createElement(mosaic.Box, { style: { maxWidth: `${maxContentWidth - sidebarWidth}px` }, py: 16 }, children))));
|
|
2287
2442
|
});
|
|
2288
2443
|
|
|
@@ -2307,7 +2462,7 @@ function useParsedValue(value) {
|
|
|
2307
2462
|
}
|
|
2308
2463
|
|
|
2309
2464
|
function isPartialHttpRequest(maybeHttpRequest) {
|
|
2310
|
-
return (
|
|
2465
|
+
return (isObject__default["default"](maybeHttpRequest) &&
|
|
2311
2466
|
'method' in maybeHttpRequest &&
|
|
2312
2467
|
typeof maybeHttpRequest['method'] === 'string' &&
|
|
2313
2468
|
'url' in maybeHttpRequest &&
|
|
@@ -2318,7 +2473,7 @@ const SchemaAndDescription = ({ title: titleProp, schema }) => {
|
|
|
2318
2473
|
const title = titleProp !== null && titleProp !== void 0 ? titleProp : schema.title;
|
|
2319
2474
|
return (React__default["default"].createElement(mosaic.Box, { py: 2 },
|
|
2320
2475
|
title && (React__default["default"].createElement(mosaic.Flex, { alignItems: "center", p: 2 },
|
|
2321
|
-
React__default["default"].createElement(
|
|
2476
|
+
React__default["default"].createElement(mosaic.Icon, { icon: NodeTypeIconDefs[types.NodeType.Model], color: NodeTypeColors[types.NodeType.Model] }),
|
|
2322
2477
|
React__default["default"].createElement(mosaic.Box, { color: "muted", px: 2 }, title))),
|
|
2323
2478
|
React__default["default"].createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: resolveRef, schema: getOriginalObject(schema) })));
|
|
2324
2479
|
};
|
|
@@ -2333,7 +2488,7 @@ const CodeComponent = props => {
|
|
|
2333
2488
|
return React__default["default"].createElement(SchemaAndDescription, { title: title, schema: parsedValue });
|
|
2334
2489
|
}
|
|
2335
2490
|
if (http) {
|
|
2336
|
-
if (!
|
|
2491
|
+
if (!isObject__default["default"](parsedValue) || (!isPartialHttpRequest(parsedValue) && !isHttpOperation(parsedValue))) {
|
|
2337
2492
|
return null;
|
|
2338
2493
|
}
|
|
2339
2494
|
return (React__default["default"].createElement(TryIt, { httpOperation: isHttpOperation(parsedValue) ? parsedValue : parseHttpRequest(parsedValue), embeddedInMd: true }));
|
|
@@ -2614,10 +2769,11 @@ const RouterComponent = {
|
|
|
2614
2769
|
history: reactRouterDom.BrowserRouter,
|
|
2615
2770
|
memory: reactRouterDom.MemoryRouter,
|
|
2616
2771
|
hash: reactRouterDom.HashRouter,
|
|
2772
|
+
static: reactRouterDom.StaticRouter,
|
|
2617
2773
|
};
|
|
2618
|
-
const useRouter = (router, basePath) => {
|
|
2774
|
+
const useRouter = (router, basePath, staticRouterPath) => {
|
|
2619
2775
|
const Router = RouterComponent[router];
|
|
2620
|
-
const routerProps = Object.assign({}, (router !== 'memory' && { basename: basePath }));
|
|
2776
|
+
const routerProps = Object.assign(Object.assign({}, (router !== 'memory' && { basename: basePath })), (router === 'static' && { location: staticRouterPath }));
|
|
2621
2777
|
return {
|
|
2622
2778
|
Router,
|
|
2623
2779
|
routerProps,
|
|
@@ -2626,9 +2782,10 @@ const useRouter = (router, basePath) => {
|
|
|
2626
2782
|
|
|
2627
2783
|
function withRouter(WrappedComponent) {
|
|
2628
2784
|
const WithRouter = (props) => {
|
|
2629
|
-
var _a, _b;
|
|
2785
|
+
var _a, _b, _c;
|
|
2630
2786
|
const basePath = (_a = props.basePath) !== null && _a !== void 0 ? _a : '/';
|
|
2631
|
-
const
|
|
2787
|
+
const staticRouterPath = (_b = props.staticRouterPath) !== null && _b !== void 0 ? _b : '';
|
|
2788
|
+
const { Router, routerProps } = useRouter((_c = props.router) !== null && _c !== void 0 ? _c : 'history', basePath, staticRouterPath);
|
|
2632
2789
|
return (React__namespace.createElement(Router, Object.assign({}, routerProps, { key: basePath }),
|
|
2633
2790
|
React__namespace.createElement(reactRouterDom.Route, { path: "/" },
|
|
2634
2791
|
React__namespace.createElement(MarkdownComponentsProvider, { value: { link: ReactRouterMarkdownLink } },
|
|
@@ -2642,28 +2799,30 @@ function useBundleRefsIntoDocument(document, options) {
|
|
|
2642
2799
|
const [bundledData, setBundledData] = React__namespace.useState(document);
|
|
2643
2800
|
const baseUrl = options === null || options === void 0 ? void 0 : options.baseUrl;
|
|
2644
2801
|
React__namespace.useEffect(() => {
|
|
2645
|
-
if (!
|
|
2802
|
+
if (!isObject__default["default"](document)) {
|
|
2646
2803
|
setBundledData(document);
|
|
2647
2804
|
return;
|
|
2648
2805
|
}
|
|
2649
|
-
let
|
|
2806
|
+
let isMounted = true;
|
|
2650
2807
|
doBundle(document, baseUrl)
|
|
2651
2808
|
.then(res => {
|
|
2652
|
-
if (
|
|
2809
|
+
if (isMounted) {
|
|
2653
2810
|
setBundledData(Object.assign({}, res));
|
|
2654
2811
|
}
|
|
2655
2812
|
})
|
|
2656
2813
|
.catch(reason => {
|
|
2657
2814
|
var _a;
|
|
2658
2815
|
if (typeof reason === 'object' && reason !== null && 'files' in reason) {
|
|
2659
|
-
|
|
2816
|
+
if (isMounted) {
|
|
2817
|
+
setBundledData(Object.assign({}, reason.files.schema));
|
|
2818
|
+
}
|
|
2660
2819
|
}
|
|
2661
2820
|
else {
|
|
2662
2821
|
console.warn(`Could bundle: ${(_a = reason === null || reason === void 0 ? void 0 : reason.message) !== null && _a !== void 0 ? _a : 'Unknown error'}`);
|
|
2663
2822
|
}
|
|
2664
2823
|
});
|
|
2665
2824
|
return () => {
|
|
2666
|
-
|
|
2825
|
+
isMounted = false;
|
|
2667
2826
|
};
|
|
2668
2827
|
}, [document, baseUrl]);
|
|
2669
2828
|
return bundledData;
|
|
@@ -2706,7 +2865,7 @@ const createElementClass = (Component, propDescriptors) => {
|
|
|
2706
2865
|
constructor() {
|
|
2707
2866
|
super();
|
|
2708
2867
|
this._props = {};
|
|
2709
|
-
Object.defineProperties(this,
|
|
2868
|
+
Object.defineProperties(this, mapValues__default["default"](propDescriptors, (_, key) => ({
|
|
2710
2869
|
get: () => {
|
|
2711
2870
|
return this._props[key];
|
|
2712
2871
|
},
|
|
@@ -2727,7 +2886,7 @@ const createElementClass = (Component, propDescriptors) => {
|
|
|
2727
2886
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
2728
2887
|
if (propDescriptors[name]) {
|
|
2729
2888
|
const newPropValue = this._safeReadAttribute(name);
|
|
2730
|
-
if (!
|
|
2889
|
+
if (!isEqual__default["default"](this._props[name], newPropValue)) {
|
|
2731
2890
|
this._props[name] = newPropValue;
|
|
2732
2891
|
this._renderComponent();
|
|
2733
2892
|
}
|
|
@@ -2793,7 +2952,7 @@ const createElementClass = (Component, propDescriptors) => {
|
|
|
2793
2952
|
}
|
|
2794
2953
|
_renderComponent() {
|
|
2795
2954
|
if (this._mountPoint) {
|
|
2796
|
-
const props =
|
|
2955
|
+
const props = mapValues__default["default"](propDescriptors, (descriptor, key) => { var _a; return (_a = this._props[key]) !== null && _a !== void 0 ? _a : descriptor.defaultValue; });
|
|
2797
2956
|
ReactDOM__namespace.render(React__namespace.createElement(Component, props), this._mountPoint);
|
|
2798
2957
|
}
|
|
2799
2958
|
}
|
|
@@ -2830,6 +2989,7 @@ exports.createResolvedObject = createResolvedObject;
|
|
|
2830
2989
|
exports.findFirstNode = findFirstNode;
|
|
2831
2990
|
exports.isHttpOperation = isHttpOperation;
|
|
2832
2991
|
exports.isHttpService = isHttpService;
|
|
2992
|
+
exports.slugify = slugify;
|
|
2833
2993
|
exports.useBundleRefsIntoDocument = useBundleRefsIntoDocument;
|
|
2834
2994
|
exports.useParsedData = useParsedData;
|
|
2835
2995
|
exports.useParsedValue = useParsedValue;
|