@clarify-labs/renderer 0.11.3 → 0.11.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.
- package/output/{ClarifyShell-D25PYLE0.cjs → ClarifyShell-BbD82nrc.cjs} +50 -22
- package/output/ClarifyShell-BbD82nrc.cjs.map +1 -0
- package/output/{ClarifyShell-4hlqrEgp.js → ClarifyShell-BwqLbTI-.js} +50 -22
- package/output/ClarifyShell-BwqLbTI-.js.map +1 -0
- package/output/{MermaidViewer-kbSVqJ_z.cjs → MermaidViewer-CO1rhB6A.cjs} +2 -2
- package/output/{MermaidViewer-kbSVqJ_z.cjs.map → MermaidViewer-CO1rhB6A.cjs.map} +1 -1
- package/output/{MermaidViewer-D4h-WEak.js → MermaidViewer-D1wiX_T9.js} +2 -2
- package/output/{MermaidViewer-D4h-WEak.js.map → MermaidViewer-D1wiX_T9.js.map} +1 -1
- package/output/{OpenApiOperation-HhSjad7q.cjs → OpenApiOperation-C77uiDjW.cjs} +271 -88
- package/output/OpenApiOperation-C77uiDjW.cjs.map +1 -0
- package/output/{OpenApiOperation-BcJYHwft.js → OpenApiOperation-CbdKZMO1.js} +270 -87
- package/output/OpenApiOperation-CbdKZMO1.js.map +1 -0
- package/output/{PageActions-Bnz5Bybt.js → PageActions-DviEypf6.js} +43 -45
- package/output/PageActions-DviEypf6.js.map +1 -0
- package/output/{PageActions-GVAsO16x.cjs → PageActions-ob2OJusG.cjs} +46 -48
- package/output/PageActions-ob2OJusG.cjs.map +1 -0
- package/output/{SearchDialog-DL5Y_bQ0.js → SearchDialog-89JAjQMh.js} +3 -3
- package/output/{SearchDialog-DL5Y_bQ0.js.map → SearchDialog-89JAjQMh.js.map} +1 -1
- package/output/{SearchDialog-CFMl0YAZ.cjs → SearchDialog-CTiUIKeo.cjs} +3 -3
- package/output/{SearchDialog-CFMl0YAZ.cjs.map → SearchDialog-CTiUIKeo.cjs.map} +1 -1
- package/output/app/AppShell.d.ts +1 -0
- package/output/app/ContentDiagnostic.d.ts +1 -1
- package/output/app/PageActions.d.ts +1 -1
- package/output/client.cjs +3 -3
- package/output/client.js +3 -3
- package/output/core/i18n.d.ts +2 -1
- package/output/{i18n-sJUQQLRZ.js → i18n-Cff810G_.js} +11 -3
- package/output/i18n-Cff810G_.js.map +1 -0
- package/output/{i18n-R08i532P.cjs → i18n-Cjfk1N7i.cjs} +11 -3
- package/output/i18n-Cjfk1N7i.cjs.map +1 -0
- package/output/index.cjs +30 -30
- package/output/index.cjs.map +1 -1
- package/output/index.js +30 -30
- package/output/index.js.map +1 -1
- package/output/openapi/components/ExamplePanels.d.ts +3 -1
- package/output/openapi/components/OpenApiDocumentSection.d.ts +1 -0
- package/output/openapi/components/OpenApiRequest.d.ts +1 -0
- package/output/openapi/components/SchemaProperties.d.ts +8 -0
- package/output/openapi/components/SchemaSearch.d.ts +20 -0
- package/output/openapi/components/useOpenApiRequestState.d.ts +1 -1
- package/output/openapi/entry.d.ts +4 -3
- package/output/openapi/lib/helpers.d.ts +3 -0
- package/output/openapi/lib/utils.d.ts +1 -0
- package/output/preview.cjs +4 -4
- package/output/preview.cjs.map +1 -1
- package/output/preview.js +4 -4
- package/output/preview.js.map +1 -1
- package/output/{render-BuWbLXJW.cjs → render-BhVJVa1q.cjs} +2 -2
- package/output/{render-BuWbLXJW.cjs.map → render-BhVJVa1q.cjs.map} +1 -1
- package/output/{render-tWo_ruCT.js → render-PDmRKKJm.js} +2 -2
- package/output/{render-tWo_ruCT.js.map → render-PDmRKKJm.js.map} +1 -1
- package/output/renderer.css +67 -28
- package/output/server.cjs +2 -2
- package/output/server.js +2 -2
- package/package.json +1 -1
- package/output/ClarifyShell-4hlqrEgp.js.map +0 -1
- package/output/ClarifyShell-D25PYLE0.cjs.map +0 -1
- package/output/OpenApiOperation-BcJYHwft.js.map +0 -1
- package/output/OpenApiOperation-HhSjad7q.cjs.map +0 -1
- package/output/PageActions-Bnz5Bybt.js.map +0 -1
- package/output/PageActions-GVAsO16x.cjs.map +0 -1
- package/output/i18n-R08i532P.cjs.map +0 -1
- package/output/i18n-sJUQQLRZ.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as useConfig, s as useLocale, t as useBuiltInText } from "./i18n-
|
|
2
|
-
import { C as isExternalHref, E as copyTextToClipboard, c as lucideIconRegistry, h as useTheme, l as resolveLucideIconName,
|
|
1
|
+
import { a as useConfig, s as useLocale, t as useBuiltInText } from "./i18n-Cff810G_.js";
|
|
2
|
+
import { C as isExternalHref, E as copyTextToClipboard, c as lucideIconRegistry, h as useTheme, l as resolveLucideIconName, o as useSectionStore, s as remToPx, t as PageActions, w as localizeHref } from "./PageActions-DviEypf6.js";
|
|
3
3
|
import { t as markdownRemarkPlugins } from "./remark-C9iRQM0R.js";
|
|
4
4
|
import clsx from "clsx";
|
|
5
5
|
import { Children, Suspense, cloneElement, createContext, createElement, forwardRef, isValidElement, lazy, useContext, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
@@ -253,7 +253,7 @@ function Card(arg0) {
|
|
|
253
253
|
}
|
|
254
254
|
//#endregion
|
|
255
255
|
//#region source/components/Mermaid.tsx
|
|
256
|
-
var MermaidViewer = lazy(() => import("./MermaidViewer-
|
|
256
|
+
var MermaidViewer = lazy(() => import("./MermaidViewer-D1wiX_T9.js"));
|
|
257
257
|
var mermaidModulePromise;
|
|
258
258
|
async function loadMermaid() {
|
|
259
259
|
mermaidModulePromise = mermaidModulePromise ?? import("mermaid").then((module) => module.default);
|
|
@@ -496,10 +496,14 @@ function CodeGroupHeader(arg0) {
|
|
|
496
496
|
}
|
|
497
497
|
function CodeGroupPanels(arg0) {
|
|
498
498
|
const { children, ...props } = arg0;
|
|
499
|
-
if (Children.count(children) > 1) return /* @__PURE__ */ jsx(TabPanels, { children: Children.map(children, (child) => /* @__PURE__ */ jsx(TabPanel, {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
499
|
+
if (Children.count(children) > 1) return /* @__PURE__ */ jsx(TabPanels, { children: Children.map(children, (child) => /* @__PURE__ */ jsx(TabPanel, {
|
|
500
|
+
static: true,
|
|
501
|
+
className: "hidden data-selected:block",
|
|
502
|
+
children: /* @__PURE__ */ jsx(CodePanel, {
|
|
503
|
+
...props,
|
|
504
|
+
children: child
|
|
505
|
+
})
|
|
506
|
+
})) });
|
|
503
507
|
return /* @__PURE__ */ jsx(CodePanel, {
|
|
504
508
|
...props,
|
|
505
509
|
children
|
|
@@ -1052,7 +1056,8 @@ function Tabs(arg0) {
|
|
|
1052
1056
|
}), /* @__PURE__ */ jsx(TabPanels, {
|
|
1053
1057
|
className: panelsClassName ?? "mt-5",
|
|
1054
1058
|
children: resolvedItems.map((item) => /* @__PURE__ */ jsx(TabPanel, {
|
|
1055
|
-
|
|
1059
|
+
static: true,
|
|
1060
|
+
className: ({ selected }) => clsx("focus:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)", !selected && "hidden"),
|
|
1056
1061
|
children: item.panel
|
|
1057
1062
|
}, item.id))
|
|
1058
1063
|
})]
|
|
@@ -1265,12 +1270,15 @@ var primitives_exports = /* @__PURE__ */ __exportAll({
|
|
|
1265
1270
|
});
|
|
1266
1271
|
function wrapper(arg0) {
|
|
1267
1272
|
const { children } = arg0;
|
|
1268
|
-
return /* @__PURE__ */
|
|
1269
|
-
className: "clarify-mdx-page flex h-full min-w-0 flex-col pt-14 pb-10",
|
|
1270
|
-
children: /* @__PURE__ */ jsx(
|
|
1273
|
+
return /* @__PURE__ */ jsxs("article", {
|
|
1274
|
+
className: "clarify-mdx-page relative flex h-full min-w-0 flex-col pt-14 pb-10",
|
|
1275
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
1276
|
+
className: "clarify-page-actions mb-4 flex justify-end sm:absolute sm:top-14 sm:right-0 sm:mb-0",
|
|
1277
|
+
children: /* @__PURE__ */ jsx(PageActions, {})
|
|
1278
|
+
}), /* @__PURE__ */ jsx(Prose, {
|
|
1271
1279
|
className: "flex-auto",
|
|
1272
1280
|
children
|
|
1273
|
-
})
|
|
1281
|
+
})]
|
|
1274
1282
|
});
|
|
1275
1283
|
}
|
|
1276
1284
|
function table(arg0) {
|
|
@@ -1292,13 +1300,10 @@ function a(arg0) {
|
|
|
1292
1300
|
}
|
|
1293
1301
|
function h1(arg0) {
|
|
1294
1302
|
const { children, className, ...props } = arg0;
|
|
1295
|
-
return /* @__PURE__ */
|
|
1296
|
-
className: "clarify-page-title
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
...props,
|
|
1300
|
-
children
|
|
1301
|
-
}), /* @__PURE__ */ jsx(PageTitleActions, {})]
|
|
1303
|
+
return /* @__PURE__ */ jsx("h1", {
|
|
1304
|
+
className: clsx("clarify-page-title min-w-0 flex-1", className),
|
|
1305
|
+
...props,
|
|
1306
|
+
children
|
|
1302
1307
|
});
|
|
1303
1308
|
}
|
|
1304
1309
|
var code = Code;
|
|
@@ -1483,6 +1488,57 @@ function resolveRequestSchema(spec, schema) {
|
|
|
1483
1488
|
delete ownSchema.allOf;
|
|
1484
1489
|
return mergeAllOfSchemas(spec, [...allOf, ownSchema]);
|
|
1485
1490
|
}
|
|
1491
|
+
function fuzzyMatch(value, query) {
|
|
1492
|
+
const candidate = value.toLocaleLowerCase();
|
|
1493
|
+
const needle = query.trim().toLocaleLowerCase();
|
|
1494
|
+
let candidateIndex = 0;
|
|
1495
|
+
for (const character of needle) {
|
|
1496
|
+
candidateIndex = candidate.indexOf(character, candidateIndex);
|
|
1497
|
+
if (candidateIndex === -1) return false;
|
|
1498
|
+
candidateIndex += 1;
|
|
1499
|
+
}
|
|
1500
|
+
return true;
|
|
1501
|
+
}
|
|
1502
|
+
var noExampleMatch = Symbol("no-example-match");
|
|
1503
|
+
function getSchemaSearchText(name, schema) {
|
|
1504
|
+
if (!isRecord$1(schema)) return name;
|
|
1505
|
+
return [
|
|
1506
|
+
name,
|
|
1507
|
+
schema.type,
|
|
1508
|
+
schema.description,
|
|
1509
|
+
schema.pattern,
|
|
1510
|
+
schema.const,
|
|
1511
|
+
schema.default,
|
|
1512
|
+
schema.minimum,
|
|
1513
|
+
schema.maximum,
|
|
1514
|
+
schema.additionalProperties
|
|
1515
|
+
].filter((value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean").join(" ");
|
|
1516
|
+
}
|
|
1517
|
+
function filterExampleValue(spec, schema, value, query) {
|
|
1518
|
+
const resolved = resolveRequestSchema(spec, schema);
|
|
1519
|
+
if (Array.isArray(value)) {
|
|
1520
|
+
const itemSchema = isRecord$1(resolved) ? resolved.items : void 0;
|
|
1521
|
+
const items = value.map((item) => filterExampleValue(spec, itemSchema, item, query)).filter((item) => item !== noExampleMatch);
|
|
1522
|
+
return items.length > 0 ? items : noExampleMatch;
|
|
1523
|
+
}
|
|
1524
|
+
if (isRecord$1(value)) {
|
|
1525
|
+
const properties = isRecord$1(resolved) && isRecord$1(resolved.properties) ? resolved.properties : {};
|
|
1526
|
+
const filtered = Object.entries(value).flatMap(([name, propertyValue]) => {
|
|
1527
|
+
const propertySchema = properties[name] ?? (isRecord$1(resolved) && isRecord$1(resolved.additionalProperties) ? resolved.additionalProperties : void 0);
|
|
1528
|
+
if (fuzzyMatch(getSchemaSearchText(name, resolveRequestSchema(spec, propertySchema)), query)) return [[name, propertyValue]];
|
|
1529
|
+
const child = filterExampleValue(spec, propertySchema, propertyValue, query);
|
|
1530
|
+
return child === noExampleMatch ? [] : [[name, child]];
|
|
1531
|
+
});
|
|
1532
|
+
return filtered.length > 0 ? Object.fromEntries(filtered) : noExampleMatch;
|
|
1533
|
+
}
|
|
1534
|
+
return fuzzyMatch(getSchemaSearchText("", resolved), query) ? value : noExampleMatch;
|
|
1535
|
+
}
|
|
1536
|
+
function filterExampleBySchema(spec, schema, value, query) {
|
|
1537
|
+
if (!query.trim()) return value;
|
|
1538
|
+
const filtered = filterExampleValue(spec, schema, value, query);
|
|
1539
|
+
if (filtered !== noExampleMatch) return filtered;
|
|
1540
|
+
return Array.isArray(value) ? [] : isRecord$1(value) ? {} : value;
|
|
1541
|
+
}
|
|
1486
1542
|
function getPathItem$1(spec, path) {
|
|
1487
1543
|
return resolveObjectRef(spec, spec.paths?.[path]);
|
|
1488
1544
|
}
|
|
@@ -1693,9 +1749,6 @@ function normalizeOpenApiOperationSectionId(operation, method, path, source) {
|
|
|
1693
1749
|
if (typeof sectionId !== "string" || !sectionId) operation[CLARIFY_OPENAPI_SECTION_ID_EXTENSION] = createOpenApiOperationSectionId(operation, method, path, source);
|
|
1694
1750
|
return operation;
|
|
1695
1751
|
}
|
|
1696
|
-
function isOpenAPIHttpMethod(method) {
|
|
1697
|
-
return OPENAPI_HTTP_METHODS.includes(method.toLowerCase());
|
|
1698
|
-
}
|
|
1699
1752
|
function isRecord(value) {
|
|
1700
1753
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1701
1754
|
}
|
|
@@ -1731,19 +1784,9 @@ function listOperationsFromPathItems(items, source, spec) {
|
|
|
1731
1784
|
}
|
|
1732
1785
|
return operations;
|
|
1733
1786
|
}
|
|
1734
|
-
function
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
const sources = source ? [source] : ["path", "webhook"];
|
|
1738
|
-
for (const currentSource of sources) {
|
|
1739
|
-
const operation = (currentSource === "webhook" ? getWebhookItem(spec, path) : getPathItem(spec, path))?.[normalizedMethod];
|
|
1740
|
-
if (isRecord(operation)) return {
|
|
1741
|
-
path,
|
|
1742
|
-
method: normalizedMethod,
|
|
1743
|
-
operation: normalizeOpenApiOperationSectionId(operation, normalizedMethod, path, currentSource),
|
|
1744
|
-
source: currentSource
|
|
1745
|
-
};
|
|
1746
|
-
}
|
|
1787
|
+
function getOpenApiOperationEntryById(spec, operationId) {
|
|
1788
|
+
const matches = listOpenApiOperations(spec).filter(({ operation }) => operation.operationId === operationId);
|
|
1789
|
+
return matches.length === 1 ? matches[0] : void 0;
|
|
1747
1790
|
}
|
|
1748
1791
|
function listOpenApiOperations(spec) {
|
|
1749
1792
|
const paths = spec.paths ?? {};
|
|
@@ -2530,8 +2573,11 @@ function ApiExampleCodeGroup(arg0) {
|
|
|
2530
2573
|
function firstExampleKeyForMediaType(requestContents, mediaType, spec) {
|
|
2531
2574
|
return getExampleEntries(requestContents.find((content) => content.mediaType === mediaType)?.value, spec)[0]?.key ?? "";
|
|
2532
2575
|
}
|
|
2576
|
+
function isStructuredMediaType(mediaType) {
|
|
2577
|
+
return mediaType.includes("json") || mediaType.includes("yaml") || mediaType.includes("yml");
|
|
2578
|
+
}
|
|
2533
2579
|
function useRequestExamplesState(arg0) {
|
|
2534
|
-
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, operationSource, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2580
|
+
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, operationSource, sharedExampleKey, onSelectExampleKey, query = "" } = arg0;
|
|
2535
2581
|
const selectedContent = requestContents.find((content) => content.mediaType === selectedMediaType) ?? requestContents[0];
|
|
2536
2582
|
const examples = getExampleEntries(selectedContent?.value, spec);
|
|
2537
2583
|
const [selectedExampleKey, setSelectedExampleKey] = useState(examples[0]?.key ?? "");
|
|
@@ -2539,6 +2585,7 @@ function useRequestExamplesState(arg0) {
|
|
|
2539
2585
|
const [selectedClientKey, setSelectedClientKey] = useState("curl");
|
|
2540
2586
|
const currentExampleKey = (sharedExampleKey && examples.some((example) => example.key === sharedExampleKey) ? sharedExampleKey : void 0) ?? selectedExampleKey;
|
|
2541
2587
|
const selectedExample = examples.find((example) => example.key === currentExampleKey) ?? examples[0];
|
|
2588
|
+
const requestExample = selectedContent && isStructuredMediaType(selectedContent.mediaType) ? filterExampleBySchema(spec, selectedContent.value.schema, selectedExample?.value, query) : selectedExample?.value;
|
|
2542
2589
|
const codeOptions = buildRequestCodeExamples({
|
|
2543
2590
|
spec,
|
|
2544
2591
|
path,
|
|
@@ -2548,7 +2595,7 @@ function useRequestExamplesState(arg0) {
|
|
|
2548
2595
|
...selectedContent,
|
|
2549
2596
|
value: {
|
|
2550
2597
|
...selectedContent.value,
|
|
2551
|
-
example:
|
|
2598
|
+
example: requestExample,
|
|
2552
2599
|
examples: void 0
|
|
2553
2600
|
}
|
|
2554
2601
|
} : void 0,
|
|
@@ -2583,7 +2630,7 @@ function useRequestExamplesState(arg0) {
|
|
|
2583
2630
|
};
|
|
2584
2631
|
}
|
|
2585
2632
|
function RequestExamplesPanel(arg0) {
|
|
2586
|
-
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, operationSource, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
2633
|
+
const { spec, path, method, parameters, requestContents, selectedMediaType, onSelectMediaType, selectedServer, serverVariables, auth, operationSource, sharedExampleKey, onSelectExampleKey, query } = arg0;
|
|
2587
2634
|
const t = useBuiltInText();
|
|
2588
2635
|
const state = useRequestExamplesState({
|
|
2589
2636
|
spec,
|
|
@@ -2598,7 +2645,8 @@ function RequestExamplesPanel(arg0) {
|
|
|
2598
2645
|
auth,
|
|
2599
2646
|
operationSource,
|
|
2600
2647
|
sharedExampleKey,
|
|
2601
|
-
onSelectExampleKey
|
|
2648
|
+
onSelectExampleKey,
|
|
2649
|
+
query
|
|
2602
2650
|
});
|
|
2603
2651
|
return /* @__PURE__ */ jsx(ApiExampleCodeGroup, {
|
|
2604
2652
|
title: t("openapi.request"),
|
|
@@ -2623,11 +2671,12 @@ function RequestExamplesPanel(arg0) {
|
|
|
2623
2671
|
function firstExampleKeyForResponseContent(content, spec) {
|
|
2624
2672
|
return getExampleEntries(content?.value, spec)[0]?.key ?? "";
|
|
2625
2673
|
}
|
|
2626
|
-
function getResponseExampleBody(content, example) {
|
|
2627
|
-
|
|
2674
|
+
function getResponseExampleBody(content, example, spec, query = "") {
|
|
2675
|
+
if (!content) return "";
|
|
2676
|
+
return stringifyExample(spec && isStructuredMediaType(content.mediaType) ? filterExampleBySchema(spec, content.value.schema, example?.value, query) : example?.value);
|
|
2628
2677
|
}
|
|
2629
2678
|
function useResponseExamplesState(arg0) {
|
|
2630
|
-
const { operation, spec, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2679
|
+
const { operation, spec, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus, query = "" } = arg0;
|
|
2631
2680
|
const orderedResponses = [...getResponseEntries(operation, spec)].sort((left, right) => {
|
|
2632
2681
|
if (left.status === "default") return -1;
|
|
2633
2682
|
if (right.status === "default") return 1;
|
|
@@ -2662,7 +2711,7 @@ function useResponseExamplesState(arg0) {
|
|
|
2662
2711
|
selectedContent,
|
|
2663
2712
|
examples,
|
|
2664
2713
|
selectedExample,
|
|
2665
|
-
responseBody: getResponseExampleBody(selectedContent, selectedExample),
|
|
2714
|
+
responseBody: getResponseExampleBody(selectedContent, selectedExample, spec, query),
|
|
2666
2715
|
onSelectStatus: (value) => {
|
|
2667
2716
|
const nextContents = getMediaTypeEntries(orderedResponses.find(({ status }) => status === value)?.response.content, spec);
|
|
2668
2717
|
if (typeof selectedStatus === "undefined") setInternalSelectedStatus(value);
|
|
@@ -2691,7 +2740,7 @@ function useResponseExamplesState(arg0) {
|
|
|
2691
2740
|
};
|
|
2692
2741
|
}
|
|
2693
2742
|
function ResponseExamplesPanel(arg0) {
|
|
2694
|
-
const { operation, spec, title, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus } = arg0;
|
|
2743
|
+
const { operation, spec, title, sharedExampleKey, onSelectExampleKey, selectedStatus, onSelectStatus, query } = arg0;
|
|
2695
2744
|
const t = useBuiltInText();
|
|
2696
2745
|
const state = useResponseExamplesState({
|
|
2697
2746
|
operation,
|
|
@@ -2699,7 +2748,8 @@ function ResponseExamplesPanel(arg0) {
|
|
|
2699
2748
|
sharedExampleKey,
|
|
2700
2749
|
onSelectExampleKey,
|
|
2701
2750
|
selectedStatus,
|
|
2702
|
-
onSelectStatus
|
|
2751
|
+
onSelectStatus,
|
|
2752
|
+
query
|
|
2703
2753
|
});
|
|
2704
2754
|
if (!state.selectedContent || !state.responseBody) return null;
|
|
2705
2755
|
return /* @__PURE__ */ jsx(ApiExampleCodeGroup, {
|
|
@@ -2721,7 +2771,7 @@ function ResponseExamplesPanel(arg0) {
|
|
|
2721
2771
|
//#endregion
|
|
2722
2772
|
//#region source/openapi/components/OpenApiDocumentSection.tsx
|
|
2723
2773
|
function OpenApiDocumentSection(props) {
|
|
2724
|
-
const { title, children, className, bodyClassName, level = 3 } = props;
|
|
2774
|
+
const { title, children, action, className, bodyClassName, level = 3 } = props;
|
|
2725
2775
|
const heading = level === 3 ? /* @__PURE__ */ jsx("h3", {
|
|
2726
2776
|
className: "!m-0 text-sm/6 font-semibold text-(--clarify-theme-tokens-colors-foreground)",
|
|
2727
2777
|
children: title
|
|
@@ -2731,7 +2781,10 @@ function OpenApiDocumentSection(props) {
|
|
|
2731
2781
|
});
|
|
2732
2782
|
return /* @__PURE__ */ jsxs("section", {
|
|
2733
2783
|
className: clsx("clarify-openapi-document-section", className),
|
|
2734
|
-
children: [
|
|
2784
|
+
children: [action ? /* @__PURE__ */ jsxs("div", {
|
|
2785
|
+
className: "flex min-w-0 items-center justify-between gap-2",
|
|
2786
|
+
children: [heading, action]
|
|
2787
|
+
}) : heading, /* @__PURE__ */ jsx("div", {
|
|
2735
2788
|
className: clsx("mt-2", bodyClassName),
|
|
2736
2789
|
children
|
|
2737
2790
|
})]
|
|
@@ -3014,7 +3067,7 @@ function getRootSchemaNode(spec, schema, defaultExpanded) {
|
|
|
3014
3067
|
function EnumValueNode(arg0) {
|
|
3015
3068
|
const { node } = arg0;
|
|
3016
3069
|
return /* @__PURE__ */ jsx("li", {
|
|
3017
|
-
className: "clarify-schema-node m-0 p-0",
|
|
3070
|
+
className: clsx("clarify-schema-node m-0 p-0", node.visible === false && "hidden"),
|
|
3018
3071
|
children: /* @__PURE__ */ jsx("div", {
|
|
3019
3072
|
className: "flex min-w-0 items-start rounded-(--clarify-theme-tokens-radius-md) px-2 py-2 text-left",
|
|
3020
3073
|
children: /* @__PURE__ */ jsxs("div", {
|
|
@@ -3040,10 +3093,11 @@ function EnumValueNode(arg0) {
|
|
|
3040
3093
|
});
|
|
3041
3094
|
}
|
|
3042
3095
|
function SchemaNode(arg0) {
|
|
3043
|
-
const { node, depth = 0, defaultExpanded } = arg0;
|
|
3096
|
+
const { node, depth = 0, defaultExpanded, forceExpanded = false } = arg0;
|
|
3044
3097
|
const t = useBuiltInText();
|
|
3045
|
-
const [
|
|
3098
|
+
const [locallyExpanded, setLocallyExpanded] = useState(defaultExpanded ?? depth < 1);
|
|
3046
3099
|
const hasChildren = node.children.length > 0;
|
|
3100
|
+
const expanded = forceExpanded || locallyExpanded;
|
|
3047
3101
|
if (node.kind === "enum") return /* @__PURE__ */ jsx(EnumValueNode, {
|
|
3048
3102
|
node,
|
|
3049
3103
|
depth
|
|
@@ -3078,25 +3132,29 @@ function SchemaNode(arg0) {
|
|
|
3078
3132
|
children: expanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })
|
|
3079
3133
|
}) : null] });
|
|
3080
3134
|
return /* @__PURE__ */ jsxs("li", {
|
|
3081
|
-
className: "clarify-schema-node m-0 p-0",
|
|
3135
|
+
className: clsx("clarify-schema-node m-0 p-0", node.visible === false && "hidden"),
|
|
3082
3136
|
children: [hasChildren ? /* @__PURE__ */ jsx("button", {
|
|
3083
3137
|
type: "button",
|
|
3084
3138
|
"aria-label": expanded ? t("openapi.collapse") : t("openapi.expand"),
|
|
3085
3139
|
"aria-expanded": expanded,
|
|
3086
|
-
onClick: () =>
|
|
3140
|
+
onClick: () => setLocallyExpanded((value) => !value),
|
|
3087
3141
|
className: clsx(rowClassName, "cursor-pointer transition hover:bg-(--clarify-ui-hover-background) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)"),
|
|
3088
3142
|
children: content
|
|
3089
3143
|
}) : /* @__PURE__ */ jsx("div", {
|
|
3090
3144
|
className: rowClassName,
|
|
3091
3145
|
children: content
|
|
3092
|
-
}), hasChildren
|
|
3093
|
-
|
|
3094
|
-
|
|
3146
|
+
}), hasChildren ? /* @__PURE__ */ jsx("div", {
|
|
3147
|
+
className: clsx(!expanded && "hidden"),
|
|
3148
|
+
children: /* @__PURE__ */ jsx(SchemaTree, {
|
|
3149
|
+
nodes: node.children,
|
|
3150
|
+
depth: depth + 1,
|
|
3151
|
+
forceExpanded
|
|
3152
|
+
})
|
|
3095
3153
|
}) : null]
|
|
3096
3154
|
});
|
|
3097
3155
|
}
|
|
3098
3156
|
function SchemaTree(arg0) {
|
|
3099
|
-
const { nodes, depth = 0 } = arg0;
|
|
3157
|
+
const { nodes, depth = 0, forceExpanded = false } = arg0;
|
|
3100
3158
|
if (nodes.length === 0) return null;
|
|
3101
3159
|
return /* @__PURE__ */ jsx("ul", {
|
|
3102
3160
|
role: "list",
|
|
@@ -3104,19 +3162,52 @@ function SchemaTree(arg0) {
|
|
|
3104
3162
|
children: nodes.map((node) => /* @__PURE__ */ jsx(SchemaNode, {
|
|
3105
3163
|
node,
|
|
3106
3164
|
depth,
|
|
3107
|
-
defaultExpanded: node.defaultExpanded
|
|
3165
|
+
defaultExpanded: node.defaultExpanded,
|
|
3166
|
+
forceExpanded
|
|
3108
3167
|
}, node.key))
|
|
3109
3168
|
});
|
|
3110
3169
|
}
|
|
3170
|
+
function markSchemaNodesVisibility(nodes, query) {
|
|
3171
|
+
if (!query) return nodes.map((node) => ({
|
|
3172
|
+
...node,
|
|
3173
|
+
visible: true,
|
|
3174
|
+
children: markSchemaNodesVisibility(node.children, query)
|
|
3175
|
+
}));
|
|
3176
|
+
return nodes.map((node) => {
|
|
3177
|
+
const children = markSchemaNodesVisibility(node.children, query);
|
|
3178
|
+
const searchableText = getSchemaSearchText(node.name, {
|
|
3179
|
+
type: node.type,
|
|
3180
|
+
description: node.description,
|
|
3181
|
+
pattern: node.details
|
|
3182
|
+
});
|
|
3183
|
+
return {
|
|
3184
|
+
...node,
|
|
3185
|
+
visible: fuzzyMatch(searchableText, query) || children.some((child) => child.visible),
|
|
3186
|
+
children
|
|
3187
|
+
};
|
|
3188
|
+
});
|
|
3189
|
+
}
|
|
3111
3190
|
function SchemaProperties(arg0) {
|
|
3112
|
-
const { title, schema, spec, defaultExpanded } = arg0;
|
|
3191
|
+
const { title, schema, spec, defaultExpanded, query = "", emptyText } = arg0;
|
|
3192
|
+
const t = useBuiltInText();
|
|
3113
3193
|
const root = getRootSchemaNode(spec, schema, defaultExpanded);
|
|
3114
3194
|
if (!root || root.children.length === 0) return null;
|
|
3115
|
-
|
|
3195
|
+
const normalizedQuery = query.trim();
|
|
3196
|
+
const nodes = markSchemaNodesVisibility(root.children, normalizedQuery);
|
|
3197
|
+
const hasQuery = Boolean(normalizedQuery);
|
|
3198
|
+
const hasVisibleNodes = nodes.some((node) => node.visible);
|
|
3199
|
+
const resolvedEmptyText = emptyText ?? t("openapi.noBodyProperties");
|
|
3200
|
+
return /* @__PURE__ */ jsxs(OpenApiDocumentSection, {
|
|
3116
3201
|
title,
|
|
3117
3202
|
level: 4,
|
|
3118
3203
|
bodyClassName: "clarify-schema-properties not-prose",
|
|
3119
|
-
children: /* @__PURE__ */ jsx(SchemaTree, {
|
|
3204
|
+
children: [/* @__PURE__ */ jsx(SchemaTree, {
|
|
3205
|
+
nodes,
|
|
3206
|
+
forceExpanded: hasQuery
|
|
3207
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
3208
|
+
className: clsx("m-0 py-2 text-sm/5 text-(--clarify-ui-text-soft)", hasVisibleNodes && "hidden"),
|
|
3209
|
+
children: resolvedEmptyText
|
|
3210
|
+
})]
|
|
3120
3211
|
});
|
|
3121
3212
|
}
|
|
3122
3213
|
function ParameterList(arg0) {
|
|
@@ -3140,7 +3231,7 @@ function ParameterList(arg0) {
|
|
|
3140
3231
|
});
|
|
3141
3232
|
}
|
|
3142
3233
|
function ResponseList(arg0) {
|
|
3143
|
-
const { title, operation, spec, selectedStatus, onSelectStatus } = arg0;
|
|
3234
|
+
const { title, operation, spec, selectedStatus, onSelectStatus, query = "", search } = arg0;
|
|
3144
3235
|
const t = useBuiltInText();
|
|
3145
3236
|
const orderedResponses = [...getResponseEntries(operation, spec)].sort((left, right) => {
|
|
3146
3237
|
if (left.status === "default") return -1;
|
|
@@ -3181,7 +3272,9 @@ function ResponseList(arg0) {
|
|
|
3181
3272
|
children: /* @__PURE__ */ jsx(SchemaProperties, {
|
|
3182
3273
|
title: t("openapi.responseBodyProperties"),
|
|
3183
3274
|
schema: responseSchema,
|
|
3184
|
-
spec
|
|
3275
|
+
spec,
|
|
3276
|
+
query,
|
|
3277
|
+
emptyText: t("openapi.noResponseBodyProperties")
|
|
3185
3278
|
})
|
|
3186
3279
|
}) : null
|
|
3187
3280
|
]
|
|
@@ -3189,18 +3282,20 @@ function ResponseList(arg0) {
|
|
|
3189
3282
|
};
|
|
3190
3283
|
if (orderedResponses.length === 1) {
|
|
3191
3284
|
const [{ status, response }] = orderedResponses;
|
|
3192
|
-
return /* @__PURE__ */
|
|
3285
|
+
return /* @__PURE__ */ jsxs(OpenApiDocumentSection, {
|
|
3193
3286
|
title: title ?? t("openapi.responses"),
|
|
3194
|
-
|
|
3287
|
+
action: search?.action,
|
|
3288
|
+
children: [search?.open ? search.input : null, renderResponsePanel({
|
|
3195
3289
|
status,
|
|
3196
3290
|
response
|
|
3197
|
-
})
|
|
3291
|
+
})]
|
|
3198
3292
|
});
|
|
3199
3293
|
}
|
|
3200
|
-
return /* @__PURE__ */
|
|
3294
|
+
return /* @__PURE__ */ jsxs(OpenApiDocumentSection, {
|
|
3201
3295
|
title: title ?? t("openapi.responses"),
|
|
3296
|
+
action: search?.action,
|
|
3202
3297
|
bodyClassName: "not-prose",
|
|
3203
|
-
children: /* @__PURE__ */ jsx(Tabs, {
|
|
3298
|
+
children: [search?.open ? search.input : null, /* @__PURE__ */ jsx(Tabs, {
|
|
3204
3299
|
selectedIndex,
|
|
3205
3300
|
onChange: (index) => {
|
|
3206
3301
|
onSelectStatus?.(orderedResponses[index]?.status ?? "");
|
|
@@ -3215,15 +3310,71 @@ function ResponseList(arg0) {
|
|
|
3215
3310
|
})),
|
|
3216
3311
|
spacingClassName: "m-0",
|
|
3217
3312
|
panelsClassName: "mt-2"
|
|
3313
|
+
})]
|
|
3314
|
+
});
|
|
3315
|
+
}
|
|
3316
|
+
//#endregion
|
|
3317
|
+
//#region source/openapi/components/SchemaSearch.tsx
|
|
3318
|
+
function useSchemaSearch() {
|
|
3319
|
+
const [open, setOpen] = useState(false);
|
|
3320
|
+
const [query, setQuery] = useState("");
|
|
3321
|
+
return {
|
|
3322
|
+
open,
|
|
3323
|
+
query,
|
|
3324
|
+
onChange: (event) => setQuery(event.target.value),
|
|
3325
|
+
toggle: () => {
|
|
3326
|
+
setOpen((current) => {
|
|
3327
|
+
if (current) setQuery("");
|
|
3328
|
+
return !current;
|
|
3329
|
+
});
|
|
3330
|
+
}
|
|
3331
|
+
};
|
|
3332
|
+
}
|
|
3333
|
+
function SchemaSearchButton(arg0) {
|
|
3334
|
+
const { label, open, onClick } = arg0;
|
|
3335
|
+
return /* @__PURE__ */ jsx("button", {
|
|
3336
|
+
type: "button",
|
|
3337
|
+
"aria-label": label,
|
|
3338
|
+
"aria-pressed": open,
|
|
3339
|
+
onClick,
|
|
3340
|
+
className: clsx("flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-(--clarify-theme-tokens-radius-md) transition focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)", open ? "bg-(--clarify-ui-hover-background) text-(--clarify-theme-tokens-colors-primary)" : "text-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground)"),
|
|
3341
|
+
children: /* @__PURE__ */ jsx(SearchIcon, {
|
|
3342
|
+
className: "size-4",
|
|
3343
|
+
"aria-hidden": "true"
|
|
3218
3344
|
})
|
|
3219
3345
|
});
|
|
3220
3346
|
}
|
|
3347
|
+
function SchemaSearchInput(arg0) {
|
|
3348
|
+
const { label, value, onChange } = arg0;
|
|
3349
|
+
return /* @__PURE__ */ jsxs("label", {
|
|
3350
|
+
className: "not-prose mb-3 flex h-9 items-center gap-2 rounded-(--clarify-theme-tokens-radius-md) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) px-3 transition focus-within:border-(--clarify-theme-tokens-colors-primary) focus-within:ring-2 focus-within:ring-(--clarify-theme-tokens-colors-primary)/15",
|
|
3351
|
+
children: [
|
|
3352
|
+
/* @__PURE__ */ jsx(SearchIcon, {
|
|
3353
|
+
className: "size-4 shrink-0 text-(--clarify-ui-text-faint)",
|
|
3354
|
+
"aria-hidden": "true"
|
|
3355
|
+
}),
|
|
3356
|
+
/* @__PURE__ */ jsx("span", {
|
|
3357
|
+
className: "sr-only",
|
|
3358
|
+
children: label
|
|
3359
|
+
}),
|
|
3360
|
+
/* @__PURE__ */ jsx("input", {
|
|
3361
|
+
type: "search",
|
|
3362
|
+
value,
|
|
3363
|
+
onChange,
|
|
3364
|
+
placeholder: label,
|
|
3365
|
+
autoFocus: true,
|
|
3366
|
+
className: "min-w-0 flex-1 bg-transparent text-sm text-(--clarify-theme-tokens-colors-foreground) outline-none placeholder:text-(--clarify-ui-text-faint)"
|
|
3367
|
+
})
|
|
3368
|
+
]
|
|
3369
|
+
});
|
|
3370
|
+
}
|
|
3221
3371
|
//#endregion
|
|
3222
3372
|
//#region source/openapi/components/EndpointSections.tsx
|
|
3223
3373
|
function EndpointRequest(arg0) {
|
|
3224
3374
|
const { spec, path, method, operationSource = "path", description, groupedParameters, parameters, requestBody, requestContents, requestSchema, selectedRequestMediaType, onSelectRequestMediaType, selectedServer, serverVariables, authOptions, auth, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
3225
3375
|
const t = useBuiltInText();
|
|
3226
3376
|
const hasRequestBody = Boolean(requestBody && requestContents.length > 0);
|
|
3377
|
+
const requestBodySearch = useSchemaSearch();
|
|
3227
3378
|
const renderDescription = () => {
|
|
3228
3379
|
if (!description) return null;
|
|
3229
3380
|
return /* @__PURE__ */ jsx(Markdown, { children: description });
|
|
@@ -3233,11 +3384,20 @@ function EndpointRequest(arg0) {
|
|
|
3233
3384
|
className: "text-sm/5 text-(--clarify-ui-text-soft)",
|
|
3234
3385
|
children: t("openapi.requestBodyEmpty")
|
|
3235
3386
|
});
|
|
3236
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3387
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
3388
|
+
requestBodySearch.open ? /* @__PURE__ */ jsx(SchemaSearchInput, {
|
|
3389
|
+
label: t("openapi.searchBodyProperties"),
|
|
3390
|
+
value: requestBodySearch.query,
|
|
3391
|
+
onChange: requestBodySearch.onChange
|
|
3392
|
+
}) : null,
|
|
3393
|
+
typeof requestBody?.description === "string" ? /* @__PURE__ */ jsx(Markdown, { children: requestBody.description }) : null,
|
|
3394
|
+
/* @__PURE__ */ jsx(SchemaProperties, {
|
|
3395
|
+
title: t("openapi.bodyProperties"),
|
|
3396
|
+
schema: requestSchema,
|
|
3397
|
+
spec,
|
|
3398
|
+
query: requestBodySearch.query
|
|
3399
|
+
})
|
|
3400
|
+
] });
|
|
3241
3401
|
};
|
|
3242
3402
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [renderDescription(), /* @__PURE__ */ jsxs(Row, {
|
|
3243
3403
|
className: "clarify-openapi-request-workspace relative mt-8 pt-6",
|
|
@@ -3259,6 +3419,11 @@ function EndpointRequest(arg0) {
|
|
|
3259
3419
|
}),
|
|
3260
3420
|
/* @__PURE__ */ jsx(OpenApiDocumentSection, {
|
|
3261
3421
|
title: t("openapi.requestBody"),
|
|
3422
|
+
action: hasRequestBody ? /* @__PURE__ */ jsx(SchemaSearchButton, {
|
|
3423
|
+
label: t("openapi.searchBodyProperties"),
|
|
3424
|
+
open: requestBodySearch.open,
|
|
3425
|
+
onClick: requestBodySearch.toggle
|
|
3426
|
+
}) : null,
|
|
3262
3427
|
children: renderRequestBody()
|
|
3263
3428
|
})
|
|
3264
3429
|
]
|
|
@@ -3279,7 +3444,8 @@ function EndpointRequest(arg0) {
|
|
|
3279
3444
|
auth,
|
|
3280
3445
|
operationSource,
|
|
3281
3446
|
sharedExampleKey,
|
|
3282
|
-
onSelectExampleKey
|
|
3447
|
+
onSelectExampleKey,
|
|
3448
|
+
query: requestBodySearch.query
|
|
3283
3449
|
})
|
|
3284
3450
|
})
|
|
3285
3451
|
})]
|
|
@@ -3290,6 +3456,7 @@ function EndpointResponse(arg0) {
|
|
|
3290
3456
|
const t = useBuiltInText();
|
|
3291
3457
|
const responseTitle = operationSource === "webhook" ? t("openapi.webhookResponses") : t("openapi.responses");
|
|
3292
3458
|
const responseExampleTitle = operationSource === "webhook" ? t("openapi.webhookResponse") : t("openapi.response");
|
|
3459
|
+
const responseBodySearch = useSchemaSearch();
|
|
3293
3460
|
return /* @__PURE__ */ jsx("div", {
|
|
3294
3461
|
className: "mt-10 pt-6",
|
|
3295
3462
|
children: /* @__PURE__ */ jsxs(Row, {
|
|
@@ -3301,7 +3468,21 @@ function EndpointResponse(arg0) {
|
|
|
3301
3468
|
operation,
|
|
3302
3469
|
spec,
|
|
3303
3470
|
selectedStatus,
|
|
3304
|
-
onSelectStatus
|
|
3471
|
+
onSelectStatus,
|
|
3472
|
+
query: responseBodySearch.query,
|
|
3473
|
+
search: {
|
|
3474
|
+
open: responseBodySearch.open,
|
|
3475
|
+
action: /* @__PURE__ */ jsx(SchemaSearchButton, {
|
|
3476
|
+
label: t("openapi.searchResponseBodyProperties"),
|
|
3477
|
+
open: responseBodySearch.open,
|
|
3478
|
+
onClick: responseBodySearch.toggle
|
|
3479
|
+
}),
|
|
3480
|
+
input: /* @__PURE__ */ jsx(SchemaSearchInput, {
|
|
3481
|
+
label: t("openapi.searchResponseBodyProperties"),
|
|
3482
|
+
value: responseBodySearch.query,
|
|
3483
|
+
onChange: responseBodySearch.onChange
|
|
3484
|
+
})
|
|
3485
|
+
}
|
|
3305
3486
|
})
|
|
3306
3487
|
}) }), /* @__PURE__ */ jsx(Col, {
|
|
3307
3488
|
sticky: true,
|
|
@@ -3314,7 +3495,8 @@ function EndpointResponse(arg0) {
|
|
|
3314
3495
|
sharedExampleKey,
|
|
3315
3496
|
onSelectExampleKey,
|
|
3316
3497
|
selectedStatus,
|
|
3317
|
-
onSelectStatus
|
|
3498
|
+
onSelectStatus,
|
|
3499
|
+
query: responseBodySearch.query
|
|
3318
3500
|
})
|
|
3319
3501
|
})
|
|
3320
3502
|
})]
|
|
@@ -4577,7 +4759,7 @@ function requestBodyForExample(spec, content, exampleKey) {
|
|
|
4577
4759
|
const example = getExampleEntries(content, spec).find((entry) => !entry.generated && entry.key === exampleKey);
|
|
4578
4760
|
return example ? stringifyExample(example.value) : initialRequestBody(spec, content);
|
|
4579
4761
|
}
|
|
4580
|
-
function useOpenApiRequestTarget(spec, path, operation, operationSource) {
|
|
4762
|
+
function useOpenApiRequestTarget(spec, path, operation, operationSource, requestExample = "") {
|
|
4581
4763
|
const servers = getServers(spec, operation, path, operationSource);
|
|
4582
4764
|
const [selectedServerKey, setSelectedServerKey] = useState(getServerKey(servers[0], 0));
|
|
4583
4765
|
const selectedServer = servers.find((server, index) => getServerKey(server, index) === selectedServerKey) ?? servers[0];
|
|
@@ -4592,7 +4774,7 @@ function useOpenApiRequestTarget(spec, path, operation, operationSource) {
|
|
|
4592
4774
|
const requestContents = getMediaTypeEntries(getRequestBody$1(spec, operation)?.content, spec);
|
|
4593
4775
|
const [mediaType, setMediaType] = useState(requestContents[0]?.mediaType ?? "");
|
|
4594
4776
|
const selectedContent = requestContents.find((entry) => entry.mediaType === mediaType) ?? requestContents[0];
|
|
4595
|
-
const [body, setBody] = useState(
|
|
4777
|
+
const [body, setBody] = useState(requestBodyForExample(spec, selectedContent?.value, requestExample));
|
|
4596
4778
|
const [bodyFiles, setBodyFiles] = useState({});
|
|
4597
4779
|
function selectServer(value) {
|
|
4598
4780
|
const nextServer = servers.find((server, index) => getServerKey(server, index) === value) ?? servers[0];
|
|
@@ -4754,12 +4936,12 @@ function parameterGroupLabel(location, t) {
|
|
|
4754
4936
|
return t("openapi.queryParameters");
|
|
4755
4937
|
}
|
|
4756
4938
|
function OpenApiRequestWorkbench(arg0) {
|
|
4757
|
-
const { spec, path, method, operation, operationSource = "path", compact = false, onClose } = arg0;
|
|
4939
|
+
const { spec, path, method, operation, operationSource = "path", requestExample, compact = false, onClose } = arg0;
|
|
4758
4940
|
const t = useBuiltInText();
|
|
4759
4941
|
const parameters = getOperationParameters(spec, path, operation, operationSource);
|
|
4760
|
-
const { servers, selectedServer, selectedServerKey, serverVariables, setServerVariables, serverVariableEntries, selectServer, authOptions, selectedAuthName, setSelectedAuthName, selectedAuth, credentialScope, credentials, setCredential, clearCredential, requestContents, mediaType, selectedContent, body, setBody, bodyFiles, setBodyFile, applyBodyExample, selectMediaType } = useOpenApiRequestTarget(spec, path, operation, operationSource);
|
|
4942
|
+
const { servers, selectedServer, selectedServerKey, serverVariables, setServerVariables, serverVariableEntries, selectServer, authOptions, selectedAuthName, setSelectedAuthName, selectedAuth, credentialScope, credentials, setCredential, clearCredential, requestContents, mediaType, selectedContent, body, setBody, bodyFiles, setBodyFile, applyBodyExample, selectMediaType } = useOpenApiRequestTarget(spec, path, operation, operationSource, requestExample);
|
|
4761
4943
|
const requestExamples = getRequestExampleEntries(parameters, selectedContent?.value);
|
|
4762
|
-
const [selectedRequestExampleKey, setSelectedRequestExampleKey] = useState(requestExamples[0]?.key ?? "");
|
|
4944
|
+
const [selectedRequestExampleKey, setSelectedRequestExampleKey] = useState(requestExample ?? requestExamples[0]?.key ?? "");
|
|
4763
4945
|
const currentRequestExampleKey = requestExamples.some((example) => example.key === selectedRequestExampleKey) ? selectedRequestExampleKey : requestExamples[0]?.key ?? "";
|
|
4764
4946
|
const parameterState = useOpenApiParameterState(spec, parameters, (parameter) => initialParameterValue(spec, parameter), currentRequestExampleKey);
|
|
4765
4947
|
const { parameterValues, parameterEnabled, parameterIssues, setParameterGroupValues, setParameterIncluded, updateParameterValue, applyParameterExample } = parameterState;
|
|
@@ -4774,6 +4956,7 @@ function OpenApiRequestWorkbench(arg0) {
|
|
|
4774
4956
|
})).filter((group) => group.parameters.length > 0);
|
|
4775
4957
|
const pathParameters = parameters.filter((parameter) => parameter.in === "path");
|
|
4776
4958
|
const hasRequestConfiguration = authOptions.length > 0 || serverVariableEntries.length > 0 || parameters.length > 0 || requestContents.length > 0;
|
|
4959
|
+
const showResponse = compact || Boolean(exchange || error);
|
|
4777
4960
|
function applyRequestExample(exampleKey) {
|
|
4778
4961
|
setSelectedRequestExampleKey(exampleKey);
|
|
4779
4962
|
applyParameterExample(exampleKey);
|
|
@@ -4985,9 +5168,9 @@ function OpenApiRequestWorkbench(arg0) {
|
|
|
4985
5168
|
});
|
|
4986
5169
|
}
|
|
4987
5170
|
return /* @__PURE__ */ jsxs("div", {
|
|
4988
|
-
className: clsx("clarify-
|
|
5171
|
+
className: clsx("clarify-openapi-request flex min-h-0 min-w-0 flex-col not-prose bg-(--clarify-theme-tokens-colors-surface) [--clarify-ui-accent-background:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_10%,transparent)] [--clarify-ui-accent-border:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_22%,transparent)] [--clarify-ui-accent-text:var(--clarify-theme-tokens-colors-foreground)] [--clarify-ui-active-background:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_12%,transparent)] [--clarify-ui-subtle-background:color-mix(in_srgb,var(--clarify-theme-tokens-colors-foreground)_5%,transparent)]", compact ? "h-full" : "my-6 overflow-hidden rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border)"),
|
|
4989
5172
|
children: [renderHeader(), /* @__PURE__ */ jsxs("div", {
|
|
4990
|
-
className: "grid min-h-0 flex-1 gap-0 px-0 lg:grid-cols-[minmax(0,1.12fr)_minmax(22rem,0.88fr)]",
|
|
5173
|
+
className: clsx("grid min-h-0 flex-1 gap-0 px-0", showResponse && "lg:grid-cols-[minmax(0,1.12fr)_minmax(22rem,0.88fr)]"),
|
|
4991
5174
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
4992
5175
|
className: "flex min-h-0 min-w-0 flex-col overflow-y-auto",
|
|
4993
5176
|
children: [
|
|
@@ -5024,13 +5207,13 @@ function OpenApiRequestWorkbench(arg0) {
|
|
|
5024
5207
|
})
|
|
5025
5208
|
}) : null
|
|
5026
5209
|
]
|
|
5027
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
5210
|
+
}), showResponse ? /* @__PURE__ */ jsx("div", {
|
|
5028
5211
|
className: "h-full min-h-0 min-w-0 overflow-hidden border-t border-(--clarify-theme-tokens-colors-border) lg:border-t-0 lg:border-l",
|
|
5029
5212
|
children: /* @__PURE__ */ jsx(OpenApiResponseViewer, {
|
|
5030
5213
|
exchange,
|
|
5031
5214
|
error
|
|
5032
5215
|
})
|
|
5033
|
-
})]
|
|
5216
|
+
}) : null]
|
|
5034
5217
|
})]
|
|
5035
5218
|
});
|
|
5036
5219
|
}
|
|
@@ -5044,7 +5227,7 @@ function OpenApiRequestDialog(arg0) {
|
|
|
5044
5227
|
children: [/* @__PURE__ */ jsx(DialogBackdrop, { className: "fixed inset-0 bg-(--clarify-ui-overlay-background) backdrop-blur-sm" }), /* @__PURE__ */ jsx("div", {
|
|
5045
5228
|
className: "fixed inset-0 grid place-items-center overflow-y-auto p-3 sm:p-6",
|
|
5046
5229
|
children: /* @__PURE__ */ jsxs(DialogPanel, {
|
|
5047
|
-
className: "relative flex h-[min(46rem,calc(100dvh-1.5rem))] w-full max-w-7xl flex-col overflow-hidden rounded-lg border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-background) shadow-2xl sm:h-[min(46rem,calc(100dvh-3rem))]",
|
|
5230
|
+
className: "relative flex h-[min(46rem,calc(100dvh-1.5rem))] w-full max-w-7xl flex-col overflow-hidden rounded-(--clarify-theme-tokens-radius-lg) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-background) shadow-2xl sm:h-[min(46rem,calc(100dvh-3rem))]",
|
|
5048
5231
|
children: [/* @__PURE__ */ jsx(DialogTitle, {
|
|
5049
5232
|
className: "sr-only",
|
|
5050
5233
|
children: t("openapi.tryRequest")
|
|
@@ -5388,6 +5571,6 @@ function OpenApiOperation(arg0) {
|
|
|
5388
5571
|
});
|
|
5389
5572
|
}
|
|
5390
5573
|
//#endregion
|
|
5391
|
-
export { Code as A, GridPattern as C, Tag as D, Heading as E, CardGroup as F, Callout as I, Button as L, Pre as M, Mermaid as N, Feedback as O, Card as P, Prose as S, Logo as T, WebFrame as _, ResponseExamplesPanel as a, Step as b, getAuthOptions as c,
|
|
5574
|
+
export { Code as A, GridPattern as C, Tag as D, Heading as E, CardGroup as F, Callout as I, Button as L, Pre as M, Mermaid as N, Feedback as O, Card as P, Prose as S, Logo as T, WebFrame as _, ResponseExamplesPanel as a, Step as b, getAuthOptions as c, getOpenApiOperationEntryById as d, listOpenApiOperations as f, primitives_exports as g, Markdown as h, RequestExamplesPanel as i, CodeGroup as j, Collapse as k, getServerKey as l, getRequestBody$1 as m, OpenApiOperation as n, authPlaceholder as o, getMediaTypeEntries as p, OpenApiRequestWorkbench as r, defaultServerVariables as s, EndpointIdentity as t, getServers as u, TabItem as v, HeroPattern as w, Steps as x, Tabs as y };
|
|
5392
5575
|
|
|
5393
|
-
//# sourceMappingURL=OpenApiOperation-
|
|
5576
|
+
//# sourceMappingURL=OpenApiOperation-CbdKZMO1.js.map
|