@stoplight/elements-core 9.0.11 → 9.0.12
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/Docs.d.ts +1 -14
- package/components/Docs/HttpOperation/Body.d.ts +1 -9
- package/components/Docs/HttpOperation/HttpOperation.d.ts +2 -6
- package/components/Docs/HttpOperation/Request.d.ts +0 -6
- package/components/Docs/HttpOperation/Responses.d.ts +1 -12
- package/index.esm.js +22 -453
- package/index.js +22 -453
- package/index.mjs +22 -453
- package/package.json +1 -1
- package/components/Docs/HttpOperation/LazySchemaTreePreviewer.d.ts +0 -34
package/index.mjs
CHANGED
|
@@ -113,8 +113,6 @@ const isResolvedObjectProxy = (someObject) => {
|
|
|
113
113
|
return !!someObject[originalObjectSymbol];
|
|
114
114
|
};
|
|
115
115
|
const getOriginalObject = (resolvedObject) => {
|
|
116
|
-
if (!resolvedObject)
|
|
117
|
-
return resolvedObject;
|
|
118
116
|
const originalObject = resolvedObject[originalObjectSymbol] || resolvedObject;
|
|
119
117
|
if (!originalObject) {
|
|
120
118
|
return resolvedObject;
|
|
@@ -2740,358 +2738,13 @@ const PanelContent = ({ schemes }) => {
|
|
|
2740
2738
|
})));
|
|
2741
2739
|
};
|
|
2742
2740
|
|
|
2743
|
-
const TYPES = ['string', 'integer', 'boolean', 'any', 'number'];
|
|
2744
|
-
function resolvePointer(obj, pointer) {
|
|
2745
|
-
const parts = pointer.replace(/^#\//, '').split('/');
|
|
2746
|
-
return parts.reduce((acc, key) => acc && acc[key], obj);
|
|
2747
|
-
}
|
|
2748
|
-
function detectCircularPath(path) {
|
|
2749
|
-
const ignored = ['properties', 'items'];
|
|
2750
|
-
const parts = path.split('/').filter(part => !ignored.includes(part));
|
|
2751
|
-
for (let i = 0; i < parts.length - 1; i++) {
|
|
2752
|
-
const current = parts[i];
|
|
2753
|
-
const rest = parts.slice(i + 1);
|
|
2754
|
-
if (rest.includes(current)) {
|
|
2755
|
-
return true;
|
|
2756
|
-
}
|
|
2757
|
-
}
|
|
2758
|
-
return false;
|
|
2759
|
-
}
|
|
2760
|
-
function dereference(node, root, visited = new WeakSet(), depth = 0, maxDepth = 10) {
|
|
2761
|
-
if (!node || typeof node !== 'object')
|
|
2762
|
-
return node;
|
|
2763
|
-
if (depth > maxDepth)
|
|
2764
|
-
return node;
|
|
2765
|
-
if (node.$ref || node['x-iata-$ref']) {
|
|
2766
|
-
let refPath = node.$ref || node['x-iata-$ref'];
|
|
2767
|
-
if (refPath.includes('#/%24defs')) {
|
|
2768
|
-
refPath = refPath.replace('#/%24defs', '$defs');
|
|
2769
|
-
}
|
|
2770
|
-
else {
|
|
2771
|
-
refPath = refPath.replace('__bundled__', 'definitions');
|
|
2772
|
-
}
|
|
2773
|
-
if (visited.has(node))
|
|
2774
|
-
return { circular: true, $ref: refPath, title: node.title, type: 'any', description: node.description };
|
|
2775
|
-
visited.add(node);
|
|
2776
|
-
const target = resolvePointer(root, refPath);
|
|
2777
|
-
if (!target)
|
|
2778
|
-
return node;
|
|
2779
|
-
const result = Object.assign({}, target);
|
|
2780
|
-
if ('description' in node)
|
|
2781
|
-
result.description = node.description;
|
|
2782
|
-
if ('title' in node)
|
|
2783
|
-
result.title = node.title;
|
|
2784
|
-
return dereference(result, root, visited, depth + 1, maxDepth);
|
|
2785
|
-
}
|
|
2786
|
-
if (Array.isArray(node)) {
|
|
2787
|
-
return node.map(item => dereference(item, root, visited, depth + 1, maxDepth));
|
|
2788
|
-
}
|
|
2789
|
-
const result = {};
|
|
2790
|
-
for (const key in node) {
|
|
2791
|
-
result[key] = dereference(node[key], root, visited, depth + 1, maxDepth);
|
|
2792
|
-
}
|
|
2793
|
-
return result;
|
|
2794
|
-
}
|
|
2795
|
-
const trimSlashes = (str) => {
|
|
2796
|
-
return str.replace(/^\/|\/$/g, '');
|
|
2797
|
-
};
|
|
2798
|
-
function isPropertiesAllHidden(path, hideData) {
|
|
2799
|
-
const current = trimSlashes(path);
|
|
2800
|
-
const parts = current.split('/');
|
|
2801
|
-
for (let i = parts.length; i >= 2; i--) {
|
|
2802
|
-
if (parts[i - 1] === 'properties') {
|
|
2803
|
-
const ancestorPropPath = parts.slice(0, i).join('/');
|
|
2804
|
-
const block = hideData.find(h => trimSlashes(h.path) === ancestorPropPath && ancestorPropPath.endsWith('/properties'));
|
|
2805
|
-
if (block && block.required === undefined) {
|
|
2806
|
-
return true;
|
|
2807
|
-
}
|
|
2808
|
-
}
|
|
2809
|
-
}
|
|
2810
|
-
return false;
|
|
2811
|
-
}
|
|
2812
|
-
function isRequiredOverride(path, hideData) {
|
|
2813
|
-
const entry = hideData.find(h => trimSlashes(h.path) === trimSlashes(path));
|
|
2814
|
-
return entry && typeof entry.required === 'boolean' ? entry.required : undefined;
|
|
2815
|
-
}
|
|
2816
|
-
function isPathHidden(path, hideData, complexData) {
|
|
2817
|
-
const isComplex = checkIfIsComplex(path, complexData);
|
|
2818
|
-
if (isComplex === null) {
|
|
2819
|
-
return false;
|
|
2820
|
-
}
|
|
2821
|
-
else if (isComplex) {
|
|
2822
|
-
const normalizedPath = trimSlashes(path);
|
|
2823
|
-
const direct = hideData.find(h => trimSlashes(h.path) === normalizedPath);
|
|
2824
|
-
if (direct && direct.required === undefined)
|
|
2825
|
-
return true;
|
|
2826
|
-
if (isPropertiesAllHidden(path, hideData))
|
|
2827
|
-
return true;
|
|
2828
|
-
for (const h of hideData) {
|
|
2829
|
-
const hPath = trimSlashes(h.path);
|
|
2830
|
-
if (h.required !== undefined)
|
|
2831
|
-
continue;
|
|
2832
|
-
if (normalizedPath.length > hPath.length &&
|
|
2833
|
-
normalizedPath.startsWith(hPath) &&
|
|
2834
|
-
(hPath.endsWith('/items') || (hPath.match(/\/items\/[^\/]+$/) && normalizedPath.startsWith(hPath + '/')))) {
|
|
2835
|
-
return true;
|
|
2836
|
-
}
|
|
2837
|
-
}
|
|
2838
|
-
return false;
|
|
2839
|
-
}
|
|
2840
|
-
else {
|
|
2841
|
-
return !hideData.some(h => h.path === path || h.path.startsWith(path + '/'));
|
|
2842
|
-
}
|
|
2843
|
-
}
|
|
2844
|
-
const checkIfIsComplex = (path, complexData) => {
|
|
2845
|
-
let isComplex = null;
|
|
2846
|
-
for (const complex of complexData) {
|
|
2847
|
-
if (path.startsWith(complex.location)) {
|
|
2848
|
-
isComplex = complex === null || complex === void 0 ? void 0 : complex.isComplex;
|
|
2849
|
-
break;
|
|
2850
|
-
}
|
|
2851
|
-
}
|
|
2852
|
-
return isComplex;
|
|
2853
|
-
};
|
|
2854
|
-
const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path = '', hideData = [], complexData = [], parentRequired, propertyKey, _subType, }) => {
|
|
2855
|
-
var _a, _b, _c, _d;
|
|
2856
|
-
const [expanded, setExpanded] = useState(false);
|
|
2857
|
-
const [selectedSchemaIndex, setSelectedSchemaIndex] = useState(0);
|
|
2858
|
-
const [showSchemaDropdown, setShowSchemaDropdown] = useState(false);
|
|
2859
|
-
const [isHoveringSelector, setIsHoveringSelector] = useState(false);
|
|
2860
|
-
const isRoot = level === 1 && (title === undefined || path === '');
|
|
2861
|
-
useEffect(() => {
|
|
2862
|
-
setSelectedSchemaIndex(0);
|
|
2863
|
-
}, [schema === null || schema === void 0 ? void 0 : schema.anyOf, schema === null || schema === void 0 ? void 0 : schema.oneOf]);
|
|
2864
|
-
const thisNodeRequiredOverride = isRequiredOverride(path, hideData);
|
|
2865
|
-
const shouldHideAllChildren = (isRoot && hideData.some(h => trimSlashes(h.path) === 'properties' && h.required === undefined)) ||
|
|
2866
|
-
(!isRoot && isPropertiesAllHidden(path, hideData));
|
|
2867
|
-
const shouldHideNode = useMemo(() => {
|
|
2868
|
-
if (isRoot)
|
|
2869
|
-
return false;
|
|
2870
|
-
if (isPathHidden(path, hideData, complexData) && thisNodeRequiredOverride === undefined)
|
|
2871
|
-
return true;
|
|
2872
|
-
return false;
|
|
2873
|
-
}, [path, hideData, isRoot, thisNodeRequiredOverride, complexData]);
|
|
2874
|
-
if (!schema || shouldHideNode) {
|
|
2875
|
-
return null;
|
|
2876
|
-
}
|
|
2877
|
-
const displayTitle = level === 1 && (title === undefined || path === '') ? '' : (_a = title !== null && title !== void 0 ? title : schema === null || schema === void 0 ? void 0 : schema.title) !== null && _a !== void 0 ? _a : 'Node';
|
|
2878
|
-
const handleToggle = () => {
|
|
2879
|
-
const circular = detectCircularPath(path);
|
|
2880
|
-
if (!circular) {
|
|
2881
|
-
setExpanded(prev => !prev);
|
|
2882
|
-
}
|
|
2883
|
-
};
|
|
2884
|
-
const renderChildren = () => {
|
|
2885
|
-
var _a, _b, _c, _d;
|
|
2886
|
-
if (shouldHideAllChildren)
|
|
2887
|
-
return null;
|
|
2888
|
-
if (!expanded && !isRoot)
|
|
2889
|
-
return null;
|
|
2890
|
-
const children = [];
|
|
2891
|
-
if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && ((schema === null || schema === void 0 ? void 0 : schema.properties) || (schema === null || schema === void 0 ? void 0 : schema.allOf) || (schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf))) {
|
|
2892
|
-
let props = schema === null || schema === void 0 ? void 0 : schema.properties;
|
|
2893
|
-
if (schema === null || schema === void 0 ? void 0 : schema.allOf) {
|
|
2894
|
-
schema === null || schema === void 0 ? void 0 : schema.allOf.forEach((item) => {
|
|
2895
|
-
props = Object.assign(Object.assign({}, props), item.properties);
|
|
2896
|
-
});
|
|
2897
|
-
}
|
|
2898
|
-
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) && (schema === null || schema === void 0 ? void 0 : schema.anyOf.length) > 0) {
|
|
2899
|
-
const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.anyOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.anyOf[0]);
|
|
2900
|
-
props = Object.assign(Object.assign({}, props), selectedSchema.properties);
|
|
2901
|
-
}
|
|
2902
|
-
if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && (schema === null || schema === void 0 ? void 0 : schema.oneOf.length) > 0) {
|
|
2903
|
-
const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.oneOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.oneOf[0]);
|
|
2904
|
-
props = Object.assign(Object.assign({}, props), selectedSchema.properties);
|
|
2905
|
-
}
|
|
2906
|
-
for (const [key, child] of Object.entries(props || {})) {
|
|
2907
|
-
const childPath = `${path}/properties/${key}`;
|
|
2908
|
-
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2909
|
-
const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
|
|
2910
|
-
const resolved = dereference(child, root);
|
|
2911
|
-
if (!shouldHideChild) {
|
|
2912
|
-
children.push(React__default.createElement("li", { key: key },
|
|
2913
|
-
React__default.createElement(LazySchemaTreePreviewer, { schema: resolved, root: root, title: key, level: level + 1, path: childPath, hideData: hideData, complexData: complexData, parentRequired: schema === null || schema === void 0 ? void 0 : schema.required, propertyKey: key, _subType: (_a = resolved === null || resolved === void 0 ? void 0 : resolved.items) === null || _a === void 0 ? void 0 : _a.type })));
|
|
2914
|
-
}
|
|
2915
|
-
}
|
|
2916
|
-
}
|
|
2917
|
-
else if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'array' &&
|
|
2918
|
-
(schema === null || schema === void 0 ? void 0 : schema.items) &&
|
|
2919
|
-
Object.keys(schema === null || schema === void 0 ? void 0 : schema.items).length > 0 &&
|
|
2920
|
-
!((_b = schema === null || schema === void 0 ? void 0 : schema.items) === null || _b === void 0 ? void 0 : _b.circular)) {
|
|
2921
|
-
const resolvedItems = dereference(schema === null || schema === void 0 ? void 0 : schema.items, root);
|
|
2922
|
-
const itemsPath = `${path}/items`;
|
|
2923
|
-
if (resolvedItems && resolvedItems.type === 'object' && resolvedItems.properties) {
|
|
2924
|
-
for (const [key, child] of Object.entries(resolvedItems.properties)) {
|
|
2925
|
-
const childPath = `${itemsPath}/properties/${key}`;
|
|
2926
|
-
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2927
|
-
const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
|
|
2928
|
-
const resolved = dereference(child, root);
|
|
2929
|
-
if (!shouldHideChild) {
|
|
2930
|
-
children.push(React__default.createElement("li", { key: key },
|
|
2931
|
-
React__default.createElement(LazySchemaTreePreviewer, { schema: resolved, root: root, title: key, level: level + 2, path: childPath, hideData: hideData, complexData: complexData, parentRequired: resolvedItems.required, propertyKey: key, _subType: (_c = resolvedItems === null || resolvedItems === void 0 ? void 0 : resolvedItems.items) === null || _c === void 0 ? void 0 : _c.type })));
|
|
2932
|
-
}
|
|
2933
|
-
}
|
|
2934
|
-
}
|
|
2935
|
-
else if (resolvedItems && resolvedItems.type === 'array' && resolvedItems.items.length > 0) {
|
|
2936
|
-
const childPath = `${path}/items`;
|
|
2937
|
-
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2938
|
-
const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
|
|
2939
|
-
if (!shouldHideChild) {
|
|
2940
|
-
children.push(React__default.createElement("li", { key: "items" },
|
|
2941
|
-
React__default.createElement(LazySchemaTreePreviewer, { schema: resolvedItems, root: root, title: "items", level: level + 1, path: childPath, hideData: hideData, complexData: complexData, parentRequired: schema === null || schema === void 0 ? void 0 : schema.required, propertyKey: "items", _subType: (_d = resolvedItems === null || resolvedItems === void 0 ? void 0 : resolvedItems.items) === null || _d === void 0 ? void 0 : _d.type })));
|
|
2942
|
-
}
|
|
2943
|
-
}
|
|
2944
|
-
}
|
|
2945
|
-
return children.length > 0 ? React__default.createElement("ul", { className: "ml-6 border-l border-gray-200 pl-2" }, children) : null;
|
|
2946
|
-
};
|
|
2947
|
-
const combinedSchemaSelector = () => {
|
|
2948
|
-
var _a;
|
|
2949
|
-
return (React__default.createElement(React__default.Fragment, null,
|
|
2950
|
-
React__default.createElement(Box, { pos: "fixed", top: 0, left: 0, right: 0, bottom: 0, bg: "transparent", style: { zIndex: 999 }, onClick: () => setShowSchemaDropdown(false) }),
|
|
2951
|
-
React__default.createElement(Box, { pos: "absolute", bg: "canvas", rounded: true, boxShadow: "md", style: {
|
|
2952
|
-
zIndex: 1000,
|
|
2953
|
-
top: '100%',
|
|
2954
|
-
left: 0,
|
|
2955
|
-
minWidth: '150px',
|
|
2956
|
-
maxWidth: '200px',
|
|
2957
|
-
marginTop: '2px',
|
|
2958
|
-
border: '1px solid rgba(0, 0, 0, 0.1)',
|
|
2959
|
-
}, fontSize: "sm", onClick: (e) => e.stopPropagation() }, (_a = ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf))) === null || _a === void 0 ? void 0 : _a.map((schemaOption, index) => (React__default.createElement(Box, { key: index, px: 3, py: 2, cursor: "pointer", bg: selectedSchemaIndex === index ? 'primary-tint' : 'canvas', fontSize: "xs", display: "flex", alignItems: "center", style: {
|
|
2960
|
-
borderBottom: index < ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)).length - 1 ? '1px solid rgba(0, 0, 0, 0.1)' : 'none',
|
|
2961
|
-
gap: '8px',
|
|
2962
|
-
}, onMouseEnter: (e) => {
|
|
2963
|
-
if (selectedSchemaIndex !== index) {
|
|
2964
|
-
e.currentTarget.style.backgroundColor = 'var(--sl-color-canvas-tint)';
|
|
2965
|
-
}
|
|
2966
|
-
}, onMouseLeave: (e) => {
|
|
2967
|
-
if (selectedSchemaIndex !== index) {
|
|
2968
|
-
e.currentTarget.style.backgroundColor = 'var(--sl-color-canvas)';
|
|
2969
|
-
}
|
|
2970
|
-
}, onClick: () => {
|
|
2971
|
-
setSelectedSchemaIndex(index);
|
|
2972
|
-
setShowSchemaDropdown(false);
|
|
2973
|
-
} },
|
|
2974
|
-
React__default.createElement(Box, { flex: 1, color: "body" }, schemaOption.type || 'object'),
|
|
2975
|
-
selectedSchemaIndex === index && (React__default.createElement(Box, { color: "primary", fontSize: "xs" }, "\u2713"))))))));
|
|
2976
|
-
};
|
|
2977
|
-
const renderMinEnums = (schema) => {
|
|
2978
|
-
if (!schema || typeof schema !== 'object')
|
|
2979
|
-
return null;
|
|
2980
|
-
const boxStyle = {
|
|
2981
|
-
background: 'rgba(245, 247, 250, 0.5)',
|
|
2982
|
-
border: '1px solid #a0aec0',
|
|
2983
|
-
borderRadius: '4px',
|
|
2984
|
-
padding: '0px 2px',
|
|
2985
|
-
display: 'inline-block',
|
|
2986
|
-
overflowWrap: 'break-word',
|
|
2987
|
-
textAlign: 'left',
|
|
2988
|
-
maxWidth: 'fit-content',
|
|
2989
|
-
maxHeight: 'fit-content',
|
|
2990
|
-
};
|
|
2991
|
-
if ('minItems' in schema) {
|
|
2992
|
-
const schemaWithMinItems = schema;
|
|
2993
|
-
if (typeof schemaWithMinItems.minItems === 'number') {
|
|
2994
|
-
return (React__default.createElement(Box, { className: "sl-text-muted", fontFamily: "ui", fontWeight: "normal", mr: 2, style: boxStyle }, `>=${schemaWithMinItems.minItems} items`));
|
|
2995
|
-
}
|
|
2996
|
-
}
|
|
2997
|
-
if ('enum' in schema && Array.isArray(schema.enum)) {
|
|
2998
|
-
return (React__default.createElement("div", null,
|
|
2999
|
-
"Allowed values:",
|
|
3000
|
-
' ',
|
|
3001
|
-
schema.enum.map((val, idx) => (React__default.createElement(Box, { key: idx, className: "sl-text-muted", fontFamily: "ui", fontWeight: "normal", mr: 2, style: boxStyle }, val)))));
|
|
3002
|
-
}
|
|
3003
|
-
return null;
|
|
3004
|
-
};
|
|
3005
|
-
const isRequired = parentRequired && propertyKey && parentRequired.includes(propertyKey);
|
|
3006
|
-
let showRequiredLabel = false;
|
|
3007
|
-
const hideDataEntry = hideData.find(hideEntry => trimSlashes(hideEntry.path) === trimSlashes(path));
|
|
3008
|
-
if ((hideDataEntry === null || hideDataEntry === void 0 ? void 0 : hideDataEntry.required) === true || ((hideDataEntry === null || hideDataEntry === void 0 ? void 0 : hideDataEntry.required) === undefined && isRequired)) {
|
|
3009
|
-
showRequiredLabel = true;
|
|
3010
|
-
}
|
|
3011
|
-
if (schema === null || schema === void 0 ? void 0 : schema.$ref) {
|
|
3012
|
-
schema = dereference(schema, root);
|
|
3013
|
-
}
|
|
3014
|
-
return (React__default.createElement("div", { className: "mb-1" },
|
|
3015
|
-
React__default.createElement(Flex, { maxW: "full", pl: 3, py: 2, "data-test": "schema-row", pos: "relative" },
|
|
3016
|
-
React__default.createElement(VStack, { spacing: 1, maxW: "full", className: "w-full" },
|
|
3017
|
-
React__default.createElement(Flex, { onClick: !isRoot ? handleToggle : undefined, className: `w-full ${isRoot ? '' : 'cursor-pointer'}` },
|
|
3018
|
-
!isRoot ? (React__default.createElement(Box, { mr: 2, className: "sl-font-mono sl-font-semibold sl-mr-2" },
|
|
3019
|
-
!TYPES.includes(schema === null || schema === void 0 ? void 0 : schema.type) &&
|
|
3020
|
-
!detectCircularPath(path) &&
|
|
3021
|
-
!((_b = schema === null || schema === void 0 ? void 0 : schema.items) === null || _b === void 0 ? void 0 : _b.circular) &&
|
|
3022
|
-
!(schema === null || schema === void 0 ? void 0 : schema.circular) ? (React__default.createElement("i", { role: "img", "aria-hidden": "true", className: `sl-icon fal ${expanded ? 'fa-chevron-down' : 'fa-chevron-right'} fa-fw fa-sm` })) : (React__default.createElement("span", { className: "sl-icon fal fa-fw fa-sm", "aria-hidden": "true" })),
|
|
3023
|
-
' ' + displayTitle)) : null,
|
|
3024
|
-
!isRoot ? (React__default.createElement(Box, { mr: 2, pos: "relative" },
|
|
3025
|
-
React__default.createElement(Box, { display: "inline-flex", alignItems: "center", onMouseEnter: () => {
|
|
3026
|
-
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) {
|
|
3027
|
-
setIsHoveringSelector(true);
|
|
3028
|
-
}
|
|
3029
|
-
}, onMouseLeave: () => {
|
|
3030
|
-
if (!showSchemaDropdown) {
|
|
3031
|
-
setIsHoveringSelector(false);
|
|
3032
|
-
}
|
|
3033
|
-
}, onClick: (e) => {
|
|
3034
|
-
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) {
|
|
3035
|
-
e.stopPropagation();
|
|
3036
|
-
setShowSchemaDropdown(prev => !prev);
|
|
3037
|
-
}
|
|
3038
|
-
}, style: {
|
|
3039
|
-
cursor: (schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf) ? 'pointer' : 'default',
|
|
3040
|
-
} },
|
|
3041
|
-
React__default.createElement("span", { className: "sl-truncate sl-text-muted" },
|
|
3042
|
-
(() => {
|
|
3043
|
-
let typeDisplay = (schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && (schema === null || schema === void 0 ? void 0 : schema.title) ? schema === null || schema === void 0 ? void 0 : schema.title : (schema === null || schema === void 0 ? void 0 : schema.type) || (root === null || root === void 0 ? void 0 : root.title);
|
|
3044
|
-
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) && (schema === null || schema === void 0 ? void 0 : schema.anyOf.length) > 0) {
|
|
3045
|
-
return `any of ${typeDisplay}`;
|
|
3046
|
-
}
|
|
3047
|
-
else if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && (schema === null || schema === void 0 ? void 0 : schema.oneOf.length) > 0) {
|
|
3048
|
-
return `one of ${typeDisplay}`;
|
|
3049
|
-
}
|
|
3050
|
-
return typeDisplay;
|
|
3051
|
-
})(),
|
|
3052
|
-
(schema === null || schema === void 0 ? void 0 : schema.items) && ((_c = schema === null || schema === void 0 ? void 0 : schema.items) === null || _c === void 0 ? void 0 : _c.title) !== undefined ? ` [${(_d = schema === null || schema === void 0 ? void 0 : schema.items) === null || _d === void 0 ? void 0 : _d.title}] ` : null),
|
|
3053
|
-
((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) && (React__default.createElement(Box, { display: "inline-flex", alignItems: "center", ml: 1, style: {
|
|
3054
|
-
opacity: isHoveringSelector ? 1 : 0.6,
|
|
3055
|
-
transition: 'opacity 0.2s',
|
|
3056
|
-
} },
|
|
3057
|
-
React__default.createElement("i", { className: "sl-icon fas fa-chevron-down", style: {
|
|
3058
|
-
fontSize: '10px',
|
|
3059
|
-
opacity: 0.6,
|
|
3060
|
-
} })))),
|
|
3061
|
-
React__default.createElement("span", { className: "text-gray-500" }, (schema === null || schema === void 0 ? void 0 : schema.format) !== undefined ? `<${schema === null || schema === void 0 ? void 0 : schema.format}>` : null),
|
|
3062
|
-
((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) && showSchemaDropdown && combinedSchemaSelector())) : null),
|
|
3063
|
-
React__default.createElement(Flex, { pl: 1, w: "full", align: "start", direction: "col", style: { overflow: 'visible', paddingLeft: '20px' } },
|
|
3064
|
-
(schema === null || schema === void 0 ? void 0 : schema.description) && (React__default.createElement(Box, { fontFamily: "ui", fontWeight: "light" },
|
|
3065
|
-
React__default.createElement("span", { className: "sl-prose sl-markdown-viewer", style: { fontSize: '12px' } }, schema === null || schema === void 0 ? void 0 : schema.description))),
|
|
3066
|
-
!isRoot && (schema === null || schema === void 0 ? void 0 : schema.examples) !== undefined && (React__default.createElement(Flex, { align: "center", mb: 1, style: { flexWrap: 'wrap' } },
|
|
3067
|
-
React__default.createElement("span", { className: "text-gray-500", style: { marginRight: 8, flexShrink: 0 } }, "Example"),
|
|
3068
|
-
React__default.createElement(Box, { className: "sl-text-muted", fontFamily: "ui", fontWeight: "normal", mr: 2, style: {
|
|
3069
|
-
background: 'rgba(245, 247, 250, 0.5)',
|
|
3070
|
-
border: '1px solid #a0aec0',
|
|
3071
|
-
borderRadius: '4px',
|
|
3072
|
-
padding: '4px 8px',
|
|
3073
|
-
display: 'inline-block',
|
|
3074
|
-
overflowWrap: 'break-word',
|
|
3075
|
-
textAlign: 'left',
|
|
3076
|
-
maxWidth: '530px',
|
|
3077
|
-
} }, JSON.stringify(schema === null || schema === void 0 ? void 0 : schema.examples))))),
|
|
3078
|
-
React__default.createElement(Flex, { pl: 1, w: "full", align: "start", direction: "col", style: { overflow: 'visible', paddingLeft: '20px' } }, schema &&
|
|
3079
|
-
typeof schema === 'object' &&
|
|
3080
|
-
('minItems' in schema || 'enum' in schema) &&
|
|
3081
|
-
renderMinEnums(schema))),
|
|
3082
|
-
!isRoot && (React__default.createElement("label", { className: "inline-flex items-top ml-2" },
|
|
3083
|
-
React__default.createElement(Box, { mr: 2, fontFamily: "ui", fontWeight: "normal" }, showRequiredLabel && (React__default.createElement("div", { className: "sl-ml-2 sl-text-warning" },
|
|
3084
|
-
React__default.createElement("span", { style: { marginLeft: '10px' } }, "required"))))))),
|
|
3085
|
-
renderChildren()));
|
|
3086
|
-
};
|
|
3087
|
-
|
|
3088
2741
|
const isBodyEmpty = (body) => {
|
|
3089
2742
|
if (!body)
|
|
3090
2743
|
return true;
|
|
3091
2744
|
const { contents = [], description } = body;
|
|
3092
2745
|
return contents.length === 0 && !(description === null || description === void 0 ? void 0 : description.trim());
|
|
3093
2746
|
};
|
|
3094
|
-
const Body = ({ body, onChange, isHttpWebhookOperation = false
|
|
2747
|
+
const Body = ({ body, onChange, isHttpWebhookOperation = false }) => {
|
|
3095
2748
|
var _a;
|
|
3096
2749
|
const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
|
|
3097
2750
|
const [chosenContent, setChosenContent] = React.useState(0);
|
|
@@ -3104,36 +2757,13 @@ const Body = ({ body, onChange, isHttpWebhookOperation = false, disableProps })
|
|
|
3104
2757
|
const { contents = [], description } = body;
|
|
3105
2758
|
const schema = (_a = contents[chosenContent]) === null || _a === void 0 ? void 0 : _a.schema;
|
|
3106
2759
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: body.id, attr: 'description' });
|
|
3107
|
-
const getMaskProperties = () => {
|
|
3108
|
-
const disablePropsConfig = disableProps || [];
|
|
3109
|
-
const absolutePathsToHide = [];
|
|
3110
|
-
disablePropsConfig.forEach(configEntry => {
|
|
3111
|
-
const { location, paths, isComplex } = configEntry;
|
|
3112
|
-
if (paths.length === 0 && !isComplex) {
|
|
3113
|
-
absolutePathsToHide.push({ path: location });
|
|
3114
|
-
}
|
|
3115
|
-
else {
|
|
3116
|
-
paths.forEach((item) => {
|
|
3117
|
-
const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
|
|
3118
|
-
let object = { path: fullPath };
|
|
3119
|
-
if (item.hasOwnProperty('required')) {
|
|
3120
|
-
object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
|
|
3121
|
-
}
|
|
3122
|
-
absolutePathsToHide.push(object);
|
|
3123
|
-
});
|
|
3124
|
-
}
|
|
3125
|
-
});
|
|
3126
|
-
return absolutePathsToHide;
|
|
3127
|
-
};
|
|
3128
|
-
const shouldUseLazySchema = disableProps === null || disableProps === void 0 ? void 0 : disableProps.some(entry => entry.isComplex === true);
|
|
3129
|
-
console.log('!!!!! shouldUseLazySchema body!!!!', shouldUseLazySchema);
|
|
3130
2760
|
return (React.createElement(VStack, { spacing: 6 },
|
|
3131
2761
|
React.createElement(SectionSubtitle, { title: "Body", id: "request-body" }, contents.length > 0 && (React.createElement(Flex, { flex: 1, justify: "end" },
|
|
3132
2762
|
React.createElement(Select, { "aria-label": "Request Body Content Type", value: String(chosenContent), onChange: value => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" })))),
|
|
3133
2763
|
description && (React.createElement(Box, { pos: "relative" },
|
|
3134
2764
|
React.createElement(MarkdownViewer, { markdown: description }),
|
|
3135
2765
|
React.createElement(NodeAnnotation, { change: descriptionChanged }))),
|
|
3136
|
-
|
|
2766
|
+
isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: isHttpWebhookOperation ? 'standalone' : 'write', renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))));
|
|
3137
2767
|
};
|
|
3138
2768
|
Body.displayName = 'HttpOperation.Body';
|
|
3139
2769
|
|
|
@@ -3200,7 +2830,7 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
|
3200
2830
|
return schema;
|
|
3201
2831
|
};
|
|
3202
2832
|
|
|
3203
|
-
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false,
|
|
2833
|
+
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false, }) => {
|
|
3204
2834
|
if (!request || typeof request !== 'object')
|
|
3205
2835
|
return null;
|
|
3206
2836
|
const bodyIsEmpty = isBodyEmpty(body);
|
|
@@ -3228,7 +2858,7 @@ const Request = ({ operation: { request, request: { path: pathParams = [], heade
|
|
|
3228
2858
|
cookieParams.length > 0 && (React.createElement(VStack, { spacing: 5 },
|
|
3229
2859
|
React.createElement(SectionSubtitle, { title: "Cookies", id: "request-cookies" }),
|
|
3230
2860
|
React.createElement(Parameters, { parameterType: "cookie", parameters: cookieParams }))),
|
|
3231
|
-
body &&
|
|
2861
|
+
body && React.createElement(Body, { onChange: onChange, body: body, isHttpWebhookOperation: isHttpWebhookOperation })));
|
|
3232
2862
|
};
|
|
3233
2863
|
Request.displayName = 'HttpOperation.Request';
|
|
3234
2864
|
const schemeExpandedState = atomWithStorage('HttpOperation_security_expanded', {});
|
|
@@ -3259,7 +2889,7 @@ const OptionalMessage$1 = () => {
|
|
|
3259
2889
|
return React.createElement(Callout, { appearance: "outline" }, OptionalSecurityMessage);
|
|
3260
2890
|
};
|
|
3261
2891
|
|
|
3262
|
-
const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange, isCompact,
|
|
2892
|
+
const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange, isCompact, }) => {
|
|
3263
2893
|
var _a, _b;
|
|
3264
2894
|
const responses = sortBy(uniqBy(unsortedResponses, r => r.code), r => r.code);
|
|
3265
2895
|
const [activeResponseId, setActiveResponseId] = React.useState((_b = (_a = responses[0]) === null || _a === void 0 ? void 0 : _a.code) !== null && _b !== void 0 ? _b : '');
|
|
@@ -3292,12 +2922,11 @@ const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTy
|
|
|
3292
2922
|
const tabResponses = (React.createElement(TabList, { density: "compact" }, responses.map(({ code }) => (React.createElement(Tab, { key: code, id: code, intent: codeToIntentVal(code) }, code)))));
|
|
3293
2923
|
return (React.createElement(VStack, { spacing: 8, as: Tabs, selectedId: activeResponseId, onChange: setActiveResponseId, appearance: "pill" },
|
|
3294
2924
|
React.createElement(SectionTitle, { title: "Responses", isCompact: isCompact }, isCompact ? compactResponses : tabResponses),
|
|
3295
|
-
isCompact ? (React.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange
|
|
3296
|
-
React.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange
|
|
2925
|
+
isCompact ? (React.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange })) : (React.createElement(TabPanels, { p: 0 }, responses.map(response => (React.createElement(TabPanel, { key: response.code, id: response.code },
|
|
2926
|
+
React.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange }))))))));
|
|
3297
2927
|
};
|
|
3298
2928
|
Responses.displayName = 'HttpOperation.Responses';
|
|
3299
|
-
const Response = ({ response, onMediaTypeChange
|
|
3300
|
-
var _a, _b;
|
|
2929
|
+
const Response = ({ response, onMediaTypeChange }) => {
|
|
3301
2930
|
const { contents = [], headers = [], description } = response;
|
|
3302
2931
|
const [chosenContent, setChosenContent] = React.useState(0);
|
|
3303
2932
|
const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
|
|
@@ -3308,29 +2937,6 @@ const Response = ({ response, onMediaTypeChange, disableProps, statusCode }) =>
|
|
|
3308
2937
|
responseContent && (onMediaTypeChange === null || onMediaTypeChange === void 0 ? void 0 : onMediaTypeChange(responseContent.mediaType));
|
|
3309
2938
|
}, [responseContent]);
|
|
3310
2939
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: response.id, attr: 'description' });
|
|
3311
|
-
const getMaskProperties = () => {
|
|
3312
|
-
if (!disableProps || !statusCode)
|
|
3313
|
-
return [];
|
|
3314
|
-
const configEntries = disableProps[statusCode] || [];
|
|
3315
|
-
const absolutePathsToHide = [];
|
|
3316
|
-
configEntries.forEach(({ location, paths, isComplex }) => {
|
|
3317
|
-
if (paths.length === 0 && !isComplex) {
|
|
3318
|
-
absolutePathsToHide.push({ path: location });
|
|
3319
|
-
}
|
|
3320
|
-
else {
|
|
3321
|
-
paths.forEach((item) => {
|
|
3322
|
-
const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
|
|
3323
|
-
let object = { path: fullPath };
|
|
3324
|
-
if (item.hasOwnProperty('required')) {
|
|
3325
|
-
object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
|
|
3326
|
-
}
|
|
3327
|
-
absolutePathsToHide.push(object);
|
|
3328
|
-
});
|
|
3329
|
-
}
|
|
3330
|
-
});
|
|
3331
|
-
return absolutePathsToHide;
|
|
3332
|
-
};
|
|
3333
|
-
const shouldUseLazySchema = (_b = (statusCode && ((_a = disableProps === null || disableProps === void 0 ? void 0 : disableProps[statusCode]) === null || _a === void 0 ? void 0 : _a.some(entry => entry.isComplex)))) !== null && _b !== void 0 ? _b : false;
|
|
3334
2940
|
return (React.createElement(VStack, { spacing: 8, pt: 8 },
|
|
3335
2941
|
description && (React.createElement(Box, { pos: "relative" },
|
|
3336
2942
|
React.createElement(MarkdownViewer, { markdown: description }),
|
|
@@ -3342,7 +2948,7 @@ const Response = ({ response, onMediaTypeChange, disableProps, statusCode }) =>
|
|
|
3342
2948
|
React.createElement(SectionSubtitle, { title: "Body", id: "response-body" },
|
|
3343
2949
|
React.createElement(Flex, { flex: 1, justify: "end" },
|
|
3344
2950
|
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" }))),
|
|
3345
|
-
schema &&
|
|
2951
|
+
schema && (React.createElement(JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, maxRefDepth: maxRefDepth, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))))));
|
|
3346
2952
|
};
|
|
3347
2953
|
Response.displayName = 'HttpOperation.Response';
|
|
3348
2954
|
const codeToIntentVal = (code) => {
|
|
@@ -3391,7 +2997,7 @@ const Callback = ({ data, isCompact }) => {
|
|
|
3391
2997
|
};
|
|
3392
2998
|
Callbacks.displayName = 'HttpOperation.Callback';
|
|
3393
2999
|
|
|
3394
|
-
const HttpOperationComponent = React.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy
|
|
3000
|
+
const HttpOperationComponent = React.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy }) => {
|
|
3395
3001
|
var _a;
|
|
3396
3002
|
const { nodeHasChanged } = useOptionsCtx();
|
|
3397
3003
|
const data = useResolvedObject(unresolvedData);
|
|
@@ -3422,11 +3028,11 @@ const HttpOperationComponent = React.memo(({ className, data: unresolvedData, la
|
|
|
3422
3028
|
React.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
|
|
3423
3029
|
React.createElement(NodeAnnotation, { change: descriptionChanged }))),
|
|
3424
3030
|
React.createElement(NodeVendorExtensions, { data: data }),
|
|
3425
|
-
React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo, isHttpWebhookOperation: isHttpWebhookOperation(data)
|
|
3426
|
-
data.responses && (React.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact
|
|
3031
|
+
React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo, isHttpWebhookOperation: isHttpWebhookOperation(data) }),
|
|
3032
|
+
data.responses && (React.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact })),
|
|
3427
3033
|
((_a = data.callbacks) === null || _a === void 0 ? void 0 : _a.length) ? React.createElement(Callbacks, { callbacks: data.callbacks, isCompact: isCompact }) : null,
|
|
3428
3034
|
isCompact && tryItPanel));
|
|
3429
|
-
return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('HttpOperation', className), header: header, left: description, right: !
|
|
3035
|
+
return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('HttpOperation', className), header: header, left: description, right: !isCompact && tryItPanel }));
|
|
3430
3036
|
});
|
|
3431
3037
|
HttpOperationComponent.displayName = 'HttpOperation.Component';
|
|
3432
3038
|
const HttpOperation = withErrorBoundary(HttpOperationComponent, {
|
|
@@ -3677,7 +3283,7 @@ const HttpServiceComponent = React.memo(({ data: unresolvedData, location = {},
|
|
|
3677
3283
|
HttpServiceComponent.displayName = 'HttpService.Component';
|
|
3678
3284
|
const HttpService = withErrorBoundary(HttpServiceComponent, { recoverableProps: ['data'] });
|
|
3679
3285
|
|
|
3680
|
-
const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOptions, exportProps,
|
|
3286
|
+
const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOptions, exportProps, }) => {
|
|
3681
3287
|
var _a, _b;
|
|
3682
3288
|
const [resolveRef, maxRefDepth] = useSchemaInlineRefResolver();
|
|
3683
3289
|
const data = useResolvedObject(unresolvedData);
|
|
@@ -3700,40 +3306,14 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
3700
3306
|
exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && !isCompact && React.createElement(ExportButton, Object.assign({}, exportProps))));
|
|
3701
3307
|
const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && React.createElement(ModelExamples, { data: data, isCollapsible: isCompact });
|
|
3702
3308
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId, attr: 'description' });
|
|
3703
|
-
const getMaskProperties = () => {
|
|
3704
|
-
const disablePropsConfig = disableProps === null || disableProps === void 0 ? void 0 : disableProps.models;
|
|
3705
|
-
const absolutePathsToHide = [];
|
|
3706
|
-
if (disableProps === null || disableProps === void 0 ? void 0 : disableProps.models) {
|
|
3707
|
-
disablePropsConfig.forEach((configEntry) => {
|
|
3708
|
-
const { location, paths, isComplex } = configEntry;
|
|
3709
|
-
if (paths.length === 0 && !isComplex) {
|
|
3710
|
-
absolutePathsToHide.push({ path: location });
|
|
3711
|
-
}
|
|
3712
|
-
else {
|
|
3713
|
-
paths.forEach((item) => {
|
|
3714
|
-
const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
|
|
3715
|
-
let object = { path: fullPath };
|
|
3716
|
-
if (item.hasOwnProperty('required')) {
|
|
3717
|
-
object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
|
|
3718
|
-
}
|
|
3719
|
-
absolutePathsToHide.push(object);
|
|
3720
|
-
});
|
|
3721
|
-
}
|
|
3722
|
-
});
|
|
3723
|
-
}
|
|
3724
|
-
return absolutePathsToHide;
|
|
3725
|
-
};
|
|
3726
|
-
const shouldUseLazySchema = disableProps && (disableProps === null || disableProps === void 0 ? void 0 : disableProps.models)
|
|
3727
|
-
? disableProps.models.some((entry) => entry.isComplex === true)
|
|
3728
|
-
: false;
|
|
3729
3309
|
const description = (React.createElement(VStack, { spacing: 10 },
|
|
3730
3310
|
data.description && data.type === 'object' && (React.createElement(Box, { pos: "relative" },
|
|
3731
3311
|
React.createElement(MarkdownViewer, { role: "textbox", markdown: data.description }),
|
|
3732
3312
|
React.createElement(NodeAnnotation, { change: descriptionChanged }))),
|
|
3733
3313
|
React.createElement(NodeVendorExtensions, { data: data }),
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('Model', className), header: header, left: description, right: !
|
|
3314
|
+
isCompact && modelExamples,
|
|
3315
|
+
React.createElement(JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(data), nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon, skipTopLevelDescription: true })));
|
|
3316
|
+
return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('Model', className), header: header, left: description, right: !isCompact && modelExamples }));
|
|
3737
3317
|
};
|
|
3738
3318
|
const ModelExamples = React.memo(({ data, isCollapsible = false }) => {
|
|
3739
3319
|
var _a;
|
|
@@ -3755,41 +3335,30 @@ const Model = withErrorBoundary(ModelComponent, { recoverableProps: ['data'] });
|
|
|
3755
3335
|
|
|
3756
3336
|
const Docs = React.memo((_a) => {
|
|
3757
3337
|
var _b;
|
|
3758
|
-
var { nodeType, nodeData,
|
|
3338
|
+
var { nodeType, nodeData, useNodeForRefResolving = false, refResolver, maxRefDepth, nodeHasChanged, renderExtensionAddon } = _a, commonProps = __rest(_a, ["nodeType", "nodeData", "useNodeForRefResolving", "refResolver", "maxRefDepth", "nodeHasChanged", "renderExtensionAddon"]);
|
|
3759
3339
|
const parsedNode = useParsedData(nodeType, nodeData);
|
|
3760
3340
|
if (!parsedNode) {
|
|
3761
3341
|
(_b = commonProps.nodeUnsupported) === null || _b === void 0 ? void 0 : _b.call(commonProps, 'dataEmpty');
|
|
3762
3342
|
return null;
|
|
3763
3343
|
}
|
|
3764
|
-
let elem = React.createElement(ParsedDocs, Object.assign({ node: parsedNode
|
|
3344
|
+
let elem = React.createElement(ParsedDocs, Object.assign({ node: parsedNode }, commonProps));
|
|
3765
3345
|
if (useNodeForRefResolving) {
|
|
3766
3346
|
elem = (React.createElement(InlineRefResolverProvider, { document: parsedNode.data, resolver: refResolver, maxRefDepth: maxRefDepth }, elem));
|
|
3767
3347
|
}
|
|
3768
3348
|
return (React.createElement(ElementsOptionsProvider, { nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }, elem));
|
|
3769
3349
|
});
|
|
3770
|
-
const getTryItVisibility = (disableProps) => {
|
|
3771
|
-
var _a, _b, _c, _d;
|
|
3772
|
-
if (!disableProps)
|
|
3773
|
-
return { hideOperationTryIt: false, hideModelTryIt: false };
|
|
3774
|
-
const requestHasComplex = (_b = (_a = disableProps.request) === null || _a === void 0 ? void 0 : _a.some(item => item.isComplex)) !== null && _b !== void 0 ? _b : false;
|
|
3775
|
-
const responseHasComplex = Object.values(disableProps.response || {}).some(arr => arr.some(item => item.isComplex));
|
|
3776
|
-
const hideOperationTryIt = requestHasComplex || responseHasComplex;
|
|
3777
|
-
const hideModelTryIt = (_d = (_c = disableProps.models) === null || _c === void 0 ? void 0 : _c.some(item => item.isComplex)) !== null && _d !== void 0 ? _d : false;
|
|
3778
|
-
return { hideOperationTryIt, hideModelTryIt };
|
|
3779
|
-
};
|
|
3780
3350
|
const ParsedDocs = (_a) => {
|
|
3781
|
-
var { node, nodeUnsupported
|
|
3782
|
-
const { hideOperationTryIt, hideModelTryIt } = getTryItVisibility(disableProps);
|
|
3351
|
+
var { node, nodeUnsupported } = _a, commonProps = __rest(_a, ["node", "nodeUnsupported"]);
|
|
3783
3352
|
switch (node.type) {
|
|
3784
3353
|
case 'article':
|
|
3785
3354
|
return React.createElement(Article, Object.assign({ data: node.data }, commonProps));
|
|
3786
3355
|
case 'http_operation':
|
|
3787
3356
|
case 'http_webhook':
|
|
3788
|
-
return React.createElement(HttpOperation, Object.assign({ data: node.data
|
|
3357
|
+
return React.createElement(HttpOperation, Object.assign({ data: node.data }, commonProps));
|
|
3789
3358
|
case 'http_service':
|
|
3790
3359
|
return React.createElement(HttpService, Object.assign({ data: node.data }, commonProps));
|
|
3791
3360
|
case 'model':
|
|
3792
|
-
return React.createElement(Model, Object.assign({ data: node.data
|
|
3361
|
+
return React.createElement(Model, Object.assign({ data: node.data }, commonProps));
|
|
3793
3362
|
default:
|
|
3794
3363
|
nodeUnsupported === null || nodeUnsupported === void 0 ? void 0 : nodeUnsupported('invalidType');
|
|
3795
3364
|
return null;
|