@stoplight/elements-core 8.4.4 → 8.4.5

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.
@@ -2,9 +2,10 @@ import { IHttpOperationRequestBody } from '@stoplight/types';
2
2
  export interface BodyProps {
3
3
  body: IHttpOperationRequestBody;
4
4
  onChange?: (requestBodyIndex: number) => void;
5
+ isHttpWebhookOperation?: boolean;
5
6
  }
6
7
  export declare const isBodyEmpty: (body?: BodyProps['body']) => boolean;
7
8
  export declare const Body: {
8
- ({ body, onChange }: BodyProps): JSX.Element | null;
9
+ ({ body, onChange, isHttpWebhookOperation }: BodyProps): JSX.Element | null;
9
10
  displayName: string;
10
11
  };
@@ -4,6 +4,7 @@ interface IRequestProps {
4
4
  operation: IHttpEndpointOperation;
5
5
  hideSecurityInfo?: boolean;
6
6
  onChange?: (requestBodyIndex: number) => void;
7
+ isHttpWebhookOperation?: boolean;
7
8
  }
8
9
  export declare const Request: React.FunctionComponent<IRequestProps>;
9
10
  export {};
@@ -1,3 +1,3 @@
1
1
  import { IMediaTypeContent } from '@stoplight/types';
2
2
  import * as React from 'react';
3
- export declare const useTextRequestBodyState: (mediaTypeContent: IMediaTypeContent | undefined) => [string, React.Dispatch<React.SetStateAction<string>>];
3
+ export declare const useTextRequestBodyState: (mediaTypeContent: IMediaTypeContent | undefined, skipReadOnly: boolean) => [string, React.Dispatch<React.SetStateAction<string>>];
package/index.esm.js CHANGED
@@ -1694,9 +1694,9 @@ const exceedsSize = (example, size = 500) => {
1694
1694
  return example.split(/\r\n|\r|\n/).length > size;
1695
1695
  };
1696
1696
 
1697
- const useTextRequestBodyState = (mediaTypeContent) => {
1697
+ const useTextRequestBodyState = (mediaTypeContent, skipReadOnly) => {
1698
1698
  const initialRequestBody = useGenerateExampleFromMediaTypeContent(mediaTypeContent, undefined, {
1699
- skipReadOnly: true,
1699
+ skipReadOnly,
1700
1700
  });
1701
1701
  const [textRequestBody, setTextRequestBody] = React.useState(initialRequestBody);
1702
1702
  React.useEffect(() => {
@@ -2263,7 +2263,7 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
2263
2263
  const { allParameters, updateParameterValue, parameterValuesWithDefaults } = useRequestParameters(httpOperation);
2264
2264
  const [mockingOptions, setMockingOptions] = useMockingOptions();
2265
2265
  const [bodyParameterValues, setBodyParameterValues, isAllowedEmptyValues, setAllowedEmptyValues, formDataState] = useBodyParameterState(mediaTypeContent);
2266
- const [textRequestBody, setTextRequestBody] = useTextRequestBodyState(mediaTypeContent);
2266
+ const [textRequestBody, setTextRequestBody] = useTextRequestBodyState(mediaTypeContent, !isHttpWebhookOperation(httpOperation));
2267
2267
  const [operationAuthValue, setOperationAuthValue, setCurrentScheme] = usePersistedSecuritySchemeWithValues();
2268
2268
  const servers = React.useMemo(() => {
2269
2269
  return getServersToDisplay(httpOperation.servers || defaultServers, mockUrl);
@@ -2641,7 +2641,7 @@ const isBodyEmpty = (body) => {
2641
2641
  const { contents = [], description } = body;
2642
2642
  return contents.length === 0 && !(description === null || description === void 0 ? void 0 : description.trim());
2643
2643
  };
2644
- const Body = ({ body, onChange }) => {
2644
+ const Body = ({ body, onChange, isHttpWebhookOperation = false }) => {
2645
2645
  var _a;
2646
2646
  const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
2647
2647
  const [chosenContent, setChosenContent] = React.useState(0);
@@ -2660,7 +2660,7 @@ const Body = ({ body, onChange }) => {
2660
2660
  description && (React.createElement(Box, { pos: "relative" },
2661
2661
  React.createElement(MarkdownViewer, { markdown: description }),
2662
2662
  React.createElement(NodeAnnotation, { change: descriptionChanged }))),
2663
- isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: "write", renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))));
2663
+ isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: isHttpWebhookOperation ? 'standalone' : 'write', renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))));
2664
2664
  };
2665
2665
  Body.displayName = 'HttpOperation.Body';
2666
2666
 
@@ -2727,7 +2727,7 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
2727
2727
  return schema;
2728
2728
  };
2729
2729
 
2730
- const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, }) => {
2730
+ const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false, }) => {
2731
2731
  if (!request || typeof request !== 'object')
2732
2732
  return null;
2733
2733
  const bodyIsEmpty = isBodyEmpty(body);
@@ -2755,7 +2755,7 @@ const Request = ({ operation: { request, request: { path: pathParams = [], heade
2755
2755
  cookieParams.length > 0 && (React.createElement(VStack, { spacing: 5 },
2756
2756
  React.createElement(SectionSubtitle, { title: "Cookies", id: "request-cookies" }),
2757
2757
  React.createElement(Parameters, { parameterType: "cookie", parameters: cookieParams }))),
2758
- body && React.createElement(Body, { onChange: onChange, body: body })));
2758
+ body && React.createElement(Body, { onChange: onChange, body: body, isHttpWebhookOperation: isHttpWebhookOperation })));
2759
2759
  };
2760
2760
  Request.displayName = 'HttpOperation.Request';
2761
2761
  const schemeExpandedState = atomWithStorage('HttpOperation_security_expanded', {});
@@ -2922,7 +2922,7 @@ const HttpOperationComponent = React.memo(({ className, data: unresolvedData, la
2922
2922
  React.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
2923
2923
  React.createElement(NodeAnnotation, { change: descriptionChanged }))),
2924
2924
  React.createElement(NodeVendorExtensions, { data: data }),
2925
- React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo }),
2925
+ React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo, isHttpWebhookOperation: isHttpWebhookOperation(data) }),
2926
2926
  data.responses && (React.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact })),
2927
2927
  ((_a = data.callbacks) === null || _a === void 0 ? void 0 : _a.length) ? React.createElement(Callbacks, { callbacks: data.callbacks, isCompact: isCompact }) : null,
2928
2928
  isCompact && tryItPanel));
package/index.js CHANGED
@@ -1716,9 +1716,9 @@ const exceedsSize = (example, size = 500) => {
1716
1716
  return example.split(/\r\n|\r|\n/).length > size;
1717
1717
  };
1718
1718
 
1719
- const useTextRequestBodyState = (mediaTypeContent) => {
1719
+ const useTextRequestBodyState = (mediaTypeContent, skipReadOnly) => {
1720
1720
  const initialRequestBody = useGenerateExampleFromMediaTypeContent(mediaTypeContent, undefined, {
1721
- skipReadOnly: true,
1721
+ skipReadOnly,
1722
1722
  });
1723
1723
  const [textRequestBody, setTextRequestBody] = React__namespace.useState(initialRequestBody);
1724
1724
  React__namespace.useEffect(() => {
@@ -2285,7 +2285,7 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
2285
2285
  const { allParameters, updateParameterValue, parameterValuesWithDefaults } = useRequestParameters(httpOperation);
2286
2286
  const [mockingOptions, setMockingOptions] = useMockingOptions();
2287
2287
  const [bodyParameterValues, setBodyParameterValues, isAllowedEmptyValues, setAllowedEmptyValues, formDataState] = useBodyParameterState(mediaTypeContent);
2288
- const [textRequestBody, setTextRequestBody] = useTextRequestBodyState(mediaTypeContent);
2288
+ const [textRequestBody, setTextRequestBody] = useTextRequestBodyState(mediaTypeContent, !isHttpWebhookOperation(httpOperation));
2289
2289
  const [operationAuthValue, setOperationAuthValue, setCurrentScheme] = usePersistedSecuritySchemeWithValues();
2290
2290
  const servers = React__namespace.useMemo(() => {
2291
2291
  return getServersToDisplay(httpOperation.servers || defaultServers, mockUrl);
@@ -2663,7 +2663,7 @@ const isBodyEmpty = (body) => {
2663
2663
  const { contents = [], description } = body;
2664
2664
  return contents.length === 0 && !(description === null || description === void 0 ? void 0 : description.trim());
2665
2665
  };
2666
- const Body = ({ body, onChange }) => {
2666
+ const Body = ({ body, onChange, isHttpWebhookOperation = false }) => {
2667
2667
  var _a;
2668
2668
  const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
2669
2669
  const [chosenContent, setChosenContent] = React__namespace.useState(0);
@@ -2682,7 +2682,7 @@ const Body = ({ body, onChange }) => {
2682
2682
  description && (React__namespace.createElement(mosaic.Box, { pos: "relative" },
2683
2683
  React__namespace.createElement(MarkdownViewer, { markdown: description }),
2684
2684
  React__namespace.createElement(mosaic.NodeAnnotation, { change: descriptionChanged }))),
2685
- isJSONSchema(schema) && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: "write", renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))));
2685
+ isJSONSchema(schema) && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: isHttpWebhookOperation ? 'standalone' : 'write', renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))));
2686
2686
  };
2687
2687
  Body.displayName = 'HttpOperation.Body';
2688
2688
 
@@ -2749,7 +2749,7 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
2749
2749
  return schema;
2750
2750
  };
2751
2751
 
2752
- const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, }) => {
2752
+ const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false, }) => {
2753
2753
  if (!request || typeof request !== 'object')
2754
2754
  return null;
2755
2755
  const bodyIsEmpty = isBodyEmpty(body);
@@ -2777,7 +2777,7 @@ const Request = ({ operation: { request, request: { path: pathParams = [], heade
2777
2777
  cookieParams.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
2778
2778
  React__namespace.createElement(SectionSubtitle, { title: "Cookies", id: "request-cookies" }),
2779
2779
  React__namespace.createElement(Parameters, { parameterType: "cookie", parameters: cookieParams }))),
2780
- body && React__namespace.createElement(Body, { onChange: onChange, body: body })));
2780
+ body && React__namespace.createElement(Body, { onChange: onChange, body: body, isHttpWebhookOperation: isHttpWebhookOperation })));
2781
2781
  };
2782
2782
  Request.displayName = 'HttpOperation.Request';
2783
2783
  const schemeExpandedState = utils.atomWithStorage('HttpOperation_security_expanded', {});
@@ -2944,7 +2944,7 @@ const HttpOperationComponent = React__namespace.memo(({ className, data: unresol
2944
2944
  React__namespace.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
2945
2945
  React__namespace.createElement(mosaic.NodeAnnotation, { change: descriptionChanged }))),
2946
2946
  React__namespace.createElement(NodeVendorExtensions, { data: data }),
2947
- React__namespace.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo }),
2947
+ React__namespace.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo, isHttpWebhookOperation: isHttpWebhookOperation(data) }),
2948
2948
  data.responses && (React__namespace.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact })),
2949
2949
  ((_a = data.callbacks) === null || _a === void 0 ? void 0 : _a.length) ? React__namespace.createElement(Callbacks, { callbacks: data.callbacks, isCompact: isCompact }) : null,
2950
2950
  isCompact && tryItPanel));
package/index.mjs CHANGED
@@ -1694,9 +1694,9 @@ const exceedsSize = (example, size = 500) => {
1694
1694
  return example.split(/\r\n|\r|\n/).length > size;
1695
1695
  };
1696
1696
 
1697
- const useTextRequestBodyState = (mediaTypeContent) => {
1697
+ const useTextRequestBodyState = (mediaTypeContent, skipReadOnly) => {
1698
1698
  const initialRequestBody = useGenerateExampleFromMediaTypeContent(mediaTypeContent, undefined, {
1699
- skipReadOnly: true,
1699
+ skipReadOnly,
1700
1700
  });
1701
1701
  const [textRequestBody, setTextRequestBody] = React.useState(initialRequestBody);
1702
1702
  React.useEffect(() => {
@@ -2263,7 +2263,7 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
2263
2263
  const { allParameters, updateParameterValue, parameterValuesWithDefaults } = useRequestParameters(httpOperation);
2264
2264
  const [mockingOptions, setMockingOptions] = useMockingOptions();
2265
2265
  const [bodyParameterValues, setBodyParameterValues, isAllowedEmptyValues, setAllowedEmptyValues, formDataState] = useBodyParameterState(mediaTypeContent);
2266
- const [textRequestBody, setTextRequestBody] = useTextRequestBodyState(mediaTypeContent);
2266
+ const [textRequestBody, setTextRequestBody] = useTextRequestBodyState(mediaTypeContent, !isHttpWebhookOperation(httpOperation));
2267
2267
  const [operationAuthValue, setOperationAuthValue, setCurrentScheme] = usePersistedSecuritySchemeWithValues();
2268
2268
  const servers = React.useMemo(() => {
2269
2269
  return getServersToDisplay(httpOperation.servers || defaultServers, mockUrl);
@@ -2641,7 +2641,7 @@ const isBodyEmpty = (body) => {
2641
2641
  const { contents = [], description } = body;
2642
2642
  return contents.length === 0 && !(description === null || description === void 0 ? void 0 : description.trim());
2643
2643
  };
2644
- const Body = ({ body, onChange }) => {
2644
+ const Body = ({ body, onChange, isHttpWebhookOperation = false }) => {
2645
2645
  var _a;
2646
2646
  const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
2647
2647
  const [chosenContent, setChosenContent] = React.useState(0);
@@ -2660,7 +2660,7 @@ const Body = ({ body, onChange }) => {
2660
2660
  description && (React.createElement(Box, { pos: "relative" },
2661
2661
  React.createElement(MarkdownViewer, { markdown: description }),
2662
2662
  React.createElement(NodeAnnotation, { change: descriptionChanged }))),
2663
- isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: "write", renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))));
2663
+ isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: isHttpWebhookOperation ? 'standalone' : 'write', renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))));
2664
2664
  };
2665
2665
  Body.displayName = 'HttpOperation.Body';
2666
2666
 
@@ -2727,7 +2727,7 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
2727
2727
  return schema;
2728
2728
  };
2729
2729
 
2730
- const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, }) => {
2730
+ const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false, }) => {
2731
2731
  if (!request || typeof request !== 'object')
2732
2732
  return null;
2733
2733
  const bodyIsEmpty = isBodyEmpty(body);
@@ -2755,7 +2755,7 @@ const Request = ({ operation: { request, request: { path: pathParams = [], heade
2755
2755
  cookieParams.length > 0 && (React.createElement(VStack, { spacing: 5 },
2756
2756
  React.createElement(SectionSubtitle, { title: "Cookies", id: "request-cookies" }),
2757
2757
  React.createElement(Parameters, { parameterType: "cookie", parameters: cookieParams }))),
2758
- body && React.createElement(Body, { onChange: onChange, body: body })));
2758
+ body && React.createElement(Body, { onChange: onChange, body: body, isHttpWebhookOperation: isHttpWebhookOperation })));
2759
2759
  };
2760
2760
  Request.displayName = 'HttpOperation.Request';
2761
2761
  const schemeExpandedState = atomWithStorage('HttpOperation_security_expanded', {});
@@ -2922,7 +2922,7 @@ const HttpOperationComponent = React.memo(({ className, data: unresolvedData, la
2922
2922
  React.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
2923
2923
  React.createElement(NodeAnnotation, { change: descriptionChanged }))),
2924
2924
  React.createElement(NodeVendorExtensions, { data: data }),
2925
- React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo }),
2925
+ React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo, isHttpWebhookOperation: isHttpWebhookOperation(data) }),
2926
2926
  data.responses && (React.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact })),
2927
2927
  ((_a = data.callbacks) === null || _a === void 0 ? void 0 : _a.length) ? React.createElement(Callbacks, { callbacks: data.callbacks, isCompact: isCompact }) : null,
2928
2928
  isCompact && tryItPanel));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoplight/elements-core",
3
- "version": "8.4.4",
3
+ "version": "8.4.5",
4
4
  "main": "./index.js",
5
5
  "sideEffects": [
6
6
  "web-components.min.js",