@stoplight/elements-core 8.2.0 → 8.3.2

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.
@@ -1 +1 @@
1
- export declare const schemaWithRefs = "---\ntitle: Schema with refs\n---\n\n# Schema with refs (Swr)\n\n### Schema\n\nThis is bundled schema with refs\n\n```json jsonSchema\n{\n \"title\": \"DerefTest\",\n \"type\": \"object\",\n \"description\": \"Dereferencing test object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"inner\": {\n \"description\": \"Inner object\",\n \"title\": \"Inner\",\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"referencedObject\": {\n \"$ref\": \"#/properties/referencedObject\",\n \"description\": \"Inner referenced object\"\n }\n },\n \"required\": [\n \"id\",\n \"bookingRate\"\n ]\n },\n \"referencedObject\": {\n \"description\": \"Referenced object\",\n \"title\": \"ReferencedObject\",\n \"type\": \"object\",\n \"required\": [\n \"property1\",\n \"property2\",\n \"property3\"\n ],\n \"properties\": {\n \"property1\": {\n \"type\": \"integer\",\n \"description\": \"Property 1\"\n },\n \"property2\": {\n \"type\": \"string\",\n \"description\": \"Property 2\"\n },\n \"property3\": {\n \"type\": \"boolean\",\n \"description\": \"Property 3\"\n }\n }\n }\n },\n \"required\": [\n \"id\",\n \"inner\",\n \"referencedObject\"\n ]\n}\n```";
1
+ export declare const schemaWithRefs = "---\ntitle: Schema with refs\n---\n\n# Schema with refs (Swr)\n\n### Schema\n\nThis is bundled schema with refs\n\n```json jsonSchema\n{\n \"title\": \"DerefTest\",\n \"type\": \"object\",\n \"description\": \"Dereferencing test object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"inner\": {\n \"description\": \"Inner object\",\n \"title\": \"Inner\",\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"referencedObject\": {\n \"$ref\": \"#/properties/referencedObject\",\n \"description\": \"Inner referenced object\"\n }\n },\n \"required\": [\n \"id\",\n \"bookingRate\"\n ]\n },\n \"referencedObject\": {\n \"description\": \"Referenced object\",\n \"title\": \"ReferencedObject\",\n \"type\": \"object\",\n \"required\": [\n \"property1\",\n \"property2\",\n \"property3\"\n ],\n \"properties\": {\n \"property1\": {\n \"type\": \"integer\",\n \"description\": \"Property 1\"\n },\n \"property2\": {\n \"type\": \"string\",\n \"description\": \"Property 2\"\n },\n \"property3\": {\n \"type\": \"boolean\",\n \"description\": \"Property 3\"\n },\n \"property4\": {\n \"type\": \"string\",\n \"enum\": [\n \"BUSINESS\",\n \"PERSONAL\",\n \"OTHER\"\n ],\n \"x-enum-descriptions\": {\n \"BUSINESS\": \"Enum description for BUSINESS\",\n \"PERSONAL\": \"Enum description for PERSONAL\",\n \"OTHER\": \"Enum description for OTHER\"\n }\n }\n }\n }\n },\n \"required\": [\n \"id\",\n \"inner\",\n \"referencedObject\"\n ]\n}\n```";
@@ -1,13 +1,17 @@
1
1
  declare const meta: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, {
2
2
  data: any;
3
+ renderExtensionAddon?: import("..").ExtensionAddonRenderer | undefined;
3
4
  } & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
4
5
  export default meta;
5
6
  export declare const Basic: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, {
6
7
  data: any;
8
+ renderExtensionAddon?: import("..").ExtensionAddonRenderer | undefined;
7
9
  } & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
8
10
  export declare const KitchenSink: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, {
9
11
  data: any;
12
+ renderExtensionAddon?: import("..").ExtensionAddonRenderer | undefined;
10
13
  } & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
11
14
  export declare const MultipleTryIts: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, {
12
15
  data: any;
16
+ renderExtensionAddon?: import("..").ExtensionAddonRenderer | undefined;
13
17
  } & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
@@ -1,3 +1,4 @@
1
+ import { SchemaNode } from '@stoplight/json-schema-tree';
1
2
  import type { NodeHasChangedFn, NodeType } from '@stoplight/types';
2
3
  import { Location } from 'history';
3
4
  import * as React from 'react';
@@ -5,6 +6,13 @@ import { ParsedNode } from '../../types';
5
6
  import { ReferenceResolver } from '../../utils/ref-resolving/ReferenceResolver';
6
7
  import { ExportButtonProps } from './HttpService/ExportButton';
7
8
  declare type NodeUnsupportedFn = (err: 'dataEmpty' | 'invalidType' | Error) => void;
9
+ export declare type VendorExtensionsData = Record<string, unknown>;
10
+ export declare type ExtensionRowProps = {
11
+ schemaNode: SchemaNode;
12
+ nestingLevel: number;
13
+ vendorExtensions: VendorExtensionsData;
14
+ };
15
+ export declare type ExtensionAddonRenderer = (props: ExtensionRowProps) => React.ReactNode;
8
16
  interface BaseDocsProps {
9
17
  className?: string;
10
18
  uri?: string;
@@ -27,6 +35,7 @@ interface BaseDocsProps {
27
35
  };
28
36
  nodeHasChanged?: NodeHasChangedFn<React.ReactNode>;
29
37
  nodeUnsupported?: NodeUnsupportedFn;
38
+ renderExtensionAddon?: ExtensionAddonRenderer;
30
39
  }
31
40
  export interface DocsProps extends BaseDocsProps {
32
41
  nodeType: NodeType;
@@ -1,4 +1,5 @@
1
1
  import { IHttpCallbackOperation } from '@stoplight/types';
2
+ import { ExtensionAddonRenderer } from '../Docs';
2
3
  export interface CallbacksProps {
3
4
  callbacks: IHttpCallbackOperation[];
4
5
  isCompact?: boolean;
@@ -6,6 +7,7 @@ export interface CallbacksProps {
6
7
  export interface CallbackProps {
7
8
  data: IHttpCallbackOperation;
8
9
  isCompact?: boolean;
10
+ renderExtensionAddon?: ExtensionAddonRenderer;
9
11
  }
10
12
  export declare const Callbacks: {
11
13
  ({ callbacks, isCompact }: CallbacksProps): JSX.Element;
@@ -1,10 +1,9 @@
1
1
  declare const meta: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, {
2
2
  data: any;
3
+ renderExtensionAddon?: import("..").ExtensionAddonRenderer | undefined;
3
4
  } & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
4
5
  export default meta;
5
6
  export declare const Story: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, {
6
7
  data: any;
7
- } & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
8
- export declare const StoryWithCustomCodeSamples: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, {
9
- data: any;
8
+ renderExtensionAddon?: import("..").ExtensionAddonRenderer | undefined;
10
9
  } & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
@@ -1,7 +1,9 @@
1
1
  declare const meta: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, {
2
2
  data: any;
3
+ renderExtensionAddon?: import("..").ExtensionAddonRenderer | undefined;
3
4
  } & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
4
5
  export default meta;
5
6
  export declare const Story: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, {
6
7
  data: any;
8
+ renderExtensionAddon?: import("..").ExtensionAddonRenderer | undefined;
7
9
  } & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
@@ -1,7 +1,9 @@
1
1
  declare const meta: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, {
2
2
  data: any;
3
+ renderExtensionAddon?: import("..").ExtensionAddonRenderer | undefined;
3
4
  } & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
4
5
  export default meta;
5
6
  export declare const Story: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, {
6
7
  data: any;
8
+ renderExtensionAddon?: import("..").ExtensionAddonRenderer | undefined;
7
9
  } & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
@@ -0,0 +1,7 @@
1
+ import { INode } from '@stoplight/types';
2
+ import type { JSONSchema7 } from 'json-schema';
3
+ import * as React from 'react';
4
+ export declare type NodeVendorExtensionsProps = {
5
+ data: INode | JSONSchema7;
6
+ };
7
+ export declare const NodeVendorExtensions: React.NamedExoticComponent<NodeVendorExtensionsProps>;
@@ -1,8 +1,10 @@
1
1
  import type { ErrorBoundaryProps } from '@stoplight/react-error-boundary';
2
2
  import type { Meta, StoryFn } from '@storybook/react';
3
3
  import * as React from 'react';
4
+ import { ExtensionAddonRenderer } from './Docs';
4
5
  declare type DocsProps = {
5
6
  data: any;
7
+ renderExtensionAddon?: ExtensionAddonRenderer;
6
8
  } & ErrorBoundaryProps;
7
9
  declare type storyOptions = DocsProps & {
8
10
  layoutOptions?: object;
@@ -0,0 +1,3 @@
1
+ import { ExtensionAddonRenderer } from './Docs';
2
+ export declare const renderExtensionRenderer: ExtensionAddonRenderer;
3
+ export declare const wrapOptionsContext: (story: any) => JSX.Element;
@@ -24,4 +24,7 @@ export declare const NODE_META_COLOR: {
24
24
  put: string;
25
25
  patch: string;
26
26
  delete: string;
27
+ head: string;
28
+ options: string;
29
+ trace: string;
27
30
  };
package/constants.d.ts CHANGED
@@ -11,6 +11,9 @@ export declare const HttpMethodColors: {
11
11
  readonly put: "warning";
12
12
  readonly patch: "warning";
13
13
  readonly delete: "danger";
14
+ readonly head: "#9061F9";
15
+ readonly options: "#0D5AA7";
16
+ readonly trace: "#0D0B28";
14
17
  };
15
18
  export declare const HttpCodeColor: {
16
19
  readonly 0: "red";
@@ -1,9 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import type { DocsProps } from '../components/Docs';
3
- export declare type ElementsOptionsContextProps = Pick<DocsProps, 'nodeHasChanged'>;
3
+ export declare type ElementsOptionsContextProps = Pick<DocsProps, 'nodeHasChanged' | 'renderExtensionAddon'>;
4
4
  export declare const ElementsOptionsContext: React.Context<ElementsOptionsContextProps>;
5
5
  export declare const useOptionsCtx: () => ElementsOptionsContextProps;
6
6
  export declare type ProviderProps = Partial<ElementsOptionsContextProps> & {
7
7
  children: React.ReactNode;
8
8
  };
9
- export declare function ElementsOptionsProvider({ children, nodeHasChanged }: ProviderProps): JSX.Element;
9
+ export declare function ElementsOptionsProvider({ children, nodeHasChanged, renderExtensionAddon }: ProviderProps): JSX.Element;
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { Docs, DocsProps, ParsedDocs } from './components/Docs';
1
+ export { Docs, DocsProps, ExtensionAddonRenderer, ExtensionRowProps, ParsedDocs } from './components/Docs';
2
2
  export { DeprecatedBadge } from './components/Docs/HttpOperation/Badges';
3
3
  export { ExportButton, ExportButtonProps } from './components/Docs/HttpService/ExportButton';
4
4
  export { ResponsiveSidebarLayout } from './components/Layout/ResponsiveSidebarLayout';
@@ -17,6 +17,7 @@ export { TryIt, TryItProps, TryItWithRequestSamples, TryItWithRequestSamplesProp
17
17
  export { HttpMethodColors, NodeTypeColors, NodeTypeIconDefs, NodeTypePrettyName } from './constants';
18
18
  export { MockingProvider } from './containers/MockingProvider';
19
19
  export { InlineRefResolverProvider } from './context/InlineRefResolver';
20
+ export { ElementsOptionsProvider } from './context/Options';
20
21
  export { PersistenceContextProvider, withPersistenceBoundary } from './context/Persistence';
21
22
  export { RouterTypeContext } from './context/RouterType';
22
23
  export { withMosaicProvider } from './hoc/withMosaicProvider';
package/index.esm.js CHANGED
@@ -44,6 +44,7 @@ import uniq from 'lodash/uniq.js';
44
44
  import orderBy from 'lodash/orderBy.js';
45
45
  import uniqBy from 'lodash/uniqBy.js';
46
46
  import formatXml from 'xml-formatter';
47
+ import memoize from 'lodash/memoize.js';
47
48
  import entries from 'lodash/entries.js';
48
49
  import keys from 'lodash/keys.js';
49
50
  import sortBy from 'lodash/sortBy.js';
@@ -164,8 +165,8 @@ const ElementsOptionsContext = React.createContext(DEFAULT_CONTEXT);
164
165
  const useOptionsCtx = () => {
165
166
  return React.useContext(ElementsOptionsContext) || DEFAULT_CONTEXT;
166
167
  };
167
- function ElementsOptionsProvider({ children, nodeHasChanged }) {
168
- return (React.createElement(ElementsOptionsContext.Provider, { value: Object.assign({}, DEFAULT_CONTEXT, { nodeHasChanged }) }, children));
168
+ function ElementsOptionsProvider({ children, nodeHasChanged, renderExtensionAddon }) {
169
+ return (React.createElement(ElementsOptionsContext.Provider, { value: Object.assign({}, DEFAULT_CONTEXT, { nodeHasChanged, renderExtensionAddon }) }, children));
169
170
  }
170
171
 
171
172
  function isSMDASTRoot(maybeAst) {
@@ -450,6 +451,9 @@ const HttpMethodColors = {
450
451
  put: 'warning',
451
452
  patch: 'warning',
452
453
  delete: 'danger',
454
+ head: '#9061F9',
455
+ options: '#0D5AA7',
456
+ trace: '#0D0B28',
453
457
  };
454
458
  const HttpCodeColor = {
455
459
  0: 'red',
@@ -2444,6 +2448,32 @@ const TryItWithRequestSamples = (_a) => {
2444
2448
  React.createElement(ResponseExamples, Object.assign({}, props))));
2445
2449
  };
2446
2450
 
2451
+ const getVendorExtensions = memoize((data) => {
2452
+ const vendorExtensionNames = Object.keys(data).filter(item => item.startsWith('x-'));
2453
+ const vendorExtensions = vendorExtensionNames.reduce((previousValue, currentValue, currentIndex) => {
2454
+ return Object.assign(Object.assign({}, previousValue), { [currentValue]: data[currentValue] });
2455
+ }, {});
2456
+ return vendorExtensions;
2457
+ });
2458
+ const NodeVendorExtensions = React.memo(({ data }) => {
2459
+ const { renderExtensionAddon } = useOptionsCtx();
2460
+ if (!renderExtensionAddon) {
2461
+ return null;
2462
+ }
2463
+ const originalObject = getOriginalObject(data);
2464
+ const vendorExtensions = originalObject.extensions ? originalObject.extensions : getVendorExtensions(originalObject);
2465
+ const vendorExtensionKeys = Object.keys(vendorExtensions);
2466
+ if (vendorExtensionKeys.length === 0) {
2467
+ return null;
2468
+ }
2469
+ return (React.createElement(React.Fragment, null, renderExtensionAddon({
2470
+ nestingLevel: -1,
2471
+ schemaNode: originalObject,
2472
+ vendorExtensions,
2473
+ })));
2474
+ });
2475
+ NodeVendorExtensions.displayName = 'NodeVendorExtensions';
2476
+
2447
2477
  const TwoColumnLayout = React__default.forwardRef(({ header, right, left, className }, ref) => (React__default.createElement(VStack, { ref: ref, w: "full", className: className, spacing: 8 },
2448
2478
  header,
2449
2479
  React__default.createElement(Flex, null,
@@ -2516,42 +2546,43 @@ const oauthFlowNames = {
2516
2546
  function getDefaultDescription(scheme) {
2517
2547
  switch (scheme.type) {
2518
2548
  case 'apiKey':
2519
- return getApiKeyDescription(scheme.in, scheme.name);
2549
+ return getApiKeyDescription(scheme);
2520
2550
  case 'http':
2521
2551
  switch (scheme.scheme) {
2522
2552
  case 'basic':
2523
- return getBasicAuthDescription();
2553
+ return getBasicAuthDescription(scheme);
2524
2554
  case 'bearer':
2525
- return getBearerAuthDescription();
2555
+ return getBearerAuthDescription(scheme);
2526
2556
  case 'digest':
2527
- return getDigestAuthDescription();
2557
+ return getDigestAuthDescription(scheme);
2528
2558
  }
2529
2559
  case 'oauth2':
2530
2560
  return getOAuthDescription(scheme);
2531
2561
  }
2532
2562
  return '';
2533
2563
  }
2534
- function getApiKeyDescription(inProperty, name) {
2564
+ function getApiKeyDescription(scheme) {
2565
+ const { in: inProperty, name } = scheme;
2535
2566
  return `An API key is a token that you provide when making API calls. Include the token in a ${inProperty} parameter called \`${name}\`.
2536
2567
 
2537
- Example: ${inProperty === 'query' ? `\`?${name}=123\`` : `\`${name}: 123\``}`;
2568
+ Example: ${inProperty === 'query' ? `\`?${name}=123\`` : `\`${name}: 123\``}${getSecuritySchemeRoles(scheme)}`;
2538
2569
  }
2539
- function getBasicAuthDescription() {
2570
+ function getBasicAuthDescription(schema) {
2540
2571
  return `Basic authentication is a simple authentication scheme built into the HTTP protocol.
2541
2572
  To use it, send your HTTP requests with an Authorization header that contains the word Basic
2542
2573
  followed by a space and a base64-encoded string \`username:password\`.
2543
2574
 
2544
- Example: \`Authorization: Basic ZGVtbzpwQDU1dzByZA==\``;
2575
+ Example: \`Authorization: Basic ZGVtbzpwQDU1dzByZA==\`${getSecuritySchemeRoles(schema)}`;
2545
2576
  }
2546
- function getBearerAuthDescription() {
2577
+ function getBearerAuthDescription(schema) {
2547
2578
  return `Provide your bearer token in the Authorization header when making requests to protected resources.
2548
2579
 
2549
- Example: \`Authorization: Bearer 123\``;
2580
+ Example: \`Authorization: Bearer 123\`${getSecuritySchemeRoles(schema)}`;
2550
2581
  }
2551
- function getDigestAuthDescription() {
2582
+ function getDigestAuthDescription(schema) {
2552
2583
  return `Provide your encrypted digest scheme data in the Authorization header when making requests to protected resources.
2553
2584
 
2554
- Example: \`Authorization: Digest username=guest, realm="test", nonce="2", uri="/uri", response="123"\``;
2585
+ Example: \`Authorization: Digest username=guest, realm="test", nonce="2", uri="/uri", response="123"\`${getSecuritySchemeRoles(schema)}`;
2555
2586
  }
2556
2587
  function getOAuthDescription(scheme) {
2557
2588
  const flows = keys(scheme.flows);
@@ -2574,6 +2605,11 @@ function getOAuthFlowDescription(title, flow) {
2574
2605
  ${scopes.map(([key, value]) => `- \`${key}\` - ${value}`).join('\n')}`;
2575
2606
  }
2576
2607
  return description;
2608
+ }
2609
+ function getSecuritySchemeRoles(scheme) {
2610
+ var _a;
2611
+ const scopes = (_a = scheme.extensions) === null || _a === void 0 ? void 0 : _a['x-scopes'];
2612
+ return Array.isArray(scopes) ? `\n\nRoles: ${scopes.map(scope => `\`${scope}\``).join(', ')}` : '';
2577
2613
  }
2578
2614
 
2579
2615
  const PanelContent = ({ schemes }) => {
@@ -2601,7 +2637,7 @@ const Body = ({ body, onChange }) => {
2601
2637
  var _a;
2602
2638
  const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
2603
2639
  const [chosenContent, setChosenContent] = React.useState(0);
2604
- const { nodeHasChanged } = useOptionsCtx();
2640
+ const { nodeHasChanged, renderExtensionAddon } = useOptionsCtx();
2605
2641
  React.useEffect(() => {
2606
2642
  onChange === null || onChange === void 0 ? void 0 : onChange(chosenContent);
2607
2643
  }, [chosenContent]);
@@ -2616,7 +2652,7 @@ const Body = ({ body, onChange }) => {
2616
2652
  description && (React.createElement(Box, { pos: "relative" },
2617
2653
  React.createElement(MarkdownViewer, { markdown: description }),
2618
2654
  React.createElement(NodeAnnotation, { change: descriptionChanged }))),
2619
- isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: "write", renderRootTreeLines: true, nodeHasChanged: nodeHasChanged }))));
2655
+ isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: "write", renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))));
2620
2656
  };
2621
2657
  Body.displayName = 'HttpOperation.Body';
2622
2658
 
@@ -2640,12 +2676,12 @@ const defaultStyle = {
2640
2676
  cookie: HttpParamStyles.Form,
2641
2677
  };
2642
2678
  const Parameters = ({ parameters, parameterType }) => {
2643
- const { nodeHasChanged } = useOptionsCtx();
2679
+ const { nodeHasChanged, renderExtensionAddon } = useOptionsCtx();
2644
2680
  const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
2645
2681
  const schema = React.useMemo(() => httpOperationParamsToSchema({ parameters, parameterType }), [parameters, parameterType]);
2646
2682
  if (!schema)
2647
2683
  return null;
2648
- return (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: schema, disableCrumbs: true, nodeHasChanged: nodeHasChanged }));
2684
+ return (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: schema, disableCrumbs: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }));
2649
2685
  };
2650
2686
  Parameters.displayName = 'HttpOperation.Parameters';
2651
2687
  const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
@@ -2785,7 +2821,7 @@ const Response = ({ response, onMediaTypeChange }) => {
2785
2821
  const { contents = [], headers = [], description } = response;
2786
2822
  const [chosenContent, setChosenContent] = React.useState(0);
2787
2823
  const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
2788
- const { nodeHasChanged } = useOptionsCtx();
2824
+ const { nodeHasChanged, renderExtensionAddon } = useOptionsCtx();
2789
2825
  const responseContent = contents[chosenContent];
2790
2826
  const schema = responseContent === null || responseContent === void 0 ? void 0 : responseContent.schema;
2791
2827
  React.useEffect(() => {
@@ -2803,7 +2839,7 @@ const Response = ({ response, onMediaTypeChange }) => {
2803
2839
  React.createElement(SectionSubtitle, { title: "Body", id: "response-body" },
2804
2840
  React.createElement(Flex, { flex: 1, justify: "end" },
2805
2841
  React.createElement(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" }))),
2806
- schema && (React.createElement(JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, maxRefDepth: maxRefDepth, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true, nodeHasChanged: nodeHasChanged }))))));
2842
+ schema && (React.createElement(JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, maxRefDepth: maxRefDepth, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))))));
2807
2843
  };
2808
2844
  Response.displayName = 'HttpOperation.Response';
2809
2845
  const codeToIntentVal = (code) => {
@@ -2879,6 +2915,7 @@ const HttpOperationComponent = React.memo(({ className, data: unresolvedData, la
2879
2915
  data.description && (React.createElement(Box, { pos: "relative" },
2880
2916
  React.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
2881
2917
  React.createElement(NodeAnnotation, { change: descriptionChanged }))),
2918
+ React.createElement(NodeVendorExtensions, { data: data }),
2882
2919
  React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data }),
2883
2920
  data.responses && (React.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact })),
2884
2921
  ((_a = data.callbacks) === null || _a === void 0 ? void 0 : _a.length) ? React.createElement(Callbacks, { callbacks: data.callbacks, isCompact: isCompact }) : null,
@@ -3130,7 +3167,7 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
3130
3167
  var _a, _b;
3131
3168
  const [resolveRef, maxRefDepth] = useSchemaInlineRefResolver();
3132
3169
  const data = useResolvedObject(unresolvedData);
3133
- const { nodeHasChanged } = useOptionsCtx();
3170
+ const { nodeHasChanged, renderExtensionAddon } = useOptionsCtx();
3134
3171
  const { ref: layoutRef, isCompact } = useIsCompact(layoutOptions);
3135
3172
  const nodeId = (_a = data === null || data === void 0 ? void 0 : data['x-stoplight']) === null || _a === void 0 ? void 0 : _a.id;
3136
3173
  const title = (_b = data.title) !== null && _b !== void 0 ? _b : nodeTitle;
@@ -3153,8 +3190,9 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
3153
3190
  data.description && data.type === 'object' && (React.createElement(Box, { pos: "relative" },
3154
3191
  React.createElement(MarkdownViewer, { role: "textbox", markdown: data.description }),
3155
3192
  React.createElement(NodeAnnotation, { change: descriptionChanged }))),
3193
+ React.createElement(NodeVendorExtensions, { data: data }),
3156
3194
  isCompact && modelExamples,
3157
- React.createElement(JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(data), nodeHasChanged: nodeHasChanged, skipTopLevelDescription: true })));
3195
+ React.createElement(JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(data), nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon, skipTopLevelDescription: true })));
3158
3196
  return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('Model', className), header: header, left: description, right: !isCompact && modelExamples }));
3159
3197
  };
3160
3198
  const ModelExamples = React.memo(({ data, isCollapsible = false }) => {
@@ -3177,7 +3215,7 @@ const Model = withErrorBoundary(ModelComponent, { recoverableProps: ['data'] });
3177
3215
 
3178
3216
  const Docs = React.memo((_a) => {
3179
3217
  var _b;
3180
- var { nodeType, nodeData, useNodeForRefResolving = false, refResolver, maxRefDepth, nodeHasChanged } = _a, commonProps = __rest(_a, ["nodeType", "nodeData", "useNodeForRefResolving", "refResolver", "maxRefDepth", "nodeHasChanged"]);
3218
+ var { nodeType, nodeData, useNodeForRefResolving = false, refResolver, maxRefDepth, nodeHasChanged, renderExtensionAddon } = _a, commonProps = __rest(_a, ["nodeType", "nodeData", "useNodeForRefResolving", "refResolver", "maxRefDepth", "nodeHasChanged", "renderExtensionAddon"]);
3181
3219
  const parsedNode = useParsedData(nodeType, nodeData);
3182
3220
  if (!parsedNode) {
3183
3221
  (_b = commonProps.nodeUnsupported) === null || _b === void 0 ? void 0 : _b.call(commonProps, 'dataEmpty');
@@ -3187,7 +3225,7 @@ const Docs = React.memo((_a) => {
3187
3225
  if (useNodeForRefResolving) {
3188
3226
  elem = (React.createElement(InlineRefResolverProvider, { document: parsedNode.data, resolver: refResolver, maxRefDepth: maxRefDepth }, elem));
3189
3227
  }
3190
- return React.createElement(ElementsOptionsProvider, { nodeHasChanged: nodeHasChanged }, elem);
3228
+ return (React.createElement(ElementsOptionsProvider, { nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }, elem));
3191
3229
  });
3192
3230
  const ParsedDocs = (_a) => {
3193
3231
  var { node, nodeUnsupported } = _a, commonProps = __rest(_a, ["node", "nodeUnsupported"]);
@@ -3293,6 +3331,9 @@ const NODE_META_COLOR = {
3293
3331
  put: 'warning',
3294
3332
  patch: 'warning',
3295
3333
  delete: 'danger',
3334
+ head: '#9061F9',
3335
+ options: '#0D5AA7',
3336
+ trace: '#0D0B28',
3296
3337
  };
3297
3338
 
3298
3339
  function getHtmlIdFromItemId(id) {
@@ -3646,12 +3687,13 @@ function isPartialHttpRequest(maybeHttpRequest) {
3646
3687
  }
3647
3688
  const SchemaAndDescription = ({ title: titleProp, schema }) => {
3648
3689
  const [resolveRef, maxRefDepth] = useSchemaInlineRefResolver();
3690
+ const { renderExtensionAddon } = useOptionsCtx();
3649
3691
  const title = titleProp !== null && titleProp !== void 0 ? titleProp : schema.title;
3650
3692
  return (React__default.createElement(Box, { py: 2 },
3651
3693
  title && (React__default.createElement(Flex, { alignItems: "center", p: 2 },
3652
3694
  React__default.createElement(Icon, { icon: NodeTypeIconDefs[NodeType.Model], color: NodeTypeColors[NodeType.Model] }),
3653
3695
  React__default.createElement(Box, { color: "muted", px: 2 }, title))),
3654
- React__default.createElement(JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema) })));
3696
+ React__default.createElement(JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), renderExtensionAddon: renderExtensionAddon })));
3655
3697
  };
3656
3698
  const CodeComponent = props => {
3657
3699
  const { title, jsonSchema, http, resolved, children } = props;
@@ -3996,4 +4038,4 @@ const createElementClass = (Component, propDescriptors) => {
3996
4038
  };
3997
4039
  };
3998
4040
 
3999
- export { DeprecatedBadge, Docs, ExportButton, HttpMethodColors, InlineRefResolverProvider, LinkHeading, Logo, MarkdownComponentsProvider, MockingProvider, NodeTypeColors, NodeTypeIconDefs, NodeTypePrettyName, NonIdealState, ParsedDocs, PersistenceContextProvider, PoweredByLink, ReactRouterMarkdownLink, ResponsiveSidebarLayout, RouterTypeContext, SidebarLayout, Styled, TableOfContents, TryIt, TryItWithRequestSamples, createElementClass, createResolvedObject, findFirstNode, isHttpOperation, isHttpService, isHttpWebhookOperation, slugify, useBundleRefsIntoDocument, useParsedData, useParsedValue, useResponsiveLayout, useRouter, withMosaicProvider, withPersistenceBoundary, withQueryClientProvider, withRouter, withStyles };
4041
+ export { DeprecatedBadge, Docs, ElementsOptionsProvider, ExportButton, HttpMethodColors, InlineRefResolverProvider, LinkHeading, Logo, MarkdownComponentsProvider, MockingProvider, NodeTypeColors, NodeTypeIconDefs, NodeTypePrettyName, NonIdealState, ParsedDocs, PersistenceContextProvider, PoweredByLink, ReactRouterMarkdownLink, ResponsiveSidebarLayout, RouterTypeContext, SidebarLayout, Styled, TableOfContents, TryIt, TryItWithRequestSamples, createElementClass, createResolvedObject, findFirstNode, isHttpOperation, isHttpService, isHttpWebhookOperation, slugify, useBundleRefsIntoDocument, useParsedData, useParsedValue, useResponsiveLayout, useRouter, withMosaicProvider, withPersistenceBoundary, withQueryClientProvider, withRouter, withStyles };
package/index.js CHANGED
@@ -46,6 +46,7 @@ var uniq = require('lodash/uniq.js');
46
46
  var orderBy = require('lodash/orderBy.js');
47
47
  var uniqBy = require('lodash/uniqBy.js');
48
48
  var formatXml = require('xml-formatter');
49
+ var memoize = require('lodash/memoize.js');
49
50
  var entries = require('lodash/entries.js');
50
51
  var keys = require('lodash/keys.js');
51
52
  var sortBy = require('lodash/sortBy.js');
@@ -106,6 +107,7 @@ var uniq__default = /*#__PURE__*/_interopDefaultLegacy(uniq);
106
107
  var orderBy__default = /*#__PURE__*/_interopDefaultLegacy(orderBy);
107
108
  var uniqBy__default = /*#__PURE__*/_interopDefaultLegacy(uniqBy);
108
109
  var formatXml__default = /*#__PURE__*/_interopDefaultLegacy(formatXml);
110
+ var memoize__default = /*#__PURE__*/_interopDefaultLegacy(memoize);
109
111
  var entries__default = /*#__PURE__*/_interopDefaultLegacy(entries);
110
112
  var keys__default = /*#__PURE__*/_interopDefaultLegacy(keys);
111
113
  var sortBy__default = /*#__PURE__*/_interopDefaultLegacy(sortBy);
@@ -224,8 +226,8 @@ const ElementsOptionsContext = React__namespace.createContext(DEFAULT_CONTEXT);
224
226
  const useOptionsCtx = () => {
225
227
  return React__namespace.useContext(ElementsOptionsContext) || DEFAULT_CONTEXT;
226
228
  };
227
- function ElementsOptionsProvider({ children, nodeHasChanged }) {
228
- return (React__namespace.createElement(ElementsOptionsContext.Provider, { value: Object.assign({}, DEFAULT_CONTEXT, { nodeHasChanged }) }, children));
229
+ function ElementsOptionsProvider({ children, nodeHasChanged, renderExtensionAddon }) {
230
+ return (React__namespace.createElement(ElementsOptionsContext.Provider, { value: Object.assign({}, DEFAULT_CONTEXT, { nodeHasChanged, renderExtensionAddon }) }, children));
229
231
  }
230
232
 
231
233
  function isSMDASTRoot(maybeAst) {
@@ -510,6 +512,9 @@ const HttpMethodColors = {
510
512
  put: 'warning',
511
513
  patch: 'warning',
512
514
  delete: 'danger',
515
+ head: '#9061F9',
516
+ options: '#0D5AA7',
517
+ trace: '#0D0B28',
513
518
  };
514
519
  const HttpCodeColor = {
515
520
  0: 'red',
@@ -2504,6 +2509,32 @@ const TryItWithRequestSamples = (_a) => {
2504
2509
  React__namespace.createElement(ResponseExamples, Object.assign({}, props))));
2505
2510
  };
2506
2511
 
2512
+ const getVendorExtensions = memoize__default["default"]((data) => {
2513
+ const vendorExtensionNames = Object.keys(data).filter(item => item.startsWith('x-'));
2514
+ const vendorExtensions = vendorExtensionNames.reduce((previousValue, currentValue, currentIndex) => {
2515
+ return Object.assign(Object.assign({}, previousValue), { [currentValue]: data[currentValue] });
2516
+ }, {});
2517
+ return vendorExtensions;
2518
+ });
2519
+ const NodeVendorExtensions = React__namespace.memo(({ data }) => {
2520
+ const { renderExtensionAddon } = useOptionsCtx();
2521
+ if (!renderExtensionAddon) {
2522
+ return null;
2523
+ }
2524
+ const originalObject = getOriginalObject(data);
2525
+ const vendorExtensions = originalObject.extensions ? originalObject.extensions : getVendorExtensions(originalObject);
2526
+ const vendorExtensionKeys = Object.keys(vendorExtensions);
2527
+ if (vendorExtensionKeys.length === 0) {
2528
+ return null;
2529
+ }
2530
+ return (React__namespace.createElement(React__namespace.Fragment, null, renderExtensionAddon({
2531
+ nestingLevel: -1,
2532
+ schemaNode: originalObject,
2533
+ vendorExtensions,
2534
+ })));
2535
+ });
2536
+ NodeVendorExtensions.displayName = 'NodeVendorExtensions';
2537
+
2507
2538
  const TwoColumnLayout = React__default["default"].forwardRef(({ header, right, left, className }, ref) => (React__default["default"].createElement(mosaic.VStack, { ref: ref, w: "full", className: className, spacing: 8 },
2508
2539
  header,
2509
2540
  React__default["default"].createElement(mosaic.Flex, null,
@@ -2576,42 +2607,43 @@ const oauthFlowNames = {
2576
2607
  function getDefaultDescription(scheme) {
2577
2608
  switch (scheme.type) {
2578
2609
  case 'apiKey':
2579
- return getApiKeyDescription(scheme.in, scheme.name);
2610
+ return getApiKeyDescription(scheme);
2580
2611
  case 'http':
2581
2612
  switch (scheme.scheme) {
2582
2613
  case 'basic':
2583
- return getBasicAuthDescription();
2614
+ return getBasicAuthDescription(scheme);
2584
2615
  case 'bearer':
2585
- return getBearerAuthDescription();
2616
+ return getBearerAuthDescription(scheme);
2586
2617
  case 'digest':
2587
- return getDigestAuthDescription();
2618
+ return getDigestAuthDescription(scheme);
2588
2619
  }
2589
2620
  case 'oauth2':
2590
2621
  return getOAuthDescription(scheme);
2591
2622
  }
2592
2623
  return '';
2593
2624
  }
2594
- function getApiKeyDescription(inProperty, name) {
2625
+ function getApiKeyDescription(scheme) {
2626
+ const { in: inProperty, name } = scheme;
2595
2627
  return `An API key is a token that you provide when making API calls. Include the token in a ${inProperty} parameter called \`${name}\`.
2596
2628
 
2597
- Example: ${inProperty === 'query' ? `\`?${name}=123\`` : `\`${name}: 123\``}`;
2629
+ Example: ${inProperty === 'query' ? `\`?${name}=123\`` : `\`${name}: 123\``}${getSecuritySchemeRoles(scheme)}`;
2598
2630
  }
2599
- function getBasicAuthDescription() {
2631
+ function getBasicAuthDescription(schema) {
2600
2632
  return `Basic authentication is a simple authentication scheme built into the HTTP protocol.
2601
2633
  To use it, send your HTTP requests with an Authorization header that contains the word Basic
2602
2634
  followed by a space and a base64-encoded string \`username:password\`.
2603
2635
 
2604
- Example: \`Authorization: Basic ZGVtbzpwQDU1dzByZA==\``;
2636
+ Example: \`Authorization: Basic ZGVtbzpwQDU1dzByZA==\`${getSecuritySchemeRoles(schema)}`;
2605
2637
  }
2606
- function getBearerAuthDescription() {
2638
+ function getBearerAuthDescription(schema) {
2607
2639
  return `Provide your bearer token in the Authorization header when making requests to protected resources.
2608
2640
 
2609
- Example: \`Authorization: Bearer 123\``;
2641
+ Example: \`Authorization: Bearer 123\`${getSecuritySchemeRoles(schema)}`;
2610
2642
  }
2611
- function getDigestAuthDescription() {
2643
+ function getDigestAuthDescription(schema) {
2612
2644
  return `Provide your encrypted digest scheme data in the Authorization header when making requests to protected resources.
2613
2645
 
2614
- Example: \`Authorization: Digest username=guest, realm="test", nonce="2", uri="/uri", response="123"\``;
2646
+ Example: \`Authorization: Digest username=guest, realm="test", nonce="2", uri="/uri", response="123"\`${getSecuritySchemeRoles(schema)}`;
2615
2647
  }
2616
2648
  function getOAuthDescription(scheme) {
2617
2649
  const flows = keys__default["default"](scheme.flows);
@@ -2634,6 +2666,11 @@ function getOAuthFlowDescription(title, flow) {
2634
2666
  ${scopes.map(([key, value]) => `- \`${key}\` - ${value}`).join('\n')}`;
2635
2667
  }
2636
2668
  return description;
2669
+ }
2670
+ function getSecuritySchemeRoles(scheme) {
2671
+ var _a;
2672
+ const scopes = (_a = scheme.extensions) === null || _a === void 0 ? void 0 : _a['x-scopes'];
2673
+ return Array.isArray(scopes) ? `\n\nRoles: ${scopes.map(scope => `\`${scope}\``).join(', ')}` : '';
2637
2674
  }
2638
2675
 
2639
2676
  const PanelContent = ({ schemes }) => {
@@ -2661,7 +2698,7 @@ const Body = ({ body, onChange }) => {
2661
2698
  var _a;
2662
2699
  const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
2663
2700
  const [chosenContent, setChosenContent] = React__namespace.useState(0);
2664
- const { nodeHasChanged } = useOptionsCtx();
2701
+ const { nodeHasChanged, renderExtensionAddon } = useOptionsCtx();
2665
2702
  React__namespace.useEffect(() => {
2666
2703
  onChange === null || onChange === void 0 ? void 0 : onChange(chosenContent);
2667
2704
  }, [chosenContent]);
@@ -2676,7 +2713,7 @@ const Body = ({ body, onChange }) => {
2676
2713
  description && (React__namespace.createElement(mosaic.Box, { pos: "relative" },
2677
2714
  React__namespace.createElement(MarkdownViewer, { markdown: description }),
2678
2715
  React__namespace.createElement(mosaic.NodeAnnotation, { change: descriptionChanged }))),
2679
- isJSONSchema(schema) && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: "write", renderRootTreeLines: true, nodeHasChanged: nodeHasChanged }))));
2716
+ isJSONSchema(schema) && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: "write", renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))));
2680
2717
  };
2681
2718
  Body.displayName = 'HttpOperation.Body';
2682
2719
 
@@ -2700,12 +2737,12 @@ const defaultStyle = {
2700
2737
  cookie: types.HttpParamStyles.Form,
2701
2738
  };
2702
2739
  const Parameters = ({ parameters, parameterType }) => {
2703
- const { nodeHasChanged } = useOptionsCtx();
2740
+ const { nodeHasChanged, renderExtensionAddon } = useOptionsCtx();
2704
2741
  const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
2705
2742
  const schema = React__namespace.useMemo(() => httpOperationParamsToSchema({ parameters, parameterType }), [parameters, parameterType]);
2706
2743
  if (!schema)
2707
2744
  return null;
2708
- return (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: schema, disableCrumbs: true, nodeHasChanged: nodeHasChanged }));
2745
+ return (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: schema, disableCrumbs: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }));
2709
2746
  };
2710
2747
  Parameters.displayName = 'HttpOperation.Parameters';
2711
2748
  const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
@@ -2845,7 +2882,7 @@ const Response = ({ response, onMediaTypeChange }) => {
2845
2882
  const { contents = [], headers = [], description } = response;
2846
2883
  const [chosenContent, setChosenContent] = React__namespace.useState(0);
2847
2884
  const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
2848
- const { nodeHasChanged } = useOptionsCtx();
2885
+ const { nodeHasChanged, renderExtensionAddon } = useOptionsCtx();
2849
2886
  const responseContent = contents[chosenContent];
2850
2887
  const schema = responseContent === null || responseContent === void 0 ? void 0 : responseContent.schema;
2851
2888
  React__namespace.useEffect(() => {
@@ -2863,7 +2900,7 @@ const Response = ({ response, onMediaTypeChange }) => {
2863
2900
  React__namespace.createElement(SectionSubtitle, { title: "Body", id: "response-body" },
2864
2901
  React__namespace.createElement(mosaic.Flex, { flex: 1, justify: "end" },
2865
2902
  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" }))),
2866
- schema && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, maxRefDepth: maxRefDepth, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true, nodeHasChanged: nodeHasChanged }))))));
2903
+ schema && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, maxRefDepth: maxRefDepth, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))))));
2867
2904
  };
2868
2905
  Response.displayName = 'HttpOperation.Response';
2869
2906
  const codeToIntentVal = (code) => {
@@ -2939,6 +2976,7 @@ const HttpOperationComponent = React__namespace.memo(({ className, data: unresol
2939
2976
  data.description && (React__namespace.createElement(mosaic.Box, { pos: "relative" },
2940
2977
  React__namespace.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
2941
2978
  React__namespace.createElement(mosaic.NodeAnnotation, { change: descriptionChanged }))),
2979
+ React__namespace.createElement(NodeVendorExtensions, { data: data }),
2942
2980
  React__namespace.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data }),
2943
2981
  data.responses && (React__namespace.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact })),
2944
2982
  ((_a = data.callbacks) === null || _a === void 0 ? void 0 : _a.length) ? React__namespace.createElement(Callbacks, { callbacks: data.callbacks, isCompact: isCompact }) : null,
@@ -3190,7 +3228,7 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
3190
3228
  var _a, _b;
3191
3229
  const [resolveRef, maxRefDepth] = useSchemaInlineRefResolver();
3192
3230
  const data = useResolvedObject(unresolvedData);
3193
- const { nodeHasChanged } = useOptionsCtx();
3231
+ const { nodeHasChanged, renderExtensionAddon } = useOptionsCtx();
3194
3232
  const { ref: layoutRef, isCompact } = useIsCompact(layoutOptions);
3195
3233
  const nodeId = (_a = data === null || data === void 0 ? void 0 : data['x-stoplight']) === null || _a === void 0 ? void 0 : _a.id;
3196
3234
  const title = (_b = data.title) !== null && _b !== void 0 ? _b : nodeTitle;
@@ -3213,8 +3251,9 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
3213
3251
  data.description && data.type === 'object' && (React__namespace.createElement(mosaic.Box, { pos: "relative" },
3214
3252
  React__namespace.createElement(MarkdownViewer, { role: "textbox", markdown: data.description }),
3215
3253
  React__namespace.createElement(mosaic.NodeAnnotation, { change: descriptionChanged }))),
3254
+ React__namespace.createElement(NodeVendorExtensions, { data: data }),
3216
3255
  isCompact && modelExamples,
3217
- React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(data), nodeHasChanged: nodeHasChanged, skipTopLevelDescription: true })));
3256
+ React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(data), nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon, skipTopLevelDescription: true })));
3218
3257
  return (React__namespace.createElement(TwoColumnLayout, { ref: layoutRef, className: cn__default["default"]('Model', className), header: header, left: description, right: !isCompact && modelExamples }));
3219
3258
  };
3220
3259
  const ModelExamples = React__namespace.memo(({ data, isCollapsible = false }) => {
@@ -3237,7 +3276,7 @@ const Model = reactErrorBoundary.withErrorBoundary(ModelComponent, { recoverable
3237
3276
 
3238
3277
  const Docs = React__namespace.memo((_a) => {
3239
3278
  var _b;
3240
- var { nodeType, nodeData, useNodeForRefResolving = false, refResolver, maxRefDepth, nodeHasChanged } = _a, commonProps = tslib.__rest(_a, ["nodeType", "nodeData", "useNodeForRefResolving", "refResolver", "maxRefDepth", "nodeHasChanged"]);
3279
+ var { nodeType, nodeData, useNodeForRefResolving = false, refResolver, maxRefDepth, nodeHasChanged, renderExtensionAddon } = _a, commonProps = tslib.__rest(_a, ["nodeType", "nodeData", "useNodeForRefResolving", "refResolver", "maxRefDepth", "nodeHasChanged", "renderExtensionAddon"]);
3241
3280
  const parsedNode = useParsedData(nodeType, nodeData);
3242
3281
  if (!parsedNode) {
3243
3282
  (_b = commonProps.nodeUnsupported) === null || _b === void 0 ? void 0 : _b.call(commonProps, 'dataEmpty');
@@ -3247,7 +3286,7 @@ const Docs = React__namespace.memo((_a) => {
3247
3286
  if (useNodeForRefResolving) {
3248
3287
  elem = (React__namespace.createElement(InlineRefResolverProvider, { document: parsedNode.data, resolver: refResolver, maxRefDepth: maxRefDepth }, elem));
3249
3288
  }
3250
- return React__namespace.createElement(ElementsOptionsProvider, { nodeHasChanged: nodeHasChanged }, elem);
3289
+ return (React__namespace.createElement(ElementsOptionsProvider, { nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }, elem));
3251
3290
  });
3252
3291
  const ParsedDocs = (_a) => {
3253
3292
  var { node, nodeUnsupported } = _a, commonProps = tslib.__rest(_a, ["node", "nodeUnsupported"]);
@@ -3353,6 +3392,9 @@ const NODE_META_COLOR = {
3353
3392
  put: 'warning',
3354
3393
  patch: 'warning',
3355
3394
  delete: 'danger',
3395
+ head: '#9061F9',
3396
+ options: '#0D5AA7',
3397
+ trace: '#0D0B28',
3356
3398
  };
3357
3399
 
3358
3400
  function getHtmlIdFromItemId(id) {
@@ -3706,12 +3748,13 @@ function isPartialHttpRequest(maybeHttpRequest) {
3706
3748
  }
3707
3749
  const SchemaAndDescription = ({ title: titleProp, schema }) => {
3708
3750
  const [resolveRef, maxRefDepth] = useSchemaInlineRefResolver();
3751
+ const { renderExtensionAddon } = useOptionsCtx();
3709
3752
  const title = titleProp !== null && titleProp !== void 0 ? titleProp : schema.title;
3710
3753
  return (React__default["default"].createElement(mosaic.Box, { py: 2 },
3711
3754
  title && (React__default["default"].createElement(mosaic.Flex, { alignItems: "center", p: 2 },
3712
3755
  React__default["default"].createElement(mosaic.Icon, { icon: NodeTypeIconDefs[types.NodeType.Model], color: NodeTypeColors[types.NodeType.Model] }),
3713
3756
  React__default["default"].createElement(mosaic.Box, { color: "muted", px: 2 }, title))),
3714
- React__default["default"].createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema) })));
3757
+ React__default["default"].createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), renderExtensionAddon: renderExtensionAddon })));
3715
3758
  };
3716
3759
  const CodeComponent = props => {
3717
3760
  const { title, jsonSchema, http, resolved, children } = props;
@@ -4062,6 +4105,7 @@ Object.defineProperty(exports, 'DefaultSMDComponents', {
4062
4105
  });
4063
4106
  exports.DeprecatedBadge = DeprecatedBadge;
4064
4107
  exports.Docs = Docs;
4108
+ exports.ElementsOptionsProvider = ElementsOptionsProvider;
4065
4109
  exports.ExportButton = ExportButton;
4066
4110
  exports.HttpMethodColors = HttpMethodColors;
4067
4111
  exports.InlineRefResolverProvider = InlineRefResolverProvider;
package/index.mjs CHANGED
@@ -44,6 +44,7 @@ import uniq from 'lodash/uniq.js';
44
44
  import orderBy from 'lodash/orderBy.js';
45
45
  import uniqBy from 'lodash/uniqBy.js';
46
46
  import formatXml from 'xml-formatter';
47
+ import memoize from 'lodash/memoize.js';
47
48
  import entries from 'lodash/entries.js';
48
49
  import keys from 'lodash/keys.js';
49
50
  import sortBy from 'lodash/sortBy.js';
@@ -164,8 +165,8 @@ const ElementsOptionsContext = React.createContext(DEFAULT_CONTEXT);
164
165
  const useOptionsCtx = () => {
165
166
  return React.useContext(ElementsOptionsContext) || DEFAULT_CONTEXT;
166
167
  };
167
- function ElementsOptionsProvider({ children, nodeHasChanged }) {
168
- return (React.createElement(ElementsOptionsContext.Provider, { value: Object.assign({}, DEFAULT_CONTEXT, { nodeHasChanged }) }, children));
168
+ function ElementsOptionsProvider({ children, nodeHasChanged, renderExtensionAddon }) {
169
+ return (React.createElement(ElementsOptionsContext.Provider, { value: Object.assign({}, DEFAULT_CONTEXT, { nodeHasChanged, renderExtensionAddon }) }, children));
169
170
  }
170
171
 
171
172
  function isSMDASTRoot(maybeAst) {
@@ -450,6 +451,9 @@ const HttpMethodColors = {
450
451
  put: 'warning',
451
452
  patch: 'warning',
452
453
  delete: 'danger',
454
+ head: '#9061F9',
455
+ options: '#0D5AA7',
456
+ trace: '#0D0B28',
453
457
  };
454
458
  const HttpCodeColor = {
455
459
  0: 'red',
@@ -2444,6 +2448,32 @@ const TryItWithRequestSamples = (_a) => {
2444
2448
  React.createElement(ResponseExamples, Object.assign({}, props))));
2445
2449
  };
2446
2450
 
2451
+ const getVendorExtensions = memoize((data) => {
2452
+ const vendorExtensionNames = Object.keys(data).filter(item => item.startsWith('x-'));
2453
+ const vendorExtensions = vendorExtensionNames.reduce((previousValue, currentValue, currentIndex) => {
2454
+ return Object.assign(Object.assign({}, previousValue), { [currentValue]: data[currentValue] });
2455
+ }, {});
2456
+ return vendorExtensions;
2457
+ });
2458
+ const NodeVendorExtensions = React.memo(({ data }) => {
2459
+ const { renderExtensionAddon } = useOptionsCtx();
2460
+ if (!renderExtensionAddon) {
2461
+ return null;
2462
+ }
2463
+ const originalObject = getOriginalObject(data);
2464
+ const vendorExtensions = originalObject.extensions ? originalObject.extensions : getVendorExtensions(originalObject);
2465
+ const vendorExtensionKeys = Object.keys(vendorExtensions);
2466
+ if (vendorExtensionKeys.length === 0) {
2467
+ return null;
2468
+ }
2469
+ return (React.createElement(React.Fragment, null, renderExtensionAddon({
2470
+ nestingLevel: -1,
2471
+ schemaNode: originalObject,
2472
+ vendorExtensions,
2473
+ })));
2474
+ });
2475
+ NodeVendorExtensions.displayName = 'NodeVendorExtensions';
2476
+
2447
2477
  const TwoColumnLayout = React__default.forwardRef(({ header, right, left, className }, ref) => (React__default.createElement(VStack, { ref: ref, w: "full", className: className, spacing: 8 },
2448
2478
  header,
2449
2479
  React__default.createElement(Flex, null,
@@ -2516,42 +2546,43 @@ const oauthFlowNames = {
2516
2546
  function getDefaultDescription(scheme) {
2517
2547
  switch (scheme.type) {
2518
2548
  case 'apiKey':
2519
- return getApiKeyDescription(scheme.in, scheme.name);
2549
+ return getApiKeyDescription(scheme);
2520
2550
  case 'http':
2521
2551
  switch (scheme.scheme) {
2522
2552
  case 'basic':
2523
- return getBasicAuthDescription();
2553
+ return getBasicAuthDescription(scheme);
2524
2554
  case 'bearer':
2525
- return getBearerAuthDescription();
2555
+ return getBearerAuthDescription(scheme);
2526
2556
  case 'digest':
2527
- return getDigestAuthDescription();
2557
+ return getDigestAuthDescription(scheme);
2528
2558
  }
2529
2559
  case 'oauth2':
2530
2560
  return getOAuthDescription(scheme);
2531
2561
  }
2532
2562
  return '';
2533
2563
  }
2534
- function getApiKeyDescription(inProperty, name) {
2564
+ function getApiKeyDescription(scheme) {
2565
+ const { in: inProperty, name } = scheme;
2535
2566
  return `An API key is a token that you provide when making API calls. Include the token in a ${inProperty} parameter called \`${name}\`.
2536
2567
 
2537
- Example: ${inProperty === 'query' ? `\`?${name}=123\`` : `\`${name}: 123\``}`;
2568
+ Example: ${inProperty === 'query' ? `\`?${name}=123\`` : `\`${name}: 123\``}${getSecuritySchemeRoles(scheme)}`;
2538
2569
  }
2539
- function getBasicAuthDescription() {
2570
+ function getBasicAuthDescription(schema) {
2540
2571
  return `Basic authentication is a simple authentication scheme built into the HTTP protocol.
2541
2572
  To use it, send your HTTP requests with an Authorization header that contains the word Basic
2542
2573
  followed by a space and a base64-encoded string \`username:password\`.
2543
2574
 
2544
- Example: \`Authorization: Basic ZGVtbzpwQDU1dzByZA==\``;
2575
+ Example: \`Authorization: Basic ZGVtbzpwQDU1dzByZA==\`${getSecuritySchemeRoles(schema)}`;
2545
2576
  }
2546
- function getBearerAuthDescription() {
2577
+ function getBearerAuthDescription(schema) {
2547
2578
  return `Provide your bearer token in the Authorization header when making requests to protected resources.
2548
2579
 
2549
- Example: \`Authorization: Bearer 123\``;
2580
+ Example: \`Authorization: Bearer 123\`${getSecuritySchemeRoles(schema)}`;
2550
2581
  }
2551
- function getDigestAuthDescription() {
2582
+ function getDigestAuthDescription(schema) {
2552
2583
  return `Provide your encrypted digest scheme data in the Authorization header when making requests to protected resources.
2553
2584
 
2554
- Example: \`Authorization: Digest username=guest, realm="test", nonce="2", uri="/uri", response="123"\``;
2585
+ Example: \`Authorization: Digest username=guest, realm="test", nonce="2", uri="/uri", response="123"\`${getSecuritySchemeRoles(schema)}`;
2555
2586
  }
2556
2587
  function getOAuthDescription(scheme) {
2557
2588
  const flows = keys(scheme.flows);
@@ -2574,6 +2605,11 @@ function getOAuthFlowDescription(title, flow) {
2574
2605
  ${scopes.map(([key, value]) => `- \`${key}\` - ${value}`).join('\n')}`;
2575
2606
  }
2576
2607
  return description;
2608
+ }
2609
+ function getSecuritySchemeRoles(scheme) {
2610
+ var _a;
2611
+ const scopes = (_a = scheme.extensions) === null || _a === void 0 ? void 0 : _a['x-scopes'];
2612
+ return Array.isArray(scopes) ? `\n\nRoles: ${scopes.map(scope => `\`${scope}\``).join(', ')}` : '';
2577
2613
  }
2578
2614
 
2579
2615
  const PanelContent = ({ schemes }) => {
@@ -2601,7 +2637,7 @@ const Body = ({ body, onChange }) => {
2601
2637
  var _a;
2602
2638
  const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
2603
2639
  const [chosenContent, setChosenContent] = React.useState(0);
2604
- const { nodeHasChanged } = useOptionsCtx();
2640
+ const { nodeHasChanged, renderExtensionAddon } = useOptionsCtx();
2605
2641
  React.useEffect(() => {
2606
2642
  onChange === null || onChange === void 0 ? void 0 : onChange(chosenContent);
2607
2643
  }, [chosenContent]);
@@ -2616,7 +2652,7 @@ const Body = ({ body, onChange }) => {
2616
2652
  description && (React.createElement(Box, { pos: "relative" },
2617
2653
  React.createElement(MarkdownViewer, { markdown: description }),
2618
2654
  React.createElement(NodeAnnotation, { change: descriptionChanged }))),
2619
- isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: "write", renderRootTreeLines: true, nodeHasChanged: nodeHasChanged }))));
2655
+ isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: "write", renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))));
2620
2656
  };
2621
2657
  Body.displayName = 'HttpOperation.Body';
2622
2658
 
@@ -2640,12 +2676,12 @@ const defaultStyle = {
2640
2676
  cookie: HttpParamStyles.Form,
2641
2677
  };
2642
2678
  const Parameters = ({ parameters, parameterType }) => {
2643
- const { nodeHasChanged } = useOptionsCtx();
2679
+ const { nodeHasChanged, renderExtensionAddon } = useOptionsCtx();
2644
2680
  const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
2645
2681
  const schema = React.useMemo(() => httpOperationParamsToSchema({ parameters, parameterType }), [parameters, parameterType]);
2646
2682
  if (!schema)
2647
2683
  return null;
2648
- return (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: schema, disableCrumbs: true, nodeHasChanged: nodeHasChanged }));
2684
+ return (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: schema, disableCrumbs: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }));
2649
2685
  };
2650
2686
  Parameters.displayName = 'HttpOperation.Parameters';
2651
2687
  const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
@@ -2785,7 +2821,7 @@ const Response = ({ response, onMediaTypeChange }) => {
2785
2821
  const { contents = [], headers = [], description } = response;
2786
2822
  const [chosenContent, setChosenContent] = React.useState(0);
2787
2823
  const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
2788
- const { nodeHasChanged } = useOptionsCtx();
2824
+ const { nodeHasChanged, renderExtensionAddon } = useOptionsCtx();
2789
2825
  const responseContent = contents[chosenContent];
2790
2826
  const schema = responseContent === null || responseContent === void 0 ? void 0 : responseContent.schema;
2791
2827
  React.useEffect(() => {
@@ -2803,7 +2839,7 @@ const Response = ({ response, onMediaTypeChange }) => {
2803
2839
  React.createElement(SectionSubtitle, { title: "Body", id: "response-body" },
2804
2840
  React.createElement(Flex, { flex: 1, justify: "end" },
2805
2841
  React.createElement(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" }))),
2806
- schema && (React.createElement(JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, maxRefDepth: maxRefDepth, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true, nodeHasChanged: nodeHasChanged }))))));
2842
+ schema && (React.createElement(JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, maxRefDepth: maxRefDepth, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))))));
2807
2843
  };
2808
2844
  Response.displayName = 'HttpOperation.Response';
2809
2845
  const codeToIntentVal = (code) => {
@@ -2879,6 +2915,7 @@ const HttpOperationComponent = React.memo(({ className, data: unresolvedData, la
2879
2915
  data.description && (React.createElement(Box, { pos: "relative" },
2880
2916
  React.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
2881
2917
  React.createElement(NodeAnnotation, { change: descriptionChanged }))),
2918
+ React.createElement(NodeVendorExtensions, { data: data }),
2882
2919
  React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data }),
2883
2920
  data.responses && (React.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact })),
2884
2921
  ((_a = data.callbacks) === null || _a === void 0 ? void 0 : _a.length) ? React.createElement(Callbacks, { callbacks: data.callbacks, isCompact: isCompact }) : null,
@@ -3130,7 +3167,7 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
3130
3167
  var _a, _b;
3131
3168
  const [resolveRef, maxRefDepth] = useSchemaInlineRefResolver();
3132
3169
  const data = useResolvedObject(unresolvedData);
3133
- const { nodeHasChanged } = useOptionsCtx();
3170
+ const { nodeHasChanged, renderExtensionAddon } = useOptionsCtx();
3134
3171
  const { ref: layoutRef, isCompact } = useIsCompact(layoutOptions);
3135
3172
  const nodeId = (_a = data === null || data === void 0 ? void 0 : data['x-stoplight']) === null || _a === void 0 ? void 0 : _a.id;
3136
3173
  const title = (_b = data.title) !== null && _b !== void 0 ? _b : nodeTitle;
@@ -3153,8 +3190,9 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
3153
3190
  data.description && data.type === 'object' && (React.createElement(Box, { pos: "relative" },
3154
3191
  React.createElement(MarkdownViewer, { role: "textbox", markdown: data.description }),
3155
3192
  React.createElement(NodeAnnotation, { change: descriptionChanged }))),
3193
+ React.createElement(NodeVendorExtensions, { data: data }),
3156
3194
  isCompact && modelExamples,
3157
- React.createElement(JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(data), nodeHasChanged: nodeHasChanged, skipTopLevelDescription: true })));
3195
+ React.createElement(JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(data), nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon, skipTopLevelDescription: true })));
3158
3196
  return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('Model', className), header: header, left: description, right: !isCompact && modelExamples }));
3159
3197
  };
3160
3198
  const ModelExamples = React.memo(({ data, isCollapsible = false }) => {
@@ -3177,7 +3215,7 @@ const Model = withErrorBoundary(ModelComponent, { recoverableProps: ['data'] });
3177
3215
 
3178
3216
  const Docs = React.memo((_a) => {
3179
3217
  var _b;
3180
- var { nodeType, nodeData, useNodeForRefResolving = false, refResolver, maxRefDepth, nodeHasChanged } = _a, commonProps = __rest(_a, ["nodeType", "nodeData", "useNodeForRefResolving", "refResolver", "maxRefDepth", "nodeHasChanged"]);
3218
+ var { nodeType, nodeData, useNodeForRefResolving = false, refResolver, maxRefDepth, nodeHasChanged, renderExtensionAddon } = _a, commonProps = __rest(_a, ["nodeType", "nodeData", "useNodeForRefResolving", "refResolver", "maxRefDepth", "nodeHasChanged", "renderExtensionAddon"]);
3181
3219
  const parsedNode = useParsedData(nodeType, nodeData);
3182
3220
  if (!parsedNode) {
3183
3221
  (_b = commonProps.nodeUnsupported) === null || _b === void 0 ? void 0 : _b.call(commonProps, 'dataEmpty');
@@ -3187,7 +3225,7 @@ const Docs = React.memo((_a) => {
3187
3225
  if (useNodeForRefResolving) {
3188
3226
  elem = (React.createElement(InlineRefResolverProvider, { document: parsedNode.data, resolver: refResolver, maxRefDepth: maxRefDepth }, elem));
3189
3227
  }
3190
- return React.createElement(ElementsOptionsProvider, { nodeHasChanged: nodeHasChanged }, elem);
3228
+ return (React.createElement(ElementsOptionsProvider, { nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }, elem));
3191
3229
  });
3192
3230
  const ParsedDocs = (_a) => {
3193
3231
  var { node, nodeUnsupported } = _a, commonProps = __rest(_a, ["node", "nodeUnsupported"]);
@@ -3293,6 +3331,9 @@ const NODE_META_COLOR = {
3293
3331
  put: 'warning',
3294
3332
  patch: 'warning',
3295
3333
  delete: 'danger',
3334
+ head: '#9061F9',
3335
+ options: '#0D5AA7',
3336
+ trace: '#0D0B28',
3296
3337
  };
3297
3338
 
3298
3339
  function getHtmlIdFromItemId(id) {
@@ -3646,12 +3687,13 @@ function isPartialHttpRequest(maybeHttpRequest) {
3646
3687
  }
3647
3688
  const SchemaAndDescription = ({ title: titleProp, schema }) => {
3648
3689
  const [resolveRef, maxRefDepth] = useSchemaInlineRefResolver();
3690
+ const { renderExtensionAddon } = useOptionsCtx();
3649
3691
  const title = titleProp !== null && titleProp !== void 0 ? titleProp : schema.title;
3650
3692
  return (React__default.createElement(Box, { py: 2 },
3651
3693
  title && (React__default.createElement(Flex, { alignItems: "center", p: 2 },
3652
3694
  React__default.createElement(Icon, { icon: NodeTypeIconDefs[NodeType.Model], color: NodeTypeColors[NodeType.Model] }),
3653
3695
  React__default.createElement(Box, { color: "muted", px: 2 }, title))),
3654
- React__default.createElement(JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema) })));
3696
+ React__default.createElement(JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), renderExtensionAddon: renderExtensionAddon })));
3655
3697
  };
3656
3698
  const CodeComponent = props => {
3657
3699
  const { title, jsonSchema, http, resolved, children } = props;
@@ -3996,4 +4038,4 @@ const createElementClass = (Component, propDescriptors) => {
3996
4038
  };
3997
4039
  };
3998
4040
 
3999
- export { DeprecatedBadge, Docs, ExportButton, HttpMethodColors, InlineRefResolverProvider, LinkHeading, Logo, MarkdownComponentsProvider, MockingProvider, NodeTypeColors, NodeTypeIconDefs, NodeTypePrettyName, NonIdealState, ParsedDocs, PersistenceContextProvider, PoweredByLink, ReactRouterMarkdownLink, ResponsiveSidebarLayout, RouterTypeContext, SidebarLayout, Styled, TableOfContents, TryIt, TryItWithRequestSamples, createElementClass, createResolvedObject, findFirstNode, isHttpOperation, isHttpService, isHttpWebhookOperation, slugify, useBundleRefsIntoDocument, useParsedData, useParsedValue, useResponsiveLayout, useRouter, withMosaicProvider, withPersistenceBoundary, withQueryClientProvider, withRouter, withStyles };
4041
+ export { DeprecatedBadge, Docs, ElementsOptionsProvider, ExportButton, HttpMethodColors, InlineRefResolverProvider, LinkHeading, Logo, MarkdownComponentsProvider, MockingProvider, NodeTypeColors, NodeTypeIconDefs, NodeTypePrettyName, NonIdealState, ParsedDocs, PersistenceContextProvider, PoweredByLink, ReactRouterMarkdownLink, ResponsiveSidebarLayout, RouterTypeContext, SidebarLayout, Styled, TableOfContents, TryIt, TryItWithRequestSamples, createElementClass, createResolvedObject, findFirstNode, isHttpOperation, isHttpService, isHttpWebhookOperation, slugify, useBundleRefsIntoDocument, useParsedData, useParsedValue, useResponsiveLayout, useRouter, withMosaicProvider, withPersistenceBoundary, withQueryClientProvider, withRouter, withStyles };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoplight/elements-core",
3
- "version": "8.2.0",
3
+ "version": "8.3.2",
4
4
  "main": "./index.js",
5
5
  "sideEffects": [
6
6
  "web-components.min.js",
@@ -24,10 +24,10 @@
24
24
  "react-dom": ">=16.8"
25
25
  },
26
26
  "dependencies": {
27
- "@stoplight/http-spec": "^7.0.3",
28
- "@stoplight/json": "^3.18.1",
29
- "@stoplight/json-schema-ref-parser": "^9.0.5",
30
- "@stoplight/json-schema-sampler": "0.2.3",
27
+ "@stoplight/http-spec": "^7.1.0",
28
+ "@stoplight/json": "^3.21.0",
29
+ "@stoplight/json-schema-ref-parser": "^9.2.7",
30
+ "@stoplight/json-schema-sampler": "0.3.0",
31
31
  "@stoplight/json-schema-tree": "^4.0.0",
32
32
  "@stoplight/json-schema-viewer": "4.16.1",
33
33
  "@stoplight/markdown-viewer": "^5.7.0",
@@ -37,7 +37,7 @@
37
37
  "@stoplight/path": "^1.3.2",
38
38
  "@stoplight/react-error-boundary": "^3.0.0",
39
39
  "@stoplight/types": "^14.1.1",
40
- "@stoplight/yaml": "^4.2.3",
40
+ "@stoplight/yaml": "^4.3.0",
41
41
  "classnames": "^2.2.6",
42
42
  "httpsnippet-lite": "^3.0.5",
43
43
  "jotai": "1.3.9",
@@ -1,2 +0,0 @@
1
- import { IHttpOperation } from '@stoplight/types';
2
- export declare const xcodeSamples: IHttpOperation;