@stoplight/elements-core 8.4.4 → 8.4.6
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/Body.d.ts +2 -1
- package/components/Docs/HttpOperation/HttpOperation.d.ts +1 -2
- package/components/Docs/HttpOperation/Request.d.ts +1 -0
- package/components/Docs/HttpService/HttpService.d.ts +1 -2
- package/components/Docs/Model/Model.d.ts +1 -2
- package/components/TryIt/Body/useTextRequestBodyState.d.ts +1 -1
- package/index.esm.js +31 -10
- package/index.js +31 -10
- package/index.mjs +31 -10
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IMarkdownViewerProps } from '@stoplight/markdown-viewer';
|
|
2
|
-
import * as React from 'react';
|
|
3
2
|
import { DocsComponentProps } from '..';
|
|
4
3
|
declare type ArticleProps = DocsComponentProps<IMarkdownViewerProps['markdown']>;
|
|
5
|
-
export declare const Article:
|
|
4
|
+
export declare const Article: import("react").FunctionComponent<ArticleProps & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
|
|
6
5
|
export {};
|
|
@@ -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
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { IHttpEndpointOperation } from '@stoplight/types';
|
|
2
|
-
import * as React from 'react';
|
|
3
2
|
import { DocsComponentProps } from '..';
|
|
4
3
|
export declare type HttpOperationProps = DocsComponentProps<IHttpEndpointOperation>;
|
|
5
|
-
export declare const HttpOperation:
|
|
4
|
+
export declare const HttpOperation: import("react").FunctionComponent<HttpOperationProps & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
|
|
6
5
|
export declare function OperationHeader({ id, noHeading, hasBadges, name, isDeprecated, isInternal, hideServerUrl, method, path, }: {
|
|
7
6
|
id: string;
|
|
8
7
|
noHeading?: boolean;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IHttpService } from '@stoplight/types';
|
|
2
|
-
import * as React from 'react';
|
|
3
2
|
import { DocsComponentProps } from '..';
|
|
4
3
|
export declare type HttpServiceProps = DocsComponentProps<Partial<IHttpService>>;
|
|
5
|
-
export declare const HttpService:
|
|
4
|
+
export declare const HttpService: import("react").FunctionComponent<HttpServiceProps & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { JSONSchema7 } from 'json-schema';
|
|
2
|
-
import * as React from 'react';
|
|
3
2
|
import { DocsComponentProps } from '..';
|
|
4
3
|
export declare type ModelProps = DocsComponentProps<JSONSchema7>;
|
|
5
|
-
export declare const Model:
|
|
4
|
+
export declare const Model: import("react").FunctionComponent<ModelProps & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
|
|
@@ -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
|
@@ -114,7 +114,28 @@ const isResolvedObjectProxy = (someObject) => {
|
|
|
114
114
|
return !!someObject[originalObjectSymbol];
|
|
115
115
|
};
|
|
116
116
|
const getOriginalObject = (resolvedObject) => {
|
|
117
|
-
|
|
117
|
+
const originalObject = resolvedObject[originalObjectSymbol] || resolvedObject;
|
|
118
|
+
if (!originalObject) {
|
|
119
|
+
return resolvedObject;
|
|
120
|
+
}
|
|
121
|
+
const hasAllSchemaErrors = (array) => {
|
|
122
|
+
return array.every(item => item['x-sl-error-message'] !== undefined);
|
|
123
|
+
};
|
|
124
|
+
if (originalObject.anyOf) {
|
|
125
|
+
if (hasAllSchemaErrors(originalObject.anyOf)) {
|
|
126
|
+
return Object.assign(Object.assign({}, originalObject), { anyOf: [originalObject.anyOf] });
|
|
127
|
+
}
|
|
128
|
+
const filteredArray = originalObject.anyOf.filter((item) => !item['x-sl-error-message']);
|
|
129
|
+
return Object.assign(Object.assign({}, originalObject), { anyOf: filteredArray });
|
|
130
|
+
}
|
|
131
|
+
else if (originalObject.oneOf) {
|
|
132
|
+
if (hasAllSchemaErrors(originalObject.oneOf)) {
|
|
133
|
+
return Object.assign(Object.assign({}, originalObject), { oneOf: [originalObject.oneOf] });
|
|
134
|
+
}
|
|
135
|
+
const filteredArray = originalObject.oneOf.filter((item) => !item['x-sl-error-message']);
|
|
136
|
+
return Object.assign(Object.assign({}, originalObject), { oneOf: filteredArray });
|
|
137
|
+
}
|
|
138
|
+
return originalObject;
|
|
118
139
|
};
|
|
119
140
|
const isReference = hasRef;
|
|
120
141
|
|
|
@@ -1694,9 +1715,9 @@ const exceedsSize = (example, size = 500) => {
|
|
|
1694
1715
|
return example.split(/\r\n|\r|\n/).length > size;
|
|
1695
1716
|
};
|
|
1696
1717
|
|
|
1697
|
-
const useTextRequestBodyState = (mediaTypeContent) => {
|
|
1718
|
+
const useTextRequestBodyState = (mediaTypeContent, skipReadOnly) => {
|
|
1698
1719
|
const initialRequestBody = useGenerateExampleFromMediaTypeContent(mediaTypeContent, undefined, {
|
|
1699
|
-
skipReadOnly
|
|
1720
|
+
skipReadOnly,
|
|
1700
1721
|
});
|
|
1701
1722
|
const [textRequestBody, setTextRequestBody] = React.useState(initialRequestBody);
|
|
1702
1723
|
React.useEffect(() => {
|
|
@@ -2263,7 +2284,7 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
|
|
|
2263
2284
|
const { allParameters, updateParameterValue, parameterValuesWithDefaults } = useRequestParameters(httpOperation);
|
|
2264
2285
|
const [mockingOptions, setMockingOptions] = useMockingOptions();
|
|
2265
2286
|
const [bodyParameterValues, setBodyParameterValues, isAllowedEmptyValues, setAllowedEmptyValues, formDataState] = useBodyParameterState(mediaTypeContent);
|
|
2266
|
-
const [textRequestBody, setTextRequestBody] = useTextRequestBodyState(mediaTypeContent);
|
|
2287
|
+
const [textRequestBody, setTextRequestBody] = useTextRequestBodyState(mediaTypeContent, !isHttpWebhookOperation(httpOperation));
|
|
2267
2288
|
const [operationAuthValue, setOperationAuthValue, setCurrentScheme] = usePersistedSecuritySchemeWithValues();
|
|
2268
2289
|
const servers = React.useMemo(() => {
|
|
2269
2290
|
return getServersToDisplay(httpOperation.servers || defaultServers, mockUrl);
|
|
@@ -2641,7 +2662,7 @@ const isBodyEmpty = (body) => {
|
|
|
2641
2662
|
const { contents = [], description } = body;
|
|
2642
2663
|
return contents.length === 0 && !(description === null || description === void 0 ? void 0 : description.trim());
|
|
2643
2664
|
};
|
|
2644
|
-
const Body = ({ body, onChange }) => {
|
|
2665
|
+
const Body = ({ body, onChange, isHttpWebhookOperation = false }) => {
|
|
2645
2666
|
var _a;
|
|
2646
2667
|
const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
|
|
2647
2668
|
const [chosenContent, setChosenContent] = React.useState(0);
|
|
@@ -2660,7 +2681,7 @@ const Body = ({ body, onChange }) => {
|
|
|
2660
2681
|
description && (React.createElement(Box, { pos: "relative" },
|
|
2661
2682
|
React.createElement(MarkdownViewer, { markdown: description }),
|
|
2662
2683
|
React.createElement(NodeAnnotation, { change: descriptionChanged }))),
|
|
2663
|
-
isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode:
|
|
2684
|
+
isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: isHttpWebhookOperation ? 'standalone' : 'write', renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))));
|
|
2664
2685
|
};
|
|
2665
2686
|
Body.displayName = 'HttpOperation.Body';
|
|
2666
2687
|
|
|
@@ -2727,7 +2748,7 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
|
2727
2748
|
return schema;
|
|
2728
2749
|
};
|
|
2729
2750
|
|
|
2730
|
-
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, }) => {
|
|
2751
|
+
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false, }) => {
|
|
2731
2752
|
if (!request || typeof request !== 'object')
|
|
2732
2753
|
return null;
|
|
2733
2754
|
const bodyIsEmpty = isBodyEmpty(body);
|
|
@@ -2755,7 +2776,7 @@ const Request = ({ operation: { request, request: { path: pathParams = [], heade
|
|
|
2755
2776
|
cookieParams.length > 0 && (React.createElement(VStack, { spacing: 5 },
|
|
2756
2777
|
React.createElement(SectionSubtitle, { title: "Cookies", id: "request-cookies" }),
|
|
2757
2778
|
React.createElement(Parameters, { parameterType: "cookie", parameters: cookieParams }))),
|
|
2758
|
-
body && React.createElement(Body, { onChange: onChange, body: body })));
|
|
2779
|
+
body && React.createElement(Body, { onChange: onChange, body: body, isHttpWebhookOperation: isHttpWebhookOperation })));
|
|
2759
2780
|
};
|
|
2760
2781
|
Request.displayName = 'HttpOperation.Request';
|
|
2761
2782
|
const schemeExpandedState = atomWithStorage('HttpOperation_security_expanded', {});
|
|
@@ -2922,7 +2943,7 @@ const HttpOperationComponent = React.memo(({ className, data: unresolvedData, la
|
|
|
2922
2943
|
React.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
|
|
2923
2944
|
React.createElement(NodeAnnotation, { change: descriptionChanged }))),
|
|
2924
2945
|
React.createElement(NodeVendorExtensions, { data: data }),
|
|
2925
|
-
React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo }),
|
|
2946
|
+
React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo, isHttpWebhookOperation: isHttpWebhookOperation(data) }),
|
|
2926
2947
|
data.responses && (React.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact })),
|
|
2927
2948
|
((_a = data.callbacks) === null || _a === void 0 ? void 0 : _a.length) ? React.createElement(Callbacks, { callbacks: data.callbacks, isCompact: isCompact }) : null,
|
|
2928
2949
|
isCompact && tryItPanel));
|
|
@@ -2993,7 +3014,7 @@ const AdditionalInfo = ({ id, termsOfService, contact, license }) => {
|
|
|
2993
3014
|
? `[${license.name}](${licenseUrl})`
|
|
2994
3015
|
: (license === null || license === void 0 ? void 0 : license.identifier) && licenseUrl
|
|
2995
3016
|
? `[${license === null || license === void 0 ? void 0 : license.identifier}](${licenseUrl})`
|
|
2996
|
-
:
|
|
3017
|
+
: '';
|
|
2997
3018
|
const tosLink = termsOfService ? `[Terms of Service](${termsOfService})` : '';
|
|
2998
3019
|
return contactLink || licenseLink || tosLink ? (React__default.createElement(Panel, { rounded: true, isCollapsible: false, pos: "relative" },
|
|
2999
3020
|
React__default.createElement(Panel.Titlebar, { bg: "canvas-300" },
|
package/index.js
CHANGED
|
@@ -136,7 +136,28 @@ const isResolvedObjectProxy = (someObject) => {
|
|
|
136
136
|
return !!someObject[originalObjectSymbol];
|
|
137
137
|
};
|
|
138
138
|
const getOriginalObject = (resolvedObject) => {
|
|
139
|
-
|
|
139
|
+
const originalObject = resolvedObject[originalObjectSymbol] || resolvedObject;
|
|
140
|
+
if (!originalObject) {
|
|
141
|
+
return resolvedObject;
|
|
142
|
+
}
|
|
143
|
+
const hasAllSchemaErrors = (array) => {
|
|
144
|
+
return array.every(item => item['x-sl-error-message'] !== undefined);
|
|
145
|
+
};
|
|
146
|
+
if (originalObject.anyOf) {
|
|
147
|
+
if (hasAllSchemaErrors(originalObject.anyOf)) {
|
|
148
|
+
return Object.assign(Object.assign({}, originalObject), { anyOf: [originalObject.anyOf] });
|
|
149
|
+
}
|
|
150
|
+
const filteredArray = originalObject.anyOf.filter((item) => !item['x-sl-error-message']);
|
|
151
|
+
return Object.assign(Object.assign({}, originalObject), { anyOf: filteredArray });
|
|
152
|
+
}
|
|
153
|
+
else if (originalObject.oneOf) {
|
|
154
|
+
if (hasAllSchemaErrors(originalObject.oneOf)) {
|
|
155
|
+
return Object.assign(Object.assign({}, originalObject), { oneOf: [originalObject.oneOf] });
|
|
156
|
+
}
|
|
157
|
+
const filteredArray = originalObject.oneOf.filter((item) => !item['x-sl-error-message']);
|
|
158
|
+
return Object.assign(Object.assign({}, originalObject), { oneOf: filteredArray });
|
|
159
|
+
}
|
|
160
|
+
return originalObject;
|
|
140
161
|
};
|
|
141
162
|
const isReference = json.hasRef;
|
|
142
163
|
|
|
@@ -1716,9 +1737,9 @@ const exceedsSize = (example, size = 500) => {
|
|
|
1716
1737
|
return example.split(/\r\n|\r|\n/).length > size;
|
|
1717
1738
|
};
|
|
1718
1739
|
|
|
1719
|
-
const useTextRequestBodyState = (mediaTypeContent) => {
|
|
1740
|
+
const useTextRequestBodyState = (mediaTypeContent, skipReadOnly) => {
|
|
1720
1741
|
const initialRequestBody = useGenerateExampleFromMediaTypeContent(mediaTypeContent, undefined, {
|
|
1721
|
-
skipReadOnly
|
|
1742
|
+
skipReadOnly,
|
|
1722
1743
|
});
|
|
1723
1744
|
const [textRequestBody, setTextRequestBody] = React__namespace.useState(initialRequestBody);
|
|
1724
1745
|
React__namespace.useEffect(() => {
|
|
@@ -2285,7 +2306,7 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
|
|
|
2285
2306
|
const { allParameters, updateParameterValue, parameterValuesWithDefaults } = useRequestParameters(httpOperation);
|
|
2286
2307
|
const [mockingOptions, setMockingOptions] = useMockingOptions();
|
|
2287
2308
|
const [bodyParameterValues, setBodyParameterValues, isAllowedEmptyValues, setAllowedEmptyValues, formDataState] = useBodyParameterState(mediaTypeContent);
|
|
2288
|
-
const [textRequestBody, setTextRequestBody] = useTextRequestBodyState(mediaTypeContent);
|
|
2309
|
+
const [textRequestBody, setTextRequestBody] = useTextRequestBodyState(mediaTypeContent, !isHttpWebhookOperation(httpOperation));
|
|
2289
2310
|
const [operationAuthValue, setOperationAuthValue, setCurrentScheme] = usePersistedSecuritySchemeWithValues();
|
|
2290
2311
|
const servers = React__namespace.useMemo(() => {
|
|
2291
2312
|
return getServersToDisplay(httpOperation.servers || defaultServers, mockUrl);
|
|
@@ -2663,7 +2684,7 @@ const isBodyEmpty = (body) => {
|
|
|
2663
2684
|
const { contents = [], description } = body;
|
|
2664
2685
|
return contents.length === 0 && !(description === null || description === void 0 ? void 0 : description.trim());
|
|
2665
2686
|
};
|
|
2666
|
-
const Body = ({ body, onChange }) => {
|
|
2687
|
+
const Body = ({ body, onChange, isHttpWebhookOperation = false }) => {
|
|
2667
2688
|
var _a;
|
|
2668
2689
|
const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
|
|
2669
2690
|
const [chosenContent, setChosenContent] = React__namespace.useState(0);
|
|
@@ -2682,7 +2703,7 @@ const Body = ({ body, onChange }) => {
|
|
|
2682
2703
|
description && (React__namespace.createElement(mosaic.Box, { pos: "relative" },
|
|
2683
2704
|
React__namespace.createElement(MarkdownViewer, { markdown: description }),
|
|
2684
2705
|
React__namespace.createElement(mosaic.NodeAnnotation, { change: descriptionChanged }))),
|
|
2685
|
-
isJSONSchema(schema) && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode:
|
|
2706
|
+
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
2707
|
};
|
|
2687
2708
|
Body.displayName = 'HttpOperation.Body';
|
|
2688
2709
|
|
|
@@ -2749,7 +2770,7 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
|
2749
2770
|
return schema;
|
|
2750
2771
|
};
|
|
2751
2772
|
|
|
2752
|
-
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, }) => {
|
|
2773
|
+
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false, }) => {
|
|
2753
2774
|
if (!request || typeof request !== 'object')
|
|
2754
2775
|
return null;
|
|
2755
2776
|
const bodyIsEmpty = isBodyEmpty(body);
|
|
@@ -2777,7 +2798,7 @@ const Request = ({ operation: { request, request: { path: pathParams = [], heade
|
|
|
2777
2798
|
cookieParams.length > 0 && (React__namespace.createElement(mosaic.VStack, { spacing: 5 },
|
|
2778
2799
|
React__namespace.createElement(SectionSubtitle, { title: "Cookies", id: "request-cookies" }),
|
|
2779
2800
|
React__namespace.createElement(Parameters, { parameterType: "cookie", parameters: cookieParams }))),
|
|
2780
|
-
body && React__namespace.createElement(Body, { onChange: onChange, body: body })));
|
|
2801
|
+
body && React__namespace.createElement(Body, { onChange: onChange, body: body, isHttpWebhookOperation: isHttpWebhookOperation })));
|
|
2781
2802
|
};
|
|
2782
2803
|
Request.displayName = 'HttpOperation.Request';
|
|
2783
2804
|
const schemeExpandedState = utils.atomWithStorage('HttpOperation_security_expanded', {});
|
|
@@ -2944,7 +2965,7 @@ const HttpOperationComponent = React__namespace.memo(({ className, data: unresol
|
|
|
2944
2965
|
React__namespace.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
|
|
2945
2966
|
React__namespace.createElement(mosaic.NodeAnnotation, { change: descriptionChanged }))),
|
|
2946
2967
|
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 }),
|
|
2968
|
+
React__namespace.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo, isHttpWebhookOperation: isHttpWebhookOperation(data) }),
|
|
2948
2969
|
data.responses && (React__namespace.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact })),
|
|
2949
2970
|
((_a = data.callbacks) === null || _a === void 0 ? void 0 : _a.length) ? React__namespace.createElement(Callbacks, { callbacks: data.callbacks, isCompact: isCompact }) : null,
|
|
2950
2971
|
isCompact && tryItPanel));
|
|
@@ -3015,7 +3036,7 @@ const AdditionalInfo = ({ id, termsOfService, contact, license }) => {
|
|
|
3015
3036
|
? `[${license.name}](${licenseUrl})`
|
|
3016
3037
|
: (license === null || license === void 0 ? void 0 : license.identifier) && licenseUrl
|
|
3017
3038
|
? `[${license === null || license === void 0 ? void 0 : license.identifier}](${licenseUrl})`
|
|
3018
|
-
:
|
|
3039
|
+
: '';
|
|
3019
3040
|
const tosLink = termsOfService ? `[Terms of Service](${termsOfService})` : '';
|
|
3020
3041
|
return contactLink || licenseLink || tosLink ? (React.createElement(mosaic.Panel, { rounded: true, isCollapsible: false, pos: "relative" },
|
|
3021
3042
|
React.createElement(mosaic.Panel.Titlebar, { bg: "canvas-300" },
|
package/index.mjs
CHANGED
|
@@ -114,7 +114,28 @@ const isResolvedObjectProxy = (someObject) => {
|
|
|
114
114
|
return !!someObject[originalObjectSymbol];
|
|
115
115
|
};
|
|
116
116
|
const getOriginalObject = (resolvedObject) => {
|
|
117
|
-
|
|
117
|
+
const originalObject = resolvedObject[originalObjectSymbol] || resolvedObject;
|
|
118
|
+
if (!originalObject) {
|
|
119
|
+
return resolvedObject;
|
|
120
|
+
}
|
|
121
|
+
const hasAllSchemaErrors = (array) => {
|
|
122
|
+
return array.every(item => item['x-sl-error-message'] !== undefined);
|
|
123
|
+
};
|
|
124
|
+
if (originalObject.anyOf) {
|
|
125
|
+
if (hasAllSchemaErrors(originalObject.anyOf)) {
|
|
126
|
+
return Object.assign(Object.assign({}, originalObject), { anyOf: [originalObject.anyOf] });
|
|
127
|
+
}
|
|
128
|
+
const filteredArray = originalObject.anyOf.filter((item) => !item['x-sl-error-message']);
|
|
129
|
+
return Object.assign(Object.assign({}, originalObject), { anyOf: filteredArray });
|
|
130
|
+
}
|
|
131
|
+
else if (originalObject.oneOf) {
|
|
132
|
+
if (hasAllSchemaErrors(originalObject.oneOf)) {
|
|
133
|
+
return Object.assign(Object.assign({}, originalObject), { oneOf: [originalObject.oneOf] });
|
|
134
|
+
}
|
|
135
|
+
const filteredArray = originalObject.oneOf.filter((item) => !item['x-sl-error-message']);
|
|
136
|
+
return Object.assign(Object.assign({}, originalObject), { oneOf: filteredArray });
|
|
137
|
+
}
|
|
138
|
+
return originalObject;
|
|
118
139
|
};
|
|
119
140
|
const isReference = hasRef;
|
|
120
141
|
|
|
@@ -1694,9 +1715,9 @@ const exceedsSize = (example, size = 500) => {
|
|
|
1694
1715
|
return example.split(/\r\n|\r|\n/).length > size;
|
|
1695
1716
|
};
|
|
1696
1717
|
|
|
1697
|
-
const useTextRequestBodyState = (mediaTypeContent) => {
|
|
1718
|
+
const useTextRequestBodyState = (mediaTypeContent, skipReadOnly) => {
|
|
1698
1719
|
const initialRequestBody = useGenerateExampleFromMediaTypeContent(mediaTypeContent, undefined, {
|
|
1699
|
-
skipReadOnly
|
|
1720
|
+
skipReadOnly,
|
|
1700
1721
|
});
|
|
1701
1722
|
const [textRequestBody, setTextRequestBody] = React.useState(initialRequestBody);
|
|
1702
1723
|
React.useEffect(() => {
|
|
@@ -2263,7 +2284,7 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
|
|
|
2263
2284
|
const { allParameters, updateParameterValue, parameterValuesWithDefaults } = useRequestParameters(httpOperation);
|
|
2264
2285
|
const [mockingOptions, setMockingOptions] = useMockingOptions();
|
|
2265
2286
|
const [bodyParameterValues, setBodyParameterValues, isAllowedEmptyValues, setAllowedEmptyValues, formDataState] = useBodyParameterState(mediaTypeContent);
|
|
2266
|
-
const [textRequestBody, setTextRequestBody] = useTextRequestBodyState(mediaTypeContent);
|
|
2287
|
+
const [textRequestBody, setTextRequestBody] = useTextRequestBodyState(mediaTypeContent, !isHttpWebhookOperation(httpOperation));
|
|
2267
2288
|
const [operationAuthValue, setOperationAuthValue, setCurrentScheme] = usePersistedSecuritySchemeWithValues();
|
|
2268
2289
|
const servers = React.useMemo(() => {
|
|
2269
2290
|
return getServersToDisplay(httpOperation.servers || defaultServers, mockUrl);
|
|
@@ -2641,7 +2662,7 @@ const isBodyEmpty = (body) => {
|
|
|
2641
2662
|
const { contents = [], description } = body;
|
|
2642
2663
|
return contents.length === 0 && !(description === null || description === void 0 ? void 0 : description.trim());
|
|
2643
2664
|
};
|
|
2644
|
-
const Body = ({ body, onChange }) => {
|
|
2665
|
+
const Body = ({ body, onChange, isHttpWebhookOperation = false }) => {
|
|
2645
2666
|
var _a;
|
|
2646
2667
|
const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
|
|
2647
2668
|
const [chosenContent, setChosenContent] = React.useState(0);
|
|
@@ -2660,7 +2681,7 @@ const Body = ({ body, onChange }) => {
|
|
|
2660
2681
|
description && (React.createElement(Box, { pos: "relative" },
|
|
2661
2682
|
React.createElement(MarkdownViewer, { markdown: description }),
|
|
2662
2683
|
React.createElement(NodeAnnotation, { change: descriptionChanged }))),
|
|
2663
|
-
isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode:
|
|
2684
|
+
isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: isHttpWebhookOperation ? 'standalone' : 'write', renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))));
|
|
2664
2685
|
};
|
|
2665
2686
|
Body.displayName = 'HttpOperation.Body';
|
|
2666
2687
|
|
|
@@ -2727,7 +2748,7 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
|
2727
2748
|
return schema;
|
|
2728
2749
|
};
|
|
2729
2750
|
|
|
2730
|
-
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, }) => {
|
|
2751
|
+
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false, }) => {
|
|
2731
2752
|
if (!request || typeof request !== 'object')
|
|
2732
2753
|
return null;
|
|
2733
2754
|
const bodyIsEmpty = isBodyEmpty(body);
|
|
@@ -2755,7 +2776,7 @@ const Request = ({ operation: { request, request: { path: pathParams = [], heade
|
|
|
2755
2776
|
cookieParams.length > 0 && (React.createElement(VStack, { spacing: 5 },
|
|
2756
2777
|
React.createElement(SectionSubtitle, { title: "Cookies", id: "request-cookies" }),
|
|
2757
2778
|
React.createElement(Parameters, { parameterType: "cookie", parameters: cookieParams }))),
|
|
2758
|
-
body && React.createElement(Body, { onChange: onChange, body: body })));
|
|
2779
|
+
body && React.createElement(Body, { onChange: onChange, body: body, isHttpWebhookOperation: isHttpWebhookOperation })));
|
|
2759
2780
|
};
|
|
2760
2781
|
Request.displayName = 'HttpOperation.Request';
|
|
2761
2782
|
const schemeExpandedState = atomWithStorage('HttpOperation_security_expanded', {});
|
|
@@ -2922,7 +2943,7 @@ const HttpOperationComponent = React.memo(({ className, data: unresolvedData, la
|
|
|
2922
2943
|
React.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
|
|
2923
2944
|
React.createElement(NodeAnnotation, { change: descriptionChanged }))),
|
|
2924
2945
|
React.createElement(NodeVendorExtensions, { data: data }),
|
|
2925
|
-
React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo }),
|
|
2946
|
+
React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo, isHttpWebhookOperation: isHttpWebhookOperation(data) }),
|
|
2926
2947
|
data.responses && (React.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact })),
|
|
2927
2948
|
((_a = data.callbacks) === null || _a === void 0 ? void 0 : _a.length) ? React.createElement(Callbacks, { callbacks: data.callbacks, isCompact: isCompact }) : null,
|
|
2928
2949
|
isCompact && tryItPanel));
|
|
@@ -2993,7 +3014,7 @@ const AdditionalInfo = ({ id, termsOfService, contact, license }) => {
|
|
|
2993
3014
|
? `[${license.name}](${licenseUrl})`
|
|
2994
3015
|
: (license === null || license === void 0 ? void 0 : license.identifier) && licenseUrl
|
|
2995
3016
|
? `[${license === null || license === void 0 ? void 0 : license.identifier}](${licenseUrl})`
|
|
2996
|
-
:
|
|
3017
|
+
: '';
|
|
2997
3018
|
const tosLink = termsOfService ? `[Terms of Service](${termsOfService})` : '';
|
|
2998
3019
|
return contactLink || licenseLink || tosLink ? (React__default.createElement(Panel, { rounded: true, isCollapsible: false, pos: "relative" },
|
|
2999
3020
|
React__default.createElement(Panel.Titlebar, { bg: "canvas-300" },
|