@stoplight/elements-core 7.3.8 → 7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Docs/Article/index.d.ts +1 -2
- package/components/Docs/HttpOperation/Badges.d.ts +0 -6
- package/components/Docs/HttpOperation/HttpOperation.d.ts +1 -2
- package/components/Docs/HttpService/HttpService.d.ts +1 -2
- package/components/Docs/HttpService/SecuritySchemes.d.ts +2 -2
- package/components/Docs/Model/Model.d.ts +1 -2
- package/components/Docs/Sections.d.ts +4 -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/useMockingOptions.d.ts +1 -1
- package/hoc/withMosaicProvider.spec.d.ts +1 -0
- package/hoc/withQueryClientProvider.spec.d.ts +1 -0
- package/index.d.ts +3 -1
- package/index.esm.js +228 -183
- package/index.js +287 -216
- package/index.mjs +228 -183
- package/package.json +8 -12
- package/styles.min.css +1 -1
- package/types.d.ts +1 -0
- package/utils/securitySchemes.d.ts +2 -0
package/index.esm.js
CHANGED
|
@@ -2,33 +2,56 @@ import { __rest, __awaiter } from 'tslib';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { useContext, useMemo } from 'react';
|
|
4
4
|
import { resolveInlineRef, isPlainObject as isPlainObject$1, safeParse, safeStringify } from '@stoplight/json';
|
|
5
|
-
import
|
|
5
|
+
import isArray from 'lodash/isArray.js';
|
|
6
|
+
import isObject from 'lodash/isObject.js';
|
|
7
|
+
import isPlainObject from 'lodash/isPlainObject.js';
|
|
6
8
|
import { parse } from '@stoplight/markdown';
|
|
7
9
|
import { NodeType, HttpParamStyles } from '@stoplight/types';
|
|
8
10
|
import { parse as parse$1 } from '@stoplight/yaml';
|
|
9
|
-
import { isArray as isArray$1, Flex,
|
|
11
|
+
import { isArray as isArray$1, Box, Flex, Icon, Popover, Button, Panel, CopyButton, Menu, Text, Input, Select, Image, Link, useThemeIsDark, Tooltip, VStack, InvertTheme, Badge, Tabs, TabList, Tab, TabPanels, TabPanel, Heading as Heading$1, HStack, useClipboard, useMosaicContext, Provider as Provider$1 } from '@stoplight/mosaic';
|
|
10
12
|
import { withErrorBoundary } from '@stoplight/react-error-boundary';
|
|
11
13
|
import { MarkdownViewer as MarkdownViewer$1, DefaultSMDComponents, MarkdownViewerProvider } from '@stoplight/markdown-viewer';
|
|
12
14
|
export { DefaultSMDComponents } from '@stoplight/markdown-viewer';
|
|
13
|
-
import { faStream, faCrosshairs, faCloud, faBookOpen, faCube, faDatabase, faQuestionCircle, faExclamationCircle, faExclamationTriangle, faEye,
|
|
14
|
-
import
|
|
15
|
+
import { faStream, faCrosshairs, faCloud, faBookOpen, faCube, faDatabase, faQuestionCircle, faExclamationCircle, faExclamationTriangle, faEye, faBolt, faCopy, faCheck } from '@fortawesome/free-solid-svg-icons';
|
|
16
|
+
import throttle from 'lodash/throttle.js';
|
|
15
17
|
import { selectAll } from 'unist-util-select';
|
|
16
18
|
import cn from 'classnames';
|
|
17
19
|
import { atom, useAtom, Provider } from 'jotai';
|
|
18
20
|
import URI from 'urijs';
|
|
19
21
|
import { CodeViewer } from '@stoplight/mosaic-code-viewer';
|
|
20
22
|
import HTTPSnippet from 'httpsnippet';
|
|
23
|
+
import flatten from 'lodash/flatten.js';
|
|
24
|
+
import capitalize from 'lodash/capitalize.js';
|
|
25
|
+
import filter from 'lodash/filter.js';
|
|
21
26
|
import { nanoid } from 'nanoid';
|
|
22
|
-
import
|
|
27
|
+
import curry from 'lodash/curry.js';
|
|
28
|
+
import omit from 'lodash/omit.js';
|
|
29
|
+
import keyBy from 'lodash/keyBy.js';
|
|
30
|
+
import map from 'lodash/map.js';
|
|
31
|
+
import mapValues from 'lodash/mapValues.js';
|
|
32
|
+
import isString from 'lodash/isString.js';
|
|
33
|
+
import pickBy from 'lodash/pickBy.js';
|
|
23
34
|
import { CodeEditor } from '@stoplight/mosaic-code-editor';
|
|
24
35
|
import * as Sampler from '@stoplight/json-schema-sampler';
|
|
36
|
+
import compact from 'lodash/compact.js';
|
|
37
|
+
import uniq from 'lodash/uniq.js';
|
|
38
|
+
import orderBy from 'lodash/orderBy.js';
|
|
39
|
+
import uniqBy from 'lodash/uniqBy.js';
|
|
25
40
|
import formatXml from 'xml-formatter';
|
|
26
|
-
import {
|
|
41
|
+
import { atomWithStorage } from 'jotai/utils';
|
|
42
|
+
import entries from 'lodash/entries.js';
|
|
43
|
+
import keys from 'lodash/keys.js';
|
|
27
44
|
import { JsonSchemaViewer, Validations } from '@stoplight/json-schema-viewer';
|
|
28
|
-
import
|
|
45
|
+
import get from 'lodash/get.js';
|
|
46
|
+
import isEmpty from 'lodash/isEmpty.js';
|
|
47
|
+
import omitBy from 'lodash/omitBy.js';
|
|
48
|
+
import sortBy from 'lodash/sortBy.js';
|
|
49
|
+
import { useLocation, BrowserRouter, MemoryRouter, HashRouter, Route } from 'react-router-dom';
|
|
29
50
|
import { HashLink } from 'react-router-hash-link';
|
|
51
|
+
import { QueryClient, useQueryClient, QueryClientProvider } from 'react-query';
|
|
30
52
|
import $RefParser from '@stoplight/json-schema-ref-parser';
|
|
31
53
|
import * as PropTypes from 'prop-types';
|
|
54
|
+
import isEqual from 'lodash/isEqual.js';
|
|
32
55
|
import * as ReactDOM from 'react-dom';
|
|
33
56
|
|
|
34
57
|
const defaultResolver = (contextObject) => ({ pointer }, _, currentObject) => {
|
|
@@ -263,15 +286,15 @@ const ArticleHeadings = ({ tree, container }) => {
|
|
|
263
286
|
const { width } = useComponentSize(container);
|
|
264
287
|
const showHeadings = width >= 768;
|
|
265
288
|
const headings = useComputeMarkdownHeadings(tree);
|
|
266
|
-
return React.createElement(Headings, { className: "ArticleHeadings", headings: headings, minimal: !showHeadings });
|
|
289
|
+
return React.createElement(Headings, { className: "ArticleHeadings", headings: headings, minimal: !showHeadings, maxWidth: 300 });
|
|
267
290
|
};
|
|
268
|
-
const Headings = ({ headings, className, title = 'On This Page', minimal }) => {
|
|
291
|
+
const Headings = ({ headings, className, title = 'On This Page', minimal, maxWidth }) => {
|
|
269
292
|
const locationHash = useLocationHash();
|
|
270
293
|
if (!headings || !headings.length)
|
|
271
294
|
return null;
|
|
272
|
-
const component = (React.createElement("
|
|
295
|
+
const component = (React.createElement(Box, { overflowY: "auto", style: { maxHeight: '85vh', maxWidth } },
|
|
273
296
|
title && (React.createElement(Flex, { py: 2, alignItems: "center", fontSize: "sm", fontWeight: "medium", color: "muted", style: { paddingLeft: 18 } },
|
|
274
|
-
React.createElement(
|
|
297
|
+
React.createElement(Box, { as: Icon, icon: faStream, mr: 2 }),
|
|
275
298
|
title)),
|
|
276
299
|
headings.map((heading, i) => (React.createElement(Heading, { key: i, item: heading, isSelected: locationHash === `#${heading.id}` })))));
|
|
277
300
|
if (minimal) {
|
|
@@ -291,7 +314,7 @@ const ArticleComponent = React.memo(({ data }) => {
|
|
|
291
314
|
const tree = React.useMemo(() => (typeof data === 'object' ? data : parse(data)), [data]);
|
|
292
315
|
if (tree === null)
|
|
293
316
|
return null;
|
|
294
|
-
return (React.createElement(Flex, { className: "sl-elements-article", w: "full", pos: "relative", ref: setContainer },
|
|
317
|
+
return (React.createElement(Flex, { className: "sl-elements-article", justifyContent: "evenly", w: "full", pos: "relative", ref: setContainer },
|
|
295
318
|
React.createElement(Box, { className: "sl-elements-article-content", style: { width: 0 }, flex: 1 },
|
|
296
319
|
React.createElement(MarkdownViewer, { markdown: tree })),
|
|
297
320
|
React.createElement(ArticleHeadings, { tree: tree, container: container })));
|
|
@@ -312,38 +335,6 @@ function createNamedContext(name, defaultValue) {
|
|
|
312
335
|
return context;
|
|
313
336
|
}
|
|
314
337
|
|
|
315
|
-
function getReadableSecurityName(securityScheme, includeKey = false) {
|
|
316
|
-
let name = '';
|
|
317
|
-
switch (securityScheme.type) {
|
|
318
|
-
case 'apiKey':
|
|
319
|
-
name = 'API Key';
|
|
320
|
-
break;
|
|
321
|
-
case 'http':
|
|
322
|
-
name = `${capitalize(securityScheme.scheme)} Auth`;
|
|
323
|
-
break;
|
|
324
|
-
case 'oauth2':
|
|
325
|
-
name = 'OAuth 2.0';
|
|
326
|
-
break;
|
|
327
|
-
case 'openIdConnect':
|
|
328
|
-
name = 'OpenID Connect';
|
|
329
|
-
break;
|
|
330
|
-
case 'mutualTLS':
|
|
331
|
-
name = 'Mutual TLS';
|
|
332
|
-
break;
|
|
333
|
-
}
|
|
334
|
-
return includeKey ? `${name} (${securityScheme.key})` : name;
|
|
335
|
-
}
|
|
336
|
-
function getServiceUriFromOperation(uri) {
|
|
337
|
-
const match = uri === null || uri === void 0 ? void 0 : uri.match(/(.*)\/(paths|operations)/);
|
|
338
|
-
return match && match.length > 1 ? match[1] || '/' : undefined;
|
|
339
|
-
}
|
|
340
|
-
const isOAuth2ImplicitFlow = (maybeFlow) => isObject(maybeFlow) && 'authorizationUrl' in maybeFlow && !('tokenUrl' in maybeFlow);
|
|
341
|
-
const isOauth2AuthorizationCodeFlow = (maybeFlow) => isObject(maybeFlow) && 'authorizationUrl' in maybeFlow && 'tokenUrl' in maybeFlow;
|
|
342
|
-
const isOauth2ClientCredentialsOrPasswordFlow = (maybeFlow) => isObject(maybeFlow) && !('authorizationUrl' in maybeFlow) && 'tokenUrl' in maybeFlow;
|
|
343
|
-
function shouldIncludeKey(schemes, type) {
|
|
344
|
-
return filter(schemes, { type }).length > 1;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
338
|
const NodeTypeColors = {
|
|
348
339
|
http_operation: '#6a6acb',
|
|
349
340
|
http_service: '#e056fd',
|
|
@@ -732,6 +723,34 @@ const RequestSamples = React__default.memo(({ request, embeddedInMd = false }) =
|
|
|
732
723
|
React__default.createElement(CodeViewer, { "aria-label": requestSample !== null && requestSample !== void 0 ? requestSample : fallbackText, noCopyButton: true, maxHeight: "400px", language: mosaicCodeViewerLanguage, value: requestSample || fallbackText }))));
|
|
733
724
|
});
|
|
734
725
|
|
|
726
|
+
function getReadableSecurityName(securityScheme, includeKey = false) {
|
|
727
|
+
let name = '';
|
|
728
|
+
switch (securityScheme.type) {
|
|
729
|
+
case 'apiKey':
|
|
730
|
+
name = 'API Key';
|
|
731
|
+
break;
|
|
732
|
+
case 'http':
|
|
733
|
+
name = `${capitalize(securityScheme.scheme)} Auth`;
|
|
734
|
+
break;
|
|
735
|
+
case 'oauth2':
|
|
736
|
+
name = 'OAuth 2.0';
|
|
737
|
+
break;
|
|
738
|
+
case 'openIdConnect':
|
|
739
|
+
name = 'OpenID Connect';
|
|
740
|
+
break;
|
|
741
|
+
case 'mutualTLS':
|
|
742
|
+
name = 'Mutual TLS';
|
|
743
|
+
break;
|
|
744
|
+
}
|
|
745
|
+
return includeKey ? `${name} (${securityScheme.key})` : name;
|
|
746
|
+
}
|
|
747
|
+
const isOAuth2ImplicitFlow = (maybeFlow) => isObject(maybeFlow) && 'authorizationUrl' in maybeFlow && !('tokenUrl' in maybeFlow);
|
|
748
|
+
const isOauth2AuthorizationCodeFlow = (maybeFlow) => isObject(maybeFlow) && 'authorizationUrl' in maybeFlow && 'tokenUrl' in maybeFlow;
|
|
749
|
+
const isOauth2ClientCredentialsOrPasswordFlow = (maybeFlow) => isObject(maybeFlow) && !('authorizationUrl' in maybeFlow) && 'tokenUrl' in maybeFlow;
|
|
750
|
+
function shouldIncludeKey(schemes, type) {
|
|
751
|
+
return filter(schemes, { type }).length > 1;
|
|
752
|
+
}
|
|
753
|
+
|
|
735
754
|
const useUniqueId = (prefix = 'id_') => React.useRef(`${prefix}${nanoid(8)}`).current;
|
|
736
755
|
|
|
737
756
|
const AuthTokenInput = ({ type, name, value, onChange }) => {
|
|
@@ -1006,7 +1025,10 @@ const getInitialValueForParameter = (parameter) => {
|
|
|
1006
1025
|
return '';
|
|
1007
1026
|
return getValueForParameter(parameter);
|
|
1008
1027
|
};
|
|
1009
|
-
const initialParameterValues =
|
|
1028
|
+
const initialParameterValues = params => {
|
|
1029
|
+
const paramsByName = keyBy(params, (param) => param.name);
|
|
1030
|
+
return mapValues(paramsByName, param => getInitialValueForParameter(param));
|
|
1031
|
+
};
|
|
1010
1032
|
function mapSchemaPropertiesToParameters(properties, required) {
|
|
1011
1033
|
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 }))));
|
|
1012
1034
|
}
|
|
@@ -1231,7 +1253,6 @@ const generateExamplesFromJsonSchema = (schema) => {
|
|
|
1231
1253
|
: [{ label: 'default', data: '' }];
|
|
1232
1254
|
}
|
|
1233
1255
|
catch (e) {
|
|
1234
|
-
console.error(e);
|
|
1235
1256
|
return [{ label: '', data: `Example cannot be created for this schema\n${e}` }];
|
|
1236
1257
|
}
|
|
1237
1258
|
};
|
|
@@ -1607,7 +1628,7 @@ const TryItResponse = ({ response }) => {
|
|
|
1607
1628
|
? parseBody(response.bodyText, responseType)
|
|
1608
1629
|
: response.bodyText })) : response.blob && responseType === 'image' ? (React.createElement(Flex, { justifyContent: "center" },
|
|
1609
1630
|
React.createElement(Image, { src: URL.createObjectURL(response.blob), alt: "response image" }))) : (React.createElement("p", null,
|
|
1610
|
-
React.createElement(
|
|
1631
|
+
React.createElement(Box, { as: Icon, icon: faExclamationCircle, mr: 2 }),
|
|
1611
1632
|
"No supported response body returned"))))));
|
|
1612
1633
|
};
|
|
1613
1634
|
const ResponseMenu = ({ types, type, onChange }) => {
|
|
@@ -1661,18 +1682,22 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
|
|
|
1661
1682
|
}
|
|
1662
1683
|
}, []);
|
|
1663
1684
|
React.useEffect(() => {
|
|
1664
|
-
let
|
|
1685
|
+
let isMounted = true;
|
|
1665
1686
|
if (onRequestChange || embeddedInMd) {
|
|
1666
1687
|
buildHarRequest(Object.assign(Object.assign({ mediaTypeContent, parameterValues: parameterValuesWithDefaults, httpOperation, bodyInput: formDataState.isFormDataBody ? bodyParameterValues : textRequestBody, auth: operationAuthValue }, (mockingOptions.isEnabled && { mockData: getMockData(mockUrl, httpOperation, mockingOptions) })), { chosenServer,
|
|
1667
1688
|
corsProxy })).then(request => {
|
|
1668
|
-
if (
|
|
1669
|
-
onRequestChange
|
|
1670
|
-
|
|
1671
|
-
|
|
1689
|
+
if (isMounted) {
|
|
1690
|
+
if (onRequestChange) {
|
|
1691
|
+
onRequestChange(request);
|
|
1692
|
+
}
|
|
1693
|
+
if (embeddedInMd) {
|
|
1694
|
+
setRequestData(request);
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1672
1697
|
});
|
|
1673
1698
|
}
|
|
1674
1699
|
return () => {
|
|
1675
|
-
|
|
1700
|
+
isMounted = false;
|
|
1676
1701
|
};
|
|
1677
1702
|
}, [
|
|
1678
1703
|
httpOperation,
|
|
@@ -1805,18 +1830,13 @@ const TryItWithRequestSamples = (_a) => {
|
|
|
1805
1830
|
const TwoColumnLayout = ({ header, right, left, className }) => (React__default.createElement(Box, { w: "full", className: className },
|
|
1806
1831
|
header,
|
|
1807
1832
|
React__default.createElement(Flex, { mt: header ? 12 : undefined },
|
|
1808
|
-
React__default.createElement(Box, {
|
|
1833
|
+
React__default.createElement(Box, { w: 0, flex: 1 }, left),
|
|
1809
1834
|
right && (React__default.createElement(Box, { ml: 16, pos: "relative", w: "2/5", style: { maxWidth: 500 } }, right)))));
|
|
1810
1835
|
|
|
1811
1836
|
const DeprecatedBadge = () => (React__default.createElement(Tooltip, { renderTrigger: React__default.createElement(Badge, { intent: "warning", icon: 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."));
|
|
1812
|
-
const InternalBadge = ({ isHttpService }) => (React__default.createElement(Tooltip, { renderTrigger: React__default.createElement(Badge, { icon: faEye, "data-testid": "badge-internal",
|
|
1813
|
-
const
|
|
1814
|
-
const badge = (React__default.createElement(Badge, { icon: faLock, "data-testid": "badge-security", className: "sl-truncate", style: { backgroundColor: badgeDefaultBackgroundColor, color: badgeDefaultColor } }, getReadableSecurityName(scheme, includeKey)));
|
|
1815
|
-
return httpServiceUri ? (React__default.createElement(Link$1, { to: `${httpServiceUri}?security=${scheme.key}`, className: "sl-no-underline sl-block" }, badge)) : (badge);
|
|
1816
|
-
};
|
|
1817
|
-
const VersionBadge = ({ value, backgroundColor }) => (React__default.createElement(Badge, { appearance: "solid", size: "sm", style: {
|
|
1837
|
+
const InternalBadge = ({ isHttpService }) => (React__default.createElement(Tooltip, { renderTrigger: React__default.createElement(Badge, { icon: faEye, "data-testid": "badge-internal", bg: "danger", ml: 0 }, "Internal") }, `This ${isHttpService ? 'operation' : 'model'} is marked as internal and won't be visible in public docs.`));
|
|
1838
|
+
const VersionBadge = ({ value, backgroundColor }) => (React__default.createElement(Badge, { appearance: "solid", size: "sm", border: 0, style: {
|
|
1818
1839
|
backgroundColor: backgroundColor || badgeDefaultBackgroundColor,
|
|
1819
|
-
border: 'none',
|
|
1820
1840
|
color: badgeDefaultColor,
|
|
1821
1841
|
} }, enhanceVersionString(value)));
|
|
1822
1842
|
const enhanceVersionString = (version) => {
|
|
@@ -1825,16 +1845,85 @@ const enhanceVersionString = (version) => {
|
|
|
1825
1845
|
return `v${version}`;
|
|
1826
1846
|
};
|
|
1827
1847
|
|
|
1848
|
+
const oauthFlowNames = {
|
|
1849
|
+
implicit: 'Implicit',
|
|
1850
|
+
authorizationCode: 'Authorization Code',
|
|
1851
|
+
clientCredentials: 'Client Credentials',
|
|
1852
|
+
password: 'Password',
|
|
1853
|
+
};
|
|
1854
|
+
function getDefaultDescription(scheme) {
|
|
1855
|
+
switch (scheme.type) {
|
|
1856
|
+
case 'apiKey':
|
|
1857
|
+
return getApiKeyDescription(scheme.in, scheme.name);
|
|
1858
|
+
case 'http':
|
|
1859
|
+
switch (scheme.scheme) {
|
|
1860
|
+
case 'basic':
|
|
1861
|
+
return getBasicAuthDescription();
|
|
1862
|
+
case 'bearer':
|
|
1863
|
+
return getBearerAuthDescription();
|
|
1864
|
+
case 'digest':
|
|
1865
|
+
return getDigestAuthDescription();
|
|
1866
|
+
}
|
|
1867
|
+
case 'oauth2':
|
|
1868
|
+
return getOAuthDescription(scheme);
|
|
1869
|
+
}
|
|
1870
|
+
return '';
|
|
1871
|
+
}
|
|
1872
|
+
function getApiKeyDescription(inProperty, name) {
|
|
1873
|
+
return `An API key is a token that you provide when making API calls. Include the token in a ${inProperty} parameter called \`${name}\`.
|
|
1874
|
+
|
|
1875
|
+
Example: ${inProperty === 'query' ? `\`?${name}=123\`` : `\`${name}: 123\``}`;
|
|
1876
|
+
}
|
|
1877
|
+
function getBasicAuthDescription() {
|
|
1878
|
+
return `Basic authentication is a simple authentication scheme built into the HTTP protocol.
|
|
1879
|
+
To use it, send your HTTP requests with an Authorization header that contains the word Basic
|
|
1880
|
+
followed by a space and a base64-encoded string \`username:password\`.
|
|
1881
|
+
|
|
1882
|
+
Example: \`Authorization: Basic ZGVtbzpwQDU1dzByZA==\``;
|
|
1883
|
+
}
|
|
1884
|
+
function getBearerAuthDescription() {
|
|
1885
|
+
return `Provide your bearer token in the Authorization header when making requests to protected resources.
|
|
1886
|
+
|
|
1887
|
+
Example: \`Authorization: Bearer 123\``;
|
|
1888
|
+
}
|
|
1889
|
+
function getDigestAuthDescription() {
|
|
1890
|
+
return `Provide your encrypted digest scheme data in the Authorization header when making requests to protected resources.
|
|
1891
|
+
|
|
1892
|
+
Example: \`Authorization: Digest username=guest, realm="test", nonce="2", uri="/uri", response="123"\``;
|
|
1893
|
+
}
|
|
1894
|
+
function getOAuthDescription(scheme) {
|
|
1895
|
+
const flows = keys(scheme.flows);
|
|
1896
|
+
return flows.map(flow => getOAuthFlowDescription(oauthFlowNames[flow], scheme.flows[flow])).join('\n\n');
|
|
1897
|
+
}
|
|
1898
|
+
function getOAuthFlowDescription(title, flow) {
|
|
1899
|
+
let description = `**${title} OAuth Flow**`;
|
|
1900
|
+
description +=
|
|
1901
|
+
isOAuth2ImplicitFlow(flow) || isOauth2AuthorizationCodeFlow(flow)
|
|
1902
|
+
? `\n\nAuthorize URL: ${flow.authorizationUrl}`
|
|
1903
|
+
: '';
|
|
1904
|
+
description +=
|
|
1905
|
+
isOauth2AuthorizationCodeFlow(flow) || isOauth2ClientCredentialsOrPasswordFlow(flow)
|
|
1906
|
+
? `\n\nToken URL: ${flow.tokenUrl}`
|
|
1907
|
+
: '';
|
|
1908
|
+
description += flow.refreshUrl ? `\n\nRefresh URL: ${flow.refreshUrl}` : '';
|
|
1909
|
+
const scopes = entries(flow.scopes);
|
|
1910
|
+
if (scopes.length) {
|
|
1911
|
+
description += `\n\nScopes:
|
|
1912
|
+
${scopes.map(([key, value]) => `- \`${key}\` - ${value}`).join('\n')}`;
|
|
1913
|
+
}
|
|
1914
|
+
return description;
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1828
1917
|
const SectionTitle = ({ title, children }) => {
|
|
1829
1918
|
return (React.createElement(Flex, { role: "heading", borderB: true, mb: 3, pb: 3, "aria-label": title, align: "baseline" },
|
|
1830
1919
|
React.createElement(Text, { size: "xl", fontWeight: "semibold", mr: 5 }, title),
|
|
1831
1920
|
children));
|
|
1832
1921
|
};
|
|
1833
|
-
const SubSectionPanel = ({ title, children, hasContent, rightComponent }) => {
|
|
1834
|
-
return (React.createElement(Panel, { appearance: "minimal", isCollapsible: hasContent, defaultIsOpen:
|
|
1922
|
+
const SubSectionPanel = ({ title, children, hasContent, rightComponent, defaultIsOpen = true, onChange, }) => {
|
|
1923
|
+
return (React.createElement(Panel, { appearance: "minimal", isCollapsible: hasContent, defaultIsOpen: defaultIsOpen, onChange: onChange },
|
|
1835
1924
|
React.createElement(Panel.Titlebar, { fontWeight: "medium", rightComponent: rightComponent },
|
|
1836
1925
|
React.createElement("div", { role: "heading" }, title)),
|
|
1837
|
-
hasContent !== false && (React.createElement(Panel.Content, { pr: 3,
|
|
1926
|
+
hasContent !== false && (React.createElement(Panel.Content, { pr: 3, pl: 6, p: 0 }, children))));
|
|
1838
1927
|
};
|
|
1839
1928
|
|
|
1840
1929
|
const Body = ({ body: { contents = [], description }, onChange }) => {
|
|
@@ -1876,7 +1965,7 @@ const defaultStyle = {
|
|
|
1876
1965
|
const Parameters = ({ parameters, parameterType }) => {
|
|
1877
1966
|
if (!parameters || !parameters.length)
|
|
1878
1967
|
return null;
|
|
1879
|
-
return (React.createElement(VStack, { spacing: 2,
|
|
1968
|
+
return (React.createElement(VStack, { spacing: 2, divider: React.createElement(Box, { borderT: true, borderColor: "light", w: "full" }) }, sortBy(parameters, ['required', 'name']).map(parameter => {
|
|
1880
1969
|
return React.createElement(Parameter, { key: parameter.name, parameter: parameter, parameterType: parameterType });
|
|
1881
1970
|
})));
|
|
1882
1971
|
};
|
|
@@ -1899,32 +1988,34 @@ const Parameter = ({ parameter, parameterType }) => {
|
|
|
1899
1988
|
const schemaExamples = (_e = parameter.schema) === null || _e === void 0 ? void 0 : _e.examples;
|
|
1900
1989
|
const schemaExamplesArray = Array.isArray(schemaExamples) ? schemaExamples : [];
|
|
1901
1990
|
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');
|
|
1902
|
-
return (React.createElement(
|
|
1903
|
-
React.createElement(
|
|
1904
|
-
React.createElement(
|
|
1905
|
-
React.createElement(
|
|
1906
|
-
React.createElement(
|
|
1907
|
-
React.createElement(
|
|
1908
|
-
deprecated && React.createElement(
|
|
1909
|
-
parameter.required && React.createElement(
|
|
1910
|
-
description && (React.createElement(
|
|
1991
|
+
return (React.createElement(Box, { className: "HttpOperation__Parameters" },
|
|
1992
|
+
React.createElement(Flex, { alignItems: "center", my: 2 },
|
|
1993
|
+
React.createElement(Flex, { alignItems: "baseline", fontSize: "base", flex: 1 },
|
|
1994
|
+
React.createElement(Box, { fontFamily: "mono", fontWeight: "bold" }, parameter.name),
|
|
1995
|
+
React.createElement(Box, { ml: 2, color: "muted" }, format ? `${type}<${format}>` : type)),
|
|
1996
|
+
React.createElement(Box, { fontSize: "sm", color: "warning" },
|
|
1997
|
+
deprecated && (React.createElement(Box, { as: "span", ml: 2 }, "deprecated")),
|
|
1998
|
+
parameter.required && (React.createElement(Box, { as: "span", ml: 2 }, "required")))),
|
|
1999
|
+
description && (React.createElement(Box, { w: "full", color: "muted", fontSize: "sm", my: 2 },
|
|
1911
2000
|
React.createElement(MarkdownViewer$1, { markdown: description }))),
|
|
1912
|
-
React.createElement(
|
|
2001
|
+
React.createElement(Box, { fontSize: "sm" },
|
|
1913
2002
|
React.createElement(Validations, { validations: validations })),
|
|
1914
|
-
parameter.style && defaultStyle[parameterType] !== parameter.style && (React.createElement(
|
|
1915
|
-
React.createElement(
|
|
2003
|
+
parameter.style && defaultStyle[parameterType] !== parameter.style && (React.createElement(Flex, { my: 2 },
|
|
2004
|
+
React.createElement(Box, { as: "span", px: 1, color: "muted", fontFamily: "mono", rounded: "lg", fontSize: "sm", textTransform: "capitalize", style: { backgroundColor: '#EDF2F7' } }, readableStyles[parameter.style] || parameter.style)))));
|
|
1916
2005
|
};
|
|
1917
2006
|
Parameter.displayName = 'HttpOperation.Parameter';
|
|
1918
2007
|
|
|
1919
2008
|
const Request = ({ operation: { path, method, request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, onChange, }) => {
|
|
1920
2009
|
if (!request || typeof request !== 'object')
|
|
1921
2010
|
return null;
|
|
1922
|
-
const
|
|
2011
|
+
const securitySchemes = flatten(security);
|
|
2012
|
+
const pathParamBlock = (React.createElement(Box, null,
|
|
1923
2013
|
React.createElement(Text, { textTransform: "uppercase", mr: 1, color: HttpMethodColors[method] }, method),
|
|
1924
2014
|
' ',
|
|
1925
2015
|
path));
|
|
1926
|
-
return (React.createElement(Box,
|
|
2016
|
+
return (React.createElement(Box, null,
|
|
1927
2017
|
React.createElement(SectionTitle, { title: "Request" }),
|
|
2018
|
+
securitySchemes.map((scheme, i) => (React.createElement(SecurityPanel, { key: i, scheme: scheme, includeKey: shouldIncludeKey(securitySchemes, scheme.type) }))),
|
|
1928
2019
|
React.createElement(SubSectionPanel, { title: pathParamBlock, hasContent: pathParams.length > 0 },
|
|
1929
2020
|
React.createElement(Parameters, { parameterType: "path", parameters: pathParams })),
|
|
1930
2021
|
queryParams.length > 0 && (React.createElement(SubSectionPanel, { title: "Query" },
|
|
@@ -1935,7 +2026,13 @@ const Request = ({ operation: { path, method, request, request: { path: pathPara
|
|
|
1935
2026
|
React.createElement(Parameters, { parameterType: "cookie", parameters: cookieParams }))),
|
|
1936
2027
|
body && React.createElement(Body, { onChange: onChange, body: body })));
|
|
1937
2028
|
};
|
|
1938
|
-
Request.displayName = 'HttpOperation.Request';
|
|
2029
|
+
Request.displayName = 'HttpOperation.Request';
|
|
2030
|
+
const schemeExpandedState = atomWithStorage('HttpOperation_security_expanded', {});
|
|
2031
|
+
const SecurityPanel = ({ scheme, includeKey }) => {
|
|
2032
|
+
const [expandedState, setExpanded] = useAtom(schemeExpandedState);
|
|
2033
|
+
return (React.createElement(SubSectionPanel, { title: `Security: ${getReadableSecurityName(scheme, includeKey)}`, defaultIsOpen: !!expandedState[scheme.key], onChange: isOpen => setExpanded(Object.assign(Object.assign({}, expandedState), { [scheme.key]: isOpen })) },
|
|
2034
|
+
React.createElement(MarkdownViewer, { style: { fontSize: 12 }, markdown: `${scheme.description || ''}\n\n` + getDefaultDescription(scheme) })));
|
|
2035
|
+
};
|
|
1939
2036
|
|
|
1940
2037
|
const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange }) => {
|
|
1941
2038
|
var _a, _b;
|
|
@@ -1971,7 +2068,7 @@ const Response = ({ response: { contents = [], headers = [], description }, onMe
|
|
|
1971
2068
|
};
|
|
1972
2069
|
Response.displayName = 'HttpOperation.Response';
|
|
1973
2070
|
|
|
1974
|
-
const HttpOperationComponent = React.memo(({ className, data: unresolvedData,
|
|
2071
|
+
const HttpOperationComponent = React.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy }) => {
|
|
1975
2072
|
const data = useResolvedObject(unresolvedData);
|
|
1976
2073
|
const mocking = React.useContext(MockingContext);
|
|
1977
2074
|
const isDeprecated = !!data.deprecated;
|
|
@@ -1979,21 +2076,17 @@ const HttpOperationComponent = React.memo(({ className, data: unresolvedData, ur
|
|
|
1979
2076
|
const [responseMediaType, setResponseMediaType] = React.useState('');
|
|
1980
2077
|
const [responseStatusCode, setResponseStatusCode] = React.useState('');
|
|
1981
2078
|
const [requestBodyIndex, setTextRequestBodyIndex] = React.useState(0);
|
|
1982
|
-
const
|
|
1983
|
-
const securitySchemes = flatten(data.security);
|
|
1984
|
-
const hasBadges = isDeprecated || securitySchemes.length > 0 || isInternal;
|
|
2079
|
+
const hasBadges = isDeprecated || isInternal;
|
|
1985
2080
|
const header = (!(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) || hasBadges) && (React.createElement(React.Fragment, null,
|
|
1986
2081
|
!(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) && (React.createElement(Heading$1, { size: 1, mb: 4, fontWeight: "semibold" }, data.summary || data.iid || `${data.method} ${data.path}`)),
|
|
1987
2082
|
hasBadges && (React.createElement(HStack, { spacing: 2 },
|
|
1988
2083
|
isDeprecated && React.createElement(DeprecatedBadge, null),
|
|
1989
|
-
sortBy(securitySchemes, 'type').map((scheme, i) => (React.createElement(SecurityBadge, { key: i, scheme: scheme, httpServiceUri: allowRouting ? httpServiceUri : undefined, includeKey: shouldIncludeKey(securitySchemes, scheme.type) }))),
|
|
1990
2084
|
isInternal && React.createElement(InternalBadge, { isHttpService: true })))));
|
|
1991
|
-
const description = (React.createElement(
|
|
1992
|
-
data.description &&
|
|
2085
|
+
const description = (React.createElement(VStack, { spacing: 6 },
|
|
2086
|
+
data.description && React.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
|
|
1993
2087
|
React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data }),
|
|
1994
2088
|
data.responses && (React.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode }))));
|
|
1995
|
-
const tryItPanel = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideTryItPanel) && (React.createElement(
|
|
1996
|
-
React.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 })));
|
|
2089
|
+
const tryItPanel = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideTryItPanel) && (React.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 }));
|
|
1997
2090
|
return (React.createElement(TwoColumnLayout, { className: cn('HttpOperation', className), header: header, left: description, right: tryItPanel }));
|
|
1998
2091
|
});
|
|
1999
2092
|
HttpOperationComponent.displayName = 'HttpOperation.Component';
|
|
@@ -2003,8 +2096,8 @@ const HttpOperation = withErrorBoundary(HttpOperationComponent, {
|
|
|
2003
2096
|
|
|
2004
2097
|
const PoweredByLink = ({ source, pathname, packageType, layout = 'sidebar' }) => {
|
|
2005
2098
|
return (React.createElement(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" },
|
|
2006
|
-
React.createElement(
|
|
2007
|
-
React.createElement(
|
|
2099
|
+
React.createElement(Box, { as: Icon, icon: faBolt, mr: 1, className: "fa-fw", style: { color: 'rgba(144, 97, 249, 1)' } }),
|
|
2100
|
+
React.createElement(Box, null,
|
|
2008
2101
|
"powered by\u00A0",
|
|
2009
2102
|
React.createElement("strong", null, "Stoplight"))));
|
|
2010
2103
|
};
|
|
@@ -2038,83 +2131,19 @@ const ExportButton = ({ original, bundled }) => {
|
|
|
2038
2131
|
React.createElement(Menu, { "aria-label": "Export", items: menuItems, renderTrigger: ({ isOpen }) => (React.createElement(Button, { iconRight: "chevron-down", appearance: "default", ml: 2, active: isOpen, size: "sm" }, "Export")) })));
|
|
2039
2132
|
};
|
|
2040
2133
|
|
|
2041
|
-
const
|
|
2042
|
-
|
|
2043
|
-
authorizationCode: 'Authorization Code',
|
|
2044
|
-
clientCredentials: 'Client Credentials',
|
|
2045
|
-
password: 'Password',
|
|
2046
|
-
};
|
|
2047
|
-
const SecuritySchemes = ({ schemes, defaultScheme }) => {
|
|
2048
|
-
return (React__default.createElement(Panel, { rounded: true, isCollapsible: false },
|
|
2134
|
+
const SecuritySchemes = ({ schemes, defaultScheme, defaultCollapsed = false, }) => {
|
|
2135
|
+
return (React__default.createElement(Panel, { rounded: true, isCollapsible: defaultCollapsed },
|
|
2049
2136
|
React__default.createElement(Panel.Titlebar, { bg: "canvas-300" },
|
|
2050
|
-
React__default.createElement("span",
|
|
2051
|
-
React__default.createElement(Panel.Content, { p: 0 }, sortBy(schemes, 'type').map((scheme, i) => (React__default.createElement(
|
|
2052
|
-
React__default.createElement(Panel.Titlebar, null,
|
|
2053
|
-
React__default.createElement("span", { role: "heading" }, getReadableSecurityName(scheme, shouldIncludeKey(schemes, scheme.type)))),
|
|
2054
|
-
React__default.createElement(Panel.Content, null,
|
|
2055
|
-
React__default.createElement(MarkdownViewer, { style: { fontSize: 12 }, markdown: `${scheme.description || ''}\n\n` + getDefaultDescription(scheme) }))))))));
|
|
2137
|
+
React__default.createElement(Box, { as: "span", role: "heading" }, "Security")),
|
|
2138
|
+
React__default.createElement(Panel.Content, { p: 0 }, sortBy(schemes, 'type').map((scheme, i) => (React__default.createElement(SecurityScheme, { key: i, scheme: scheme, defaultIsOpen: defaultScheme ? scheme.key === defaultScheme : i === 0, isCollapsible: schemes.length > 1, showSchemeKey: shouldIncludeKey(schemes, scheme.type) }))))));
|
|
2056
2139
|
};
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
return getBasicAuthDescription();
|
|
2065
|
-
case 'bearer':
|
|
2066
|
-
return getBearerAuthDescription();
|
|
2067
|
-
case 'digest':
|
|
2068
|
-
return getDigestAuthDescription();
|
|
2069
|
-
}
|
|
2070
|
-
case 'oauth2':
|
|
2071
|
-
return getOAuthDescription(scheme);
|
|
2072
|
-
}
|
|
2073
|
-
return '';
|
|
2074
|
-
}
|
|
2075
|
-
function getApiKeyDescription(inProperty, name) {
|
|
2076
|
-
return `An API key is a token that you provide when making API calls. Include the token in a ${inProperty} parameter called \`${name}\`.
|
|
2077
|
-
|
|
2078
|
-
Example: ${inProperty === 'query' ? `\`?${name}=123\`` : `\`${name}: 123\``}`;
|
|
2079
|
-
}
|
|
2080
|
-
function getBasicAuthDescription() {
|
|
2081
|
-
return `Basic authentication is a simple authentication scheme built into the HTTP protocol.
|
|
2082
|
-
To use it, send your HTTP requests with an Authorization header that contains the word Basic
|
|
2083
|
-
followed by a space and a base64-encoded string \`username:password\`.
|
|
2084
|
-
|
|
2085
|
-
Example: \`Authorization: Basic ZGVtbzpwQDU1dzByZA==\``;
|
|
2086
|
-
}
|
|
2087
|
-
function getBearerAuthDescription() {
|
|
2088
|
-
return `Provide your bearer token in the Authorization header when making requests to protected resources.
|
|
2089
|
-
|
|
2090
|
-
Example: \`Authorization: Bearer 123\``;
|
|
2091
|
-
}
|
|
2092
|
-
function getDigestAuthDescription() {
|
|
2093
|
-
return `Provide your encrypted digest scheme data in the Authorization header when making requests to protected resources.
|
|
2094
|
-
|
|
2095
|
-
Example: \`Authorization: Digest username=guest, realm="test", nonce="2", uri="/uri", response="123"\``;
|
|
2096
|
-
}
|
|
2097
|
-
function getOAuthDescription(scheme) {
|
|
2098
|
-
const flows = keys(scheme.flows);
|
|
2099
|
-
return flows.map(flow => getOAuthFlowDescription(oauthFlowNames[flow], scheme.flows[flow])).join('\n\n');
|
|
2100
|
-
}
|
|
2101
|
-
function getOAuthFlowDescription(title, flow) {
|
|
2102
|
-
let description = `**${title} OAuth Flow**`;
|
|
2103
|
-
description +=
|
|
2104
|
-
isOAuth2ImplicitFlow(flow) || isOauth2AuthorizationCodeFlow(flow)
|
|
2105
|
-
? `\n\nAuthorize URL: ${flow.authorizationUrl}`
|
|
2106
|
-
: '';
|
|
2107
|
-
description +=
|
|
2108
|
-
isOauth2AuthorizationCodeFlow(flow) || isOauth2ClientCredentialsOrPasswordFlow(flow)
|
|
2109
|
-
? `\n\nToken URL: ${flow.tokenUrl}`
|
|
2110
|
-
: '';
|
|
2111
|
-
description += flow.refreshUrl ? `\n\nRefresh URL: ${flow.refreshUrl}` : '';
|
|
2112
|
-
description += `\n\nScopes:
|
|
2113
|
-
${entries(flow.scopes)
|
|
2114
|
-
.map(([key, value]) => `- \`${key}\` - ${value}`)
|
|
2115
|
-
.join('\n')}`;
|
|
2116
|
-
return description;
|
|
2117
|
-
}
|
|
2140
|
+
const SecurityScheme = ({ scheme, defaultIsOpen, isCollapsible, showSchemeKey }) => {
|
|
2141
|
+
return (React__default.createElement(Panel, { defaultIsOpen: defaultIsOpen, isCollapsible: isCollapsible },
|
|
2142
|
+
React__default.createElement(Panel.Titlebar, null,
|
|
2143
|
+
React__default.createElement(Box, { as: "span", role: "heading" }, getReadableSecurityName(scheme, showSchemeKey))),
|
|
2144
|
+
React__default.createElement(Panel.Content, null,
|
|
2145
|
+
React__default.createElement(MarkdownViewer, { style: { fontSize: 12 }, markdown: `${scheme.description || ''}\n\n` + getDefaultDescription(scheme) }))));
|
|
2146
|
+
};
|
|
2118
2147
|
|
|
2119
2148
|
const ServerInfo = ({ servers, mockUrl }) => {
|
|
2120
2149
|
const mocking = React.useContext(MockingContext);
|
|
@@ -2280,7 +2309,7 @@ const SchemaAndDescription = ({ title: titleProp, schema }) => {
|
|
|
2280
2309
|
const title = titleProp !== null && titleProp !== void 0 ? titleProp : schema.title;
|
|
2281
2310
|
return (React__default.createElement(Box, { py: 2 },
|
|
2282
2311
|
title && (React__default.createElement(Flex, { alignItems: "center", p: 2 },
|
|
2283
|
-
React__default.createElement(
|
|
2312
|
+
React__default.createElement(Icon, { icon: NodeTypeIconDefs[NodeType.Model], color: NodeTypeColors[NodeType.Model] }),
|
|
2284
2313
|
React__default.createElement(Box, { color: "muted", px: 2 }, title))),
|
|
2285
2314
|
React__default.createElement(JsonSchemaViewer, { resolveRef: resolveRef, schema: getOriginalObject(schema) })));
|
|
2286
2315
|
};
|
|
@@ -2334,6 +2363,15 @@ const MarkdownComponentsProvider = ({ value, children }) => {
|
|
|
2334
2363
|
return React.createElement(MarkdownViewerProvider, { components: Object.assign({ code: CodeComponent }, value) }, children);
|
|
2335
2364
|
};
|
|
2336
2365
|
|
|
2366
|
+
const externalRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
2367
|
+
const ReactRouterMarkdownLink = ({ title, href, children }) => {
|
|
2368
|
+
const isExternal = href !== undefined && externalRegex.test(href);
|
|
2369
|
+
if (isExternal) {
|
|
2370
|
+
return (React__default.createElement("a", { target: "_blank", rel: "noreferrer noopener", href: href, title: title }, children));
|
|
2371
|
+
}
|
|
2372
|
+
return (React__default.createElement(HashLink, { to: href, title: title }, children));
|
|
2373
|
+
};
|
|
2374
|
+
|
|
2337
2375
|
const NODE_TYPE_TITLE_ICON = {
|
|
2338
2376
|
http_service: faCloud,
|
|
2339
2377
|
};
|
|
@@ -2525,6 +2563,14 @@ function withPersistenceBoundary(WrappedComponent) {
|
|
|
2525
2563
|
|
|
2526
2564
|
function withMosaicProvider(WrappedComponent) {
|
|
2527
2565
|
const WithMosaicProvider = (props) => {
|
|
2566
|
+
try {
|
|
2567
|
+
const mosaicContext = useMosaicContext();
|
|
2568
|
+
if (mosaicContext === null || mosaicContext === void 0 ? void 0 : mosaicContext.providerId) {
|
|
2569
|
+
return React__default.createElement(WrappedComponent, Object.assign({}, props));
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
catch (_a) {
|
|
2573
|
+
}
|
|
2528
2574
|
return (React__default.createElement(Provider$1, { style: { height: '100%' } },
|
|
2529
2575
|
React__default.createElement(WrappedComponent, Object.assign({}, props))));
|
|
2530
2576
|
};
|
|
@@ -2542,6 +2588,12 @@ const queryClient = new QueryClient({
|
|
|
2542
2588
|
});
|
|
2543
2589
|
function withQueryClientProvider(WrappedComponent) {
|
|
2544
2590
|
const WithQueryClientProvider = (props) => {
|
|
2591
|
+
try {
|
|
2592
|
+
useQueryClient();
|
|
2593
|
+
return React__default.createElement(WrappedComponent, Object.assign({}, props));
|
|
2594
|
+
}
|
|
2595
|
+
catch (_a) {
|
|
2596
|
+
}
|
|
2545
2597
|
return (React__default.createElement(QueryClientProvider, { client: queryClient },
|
|
2546
2598
|
React__default.createElement(WrappedComponent, Object.assign({}, props))));
|
|
2547
2599
|
};
|
|
@@ -2549,15 +2601,6 @@ function withQueryClientProvider(WrappedComponent) {
|
|
|
2549
2601
|
return WithQueryClientProvider;
|
|
2550
2602
|
}
|
|
2551
2603
|
|
|
2552
|
-
const externalRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
2553
|
-
const ReactRouterMarkdownLink = ({ title, href, children }) => {
|
|
2554
|
-
const isExternal = href !== undefined && externalRegex.test(href);
|
|
2555
|
-
if (isExternal) {
|
|
2556
|
-
return (React__default.createElement("a", { target: "_blank", rel: "noreferrer noopener", href: href, title: title }, children));
|
|
2557
|
-
}
|
|
2558
|
-
return (React__default.createElement(HashLink, { to: href, title: title }, children));
|
|
2559
|
-
};
|
|
2560
|
-
|
|
2561
2604
|
const RouterComponent = {
|
|
2562
2605
|
history: BrowserRouter,
|
|
2563
2606
|
memory: MemoryRouter,
|
|
@@ -2594,24 +2637,26 @@ function useBundleRefsIntoDocument(document, options) {
|
|
|
2594
2637
|
setBundledData(document);
|
|
2595
2638
|
return;
|
|
2596
2639
|
}
|
|
2597
|
-
let
|
|
2640
|
+
let isMounted = true;
|
|
2598
2641
|
doBundle(document, baseUrl)
|
|
2599
2642
|
.then(res => {
|
|
2600
|
-
if (
|
|
2643
|
+
if (isMounted) {
|
|
2601
2644
|
setBundledData(Object.assign({}, res));
|
|
2602
2645
|
}
|
|
2603
2646
|
})
|
|
2604
2647
|
.catch(reason => {
|
|
2605
2648
|
var _a;
|
|
2606
2649
|
if (typeof reason === 'object' && reason !== null && 'files' in reason) {
|
|
2607
|
-
|
|
2650
|
+
if (isMounted) {
|
|
2651
|
+
setBundledData(Object.assign({}, reason.files.schema));
|
|
2652
|
+
}
|
|
2608
2653
|
}
|
|
2609
2654
|
else {
|
|
2610
2655
|
console.warn(`Could bundle: ${(_a = reason === null || reason === void 0 ? void 0 : reason.message) !== null && _a !== void 0 ? _a : 'Unknown error'}`);
|
|
2611
2656
|
}
|
|
2612
2657
|
});
|
|
2613
2658
|
return () => {
|
|
2614
|
-
|
|
2659
|
+
isMounted = false;
|
|
2615
2660
|
};
|
|
2616
2661
|
}, [document, baseUrl]);
|
|
2617
2662
|
return bundledData;
|
|
@@ -2654,7 +2699,7 @@ const createElementClass = (Component, propDescriptors) => {
|
|
|
2654
2699
|
constructor() {
|
|
2655
2700
|
super();
|
|
2656
2701
|
this._props = {};
|
|
2657
|
-
Object.defineProperties(this, mapValues
|
|
2702
|
+
Object.defineProperties(this, mapValues(propDescriptors, (_, key) => ({
|
|
2658
2703
|
get: () => {
|
|
2659
2704
|
return this._props[key];
|
|
2660
2705
|
},
|
|
@@ -2741,11 +2786,11 @@ const createElementClass = (Component, propDescriptors) => {
|
|
|
2741
2786
|
}
|
|
2742
2787
|
_renderComponent() {
|
|
2743
2788
|
if (this._mountPoint) {
|
|
2744
|
-
const props = mapValues
|
|
2789
|
+
const props = mapValues(propDescriptors, (descriptor, key) => { var _a; return (_a = this._props[key]) !== null && _a !== void 0 ? _a : descriptor.defaultValue; });
|
|
2745
2790
|
ReactDOM.render(React.createElement(Component, props), this._mountPoint);
|
|
2746
2791
|
}
|
|
2747
2792
|
}
|
|
2748
2793
|
};
|
|
2749
2794
|
};
|
|
2750
2795
|
|
|
2751
|
-
export { DeprecatedBadge, Docs, ExportButton, HttpMethodColors, InlineRefResolverProvider, Logo, MarkdownComponentsProvider, MockingProvider, NodeTypeColors, NodeTypeIconDefs, NodeTypePrettyName, NonIdealState, ParsedDocs, PersistenceContextProvider, PoweredByLink, SidebarLayout, Styled, TableOfContents, TryIt, TryItWithRequestSamples, createElementClass, createResolvedObject, findFirstNode, isHttpOperation, isHttpService, useBundleRefsIntoDocument, useParsedData, useParsedValue, useRouter, withMosaicProvider, withPersistenceBoundary, withQueryClientProvider, withRouter, withStyles };
|
|
2796
|
+
export { DeprecatedBadge, Docs, ExportButton, HttpMethodColors, InlineRefResolverProvider, Logo, MarkdownComponentsProvider, MockingProvider, NodeTypeColors, NodeTypeIconDefs, NodeTypePrettyName, NonIdealState, ParsedDocs, PersistenceContextProvider, PoweredByLink, ReactRouterMarkdownLink, SidebarLayout, Styled, TableOfContents, TryIt, TryItWithRequestSamples, createElementClass, createResolvedObject, findFirstNode, isHttpOperation, isHttpService, useBundleRefsIntoDocument, useParsedData, useParsedValue, useRouter, withMosaicProvider, withPersistenceBoundary, withQueryClientProvider, withRouter, withStyles };
|