@clarify-labs/renderer 0.11.0 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/output/{ClarifyShell-BAjq876Z.cjs → ClarifyShell-Cn48irqj.cjs} +37 -21
- package/output/ClarifyShell-Cn48irqj.cjs.map +1 -0
- package/output/{ClarifyShell-GoSXvgMg.js → ClarifyShell-D_HluctW.js} +37 -21
- package/output/ClarifyShell-D_HluctW.js.map +1 -0
- package/output/{MermaidViewer-CkIxyqtf.js → MermaidViewer-Dby0ylNr.js} +2 -2
- package/output/{MermaidViewer-CkIxyqtf.js.map → MermaidViewer-Dby0ylNr.js.map} +1 -1
- package/output/{MermaidViewer-BZ8ghcFP.cjs → MermaidViewer-EZjolX08.cjs} +2 -2
- package/output/{MermaidViewer-BZ8ghcFP.cjs.map → MermaidViewer-EZjolX08.cjs.map} +1 -1
- package/output/{OpenApiOperation-C2vJztWZ.js → OpenApiOperation-Cr8TxLjl.js} +553 -125
- package/output/OpenApiOperation-Cr8TxLjl.js.map +1 -0
- package/output/{OpenApiOperation-D-5uE5v7.cjs → OpenApiOperation-bdALspAY.cjs} +553 -125
- package/output/OpenApiOperation-bdALspAY.cjs.map +1 -0
- package/output/{PageActions-bugd7GZh.js → PageActions-BLzCasvB.js} +47 -6
- package/output/PageActions-BLzCasvB.js.map +1 -0
- package/output/{PageActions-DJRXlGhz.cjs → PageActions-Bw9SAHLl.cjs} +46 -5
- package/output/PageActions-Bw9SAHLl.cjs.map +1 -0
- package/output/{SearchDialog-CBJjDs_9.js → SearchDialog-DWYp1c6c.js} +3 -3
- package/output/{SearchDialog-CBJjDs_9.js.map → SearchDialog-DWYp1c6c.js.map} +1 -1
- package/output/{SearchDialog-8AdCRp6K.cjs → SearchDialog-j_4Y9WY_.cjs} +3 -3
- package/output/{SearchDialog-8AdCRp6K.cjs.map → SearchDialog-j_4Y9WY_.cjs.map} +1 -1
- package/output/client.cjs +3 -3
- package/output/client.js +3 -3
- package/output/core/i18n.d.ts +1 -1
- package/output/core/types.d.ts +1 -1
- package/output/{i18n-BPrC45nD.js → i18n-DjRcGSuU.js} +23 -1
- package/output/i18n-DjRcGSuU.js.map +1 -0
- package/output/{i18n-wXINKKV0.cjs → i18n-L1XX-y6M.cjs} +23 -1
- package/output/i18n-L1XX-y6M.cjs.map +1 -0
- package/output/index.cjs +5 -5
- package/output/index.js +5 -5
- package/output/openapi/components/EndpointSections.d.ts +2 -0
- package/output/openapi/components/InlineListbox.d.ts +1 -0
- package/output/openapi/components/OpenApiAuthDocumentation.d.ts +7 -0
- package/output/openapi/components/OpenApiRequestBodyEditor.d.ts +14 -0
- package/output/openapi/components/OpenApiResponseViewer.d.ts +6 -0
- package/output/openapi/components/helpers.d.ts +1 -0
- package/output/openapi/components/useOpenApiRequestState.d.ts +9 -2
- package/output/openapi/lib/api-request.d.ts +1 -0
- package/output/openapi/lib/helpers.d.ts +8 -0
- package/output/openapi/types.d.ts +3 -0
- package/output/preview.cjs +14 -18
- package/output/preview.cjs.map +1 -1
- package/output/preview.js +14 -18
- package/output/preview.js.map +1 -1
- package/output/{render-XQiw_48i.js → render-CYQmEacg.js} +2 -2
- package/output/{render-XQiw_48i.js.map → render-CYQmEacg.js.map} +1 -1
- package/output/{render-FICIzeXz.cjs → render-hq20DPxe.cjs} +2 -2
- package/output/{render-FICIzeXz.cjs.map → render-hq20DPxe.cjs.map} +1 -1
- package/output/renderer.css +145 -48
- package/output/server.cjs +2 -2
- package/output/server.js +2 -2
- package/package.json +2 -1
- package/output/ClarifyShell-BAjq876Z.cjs.map +0 -1
- package/output/ClarifyShell-GoSXvgMg.js.map +0 -1
- package/output/OpenApiOperation-C2vJztWZ.js.map +0 -1
- package/output/OpenApiOperation-D-5uE5v7.cjs.map +0 -1
- package/output/PageActions-DJRXlGhz.cjs.map +0 -1
- package/output/PageActions-bugd7GZh.js.map +0 -1
- package/output/core/index.d.ts +0 -3
- package/output/i18n-BPrC45nD.js.map +0 -1
- package/output/i18n-wXINKKV0.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-DakpK96I.cjs");
|
|
2
|
-
const require_i18n = require("./i18n-
|
|
3
|
-
const require_PageActions = require("./PageActions-
|
|
2
|
+
const require_i18n = require("./i18n-L1XX-y6M.cjs");
|
|
3
|
+
const require_PageActions = require("./PageActions-Bw9SAHLl.cjs");
|
|
4
4
|
const require_remark = require("./remark-DTLbG8PK.cjs");
|
|
5
5
|
let clsx = require("clsx");
|
|
6
6
|
clsx = require_rolldown_runtime.__toESM(clsx, 1);
|
|
@@ -18,6 +18,7 @@ rehype_raw = require_rolldown_runtime.__toESM(rehype_raw, 1);
|
|
|
18
18
|
let github_slugger = require("github-slugger");
|
|
19
19
|
let shiki = require("shiki");
|
|
20
20
|
let _scalar_snippetz = require("@scalar/snippetz");
|
|
21
|
+
let yaml = require("yaml");
|
|
21
22
|
//#region source/components/AccordionGroup.tsx
|
|
22
23
|
function AccordionGroup(arg0) {
|
|
23
24
|
const { children, multiple = false, className, ...props } = arg0;
|
|
@@ -244,7 +245,7 @@ function Card(arg0) {
|
|
|
244
245
|
}
|
|
245
246
|
//#endregion
|
|
246
247
|
//#region source/components/Mermaid.tsx
|
|
247
|
-
var MermaidViewer = (0, react.lazy)(() => Promise.resolve().then(() => require("./MermaidViewer-
|
|
248
|
+
var MermaidViewer = (0, react.lazy)(() => Promise.resolve().then(() => require("./MermaidViewer-EZjolX08.cjs")));
|
|
248
249
|
var mermaidModulePromise;
|
|
249
250
|
async function loadMermaid() {
|
|
250
251
|
mermaidModulePromise = mermaidModulePromise ?? import("mermaid").then((module) => module.default);
|
|
@@ -1446,6 +1447,31 @@ function resolveSchema(spec, schema, seen = /* @__PURE__ */ new Set()) {
|
|
|
1446
1447
|
seen.add(schema.$ref);
|
|
1447
1448
|
return resolveSchema(spec, resolveOpenApiRef$1(spec, schema.$ref), seen) ?? schema;
|
|
1448
1449
|
}
|
|
1450
|
+
function mergeAllOfSchemas(spec, schemas) {
|
|
1451
|
+
const merged = {};
|
|
1452
|
+
const properties = {};
|
|
1453
|
+
const required = /* @__PURE__ */ new Set();
|
|
1454
|
+
for (const schema of schemas) {
|
|
1455
|
+
const resolved = resolveRequestSchema(spec, schema);
|
|
1456
|
+
if (!isRecord$1(resolved)) continue;
|
|
1457
|
+
Object.assign(merged, resolved);
|
|
1458
|
+
if (isRecord$1(resolved.properties)) Object.assign(properties, resolved.properties);
|
|
1459
|
+
if (Array.isArray(resolved.required)) resolved.required.forEach((name) => required.add(String(name)));
|
|
1460
|
+
}
|
|
1461
|
+
if (Object.keys(properties).length > 0) merged.properties = properties;
|
|
1462
|
+
if (required.size > 0) merged.required = [...required];
|
|
1463
|
+
delete merged.allOf;
|
|
1464
|
+
return merged;
|
|
1465
|
+
}
|
|
1466
|
+
function resolveRequestSchema(spec, schema) {
|
|
1467
|
+
const resolved = resolveSchema(spec, schema);
|
|
1468
|
+
if (!isRecord$1(resolved)) return resolved;
|
|
1469
|
+
const ownSchema = { ...resolved };
|
|
1470
|
+
const allOf = Array.isArray(ownSchema.allOf) ? ownSchema.allOf : [];
|
|
1471
|
+
if (allOf.length === 0) return ownSchema;
|
|
1472
|
+
delete ownSchema.allOf;
|
|
1473
|
+
return mergeAllOfSchemas(spec, [...allOf, ownSchema]);
|
|
1474
|
+
}
|
|
1449
1475
|
function getPathItem$1(spec, path) {
|
|
1450
1476
|
return resolveObjectRef(spec, spec.paths?.[path]);
|
|
1451
1477
|
}
|
|
@@ -1465,6 +1491,7 @@ function resolveObjectRef(spec, value) {
|
|
|
1465
1491
|
}
|
|
1466
1492
|
function schemaHasType(schema, type) {
|
|
1467
1493
|
if (!isRecord$1(schema)) return false;
|
|
1494
|
+
if (type === "null" && schema.nullable === true) return true;
|
|
1468
1495
|
return schema.type === type || Array.isArray(schema.type) && schema.type.includes(type);
|
|
1469
1496
|
}
|
|
1470
1497
|
function getOperationParameters(spec, path, operation, source = "path") {
|
|
@@ -1534,7 +1561,7 @@ function getExampleEntries(mediaType, spec) {
|
|
|
1534
1561
|
title: "Example",
|
|
1535
1562
|
value: mediaType.example
|
|
1536
1563
|
}];
|
|
1537
|
-
const generated = schemaToExample(spec ?
|
|
1564
|
+
const generated = schemaToExample(spec ? resolveRequestSchema(spec, mediaType.schema) : mediaType.schema);
|
|
1538
1565
|
return typeof generated === "undefined" ? [] : [{
|
|
1539
1566
|
key: "schema",
|
|
1540
1567
|
title: "schema",
|
|
@@ -1542,6 +1569,34 @@ function getExampleEntries(mediaType, spec) {
|
|
|
1542
1569
|
generated: true
|
|
1543
1570
|
}];
|
|
1544
1571
|
}
|
|
1572
|
+
function getParameterExampleEntries(parameter) {
|
|
1573
|
+
if (isRecord$1(parameter.examples)) {
|
|
1574
|
+
const examples = [];
|
|
1575
|
+
for (const [key, example] of Object.entries(parameter.examples)) {
|
|
1576
|
+
const value = getExampleValue(example);
|
|
1577
|
+
if (typeof value === "undefined") continue;
|
|
1578
|
+
const { title, summary } = getExampleTitle(key, example);
|
|
1579
|
+
examples.push({
|
|
1580
|
+
key,
|
|
1581
|
+
title,
|
|
1582
|
+
summary,
|
|
1583
|
+
value
|
|
1584
|
+
});
|
|
1585
|
+
}
|
|
1586
|
+
if (examples.length > 0) return examples;
|
|
1587
|
+
}
|
|
1588
|
+
return typeof parameter.example === "undefined" ? [] : [{
|
|
1589
|
+
key: "default",
|
|
1590
|
+
title: "Example",
|
|
1591
|
+
value: parameter.example
|
|
1592
|
+
}];
|
|
1593
|
+
}
|
|
1594
|
+
function getRequestExampleEntries(parameters, mediaType) {
|
|
1595
|
+
const entries = /* @__PURE__ */ new Map();
|
|
1596
|
+
for (const example of getExampleEntries(mediaType).filter((entry) => !entry.generated)) entries.set(example.key, example);
|
|
1597
|
+
for (const parameter of parameters) for (const example of getParameterExampleEntries(parameter)) if (!entries.has(example.key)) entries.set(example.key, example);
|
|
1598
|
+
return [...entries.values()];
|
|
1599
|
+
}
|
|
1545
1600
|
function getContentExample(mediaType) {
|
|
1546
1601
|
return getExampleEntries(mediaType)[0]?.value;
|
|
1547
1602
|
}
|
|
@@ -1555,7 +1610,8 @@ function schemaToType(schema) {
|
|
|
1555
1610
|
if (Array.isArray(schema.allOf)) return schema.allOf.map((branch) => schemaToType(branch)).filter(Boolean).join(" & ");
|
|
1556
1611
|
if (schemaHasType(schema, "array")) return `${schemaToType(schema.items) ?? "unknown"}[]`;
|
|
1557
1612
|
const type = Array.isArray(schema.type) ? schema.type.map(String).join(" | ") : schema.type;
|
|
1558
|
-
|
|
1613
|
+
const nullableType = schema.nullable === true && type !== "null" ? [type, "null"].filter(Boolean).join(" | ") : type;
|
|
1614
|
+
return typeof nullableType === "string" ? [nullableType, typeof schema.format === "string" ? `<${schema.format}>` : void 0].filter(Boolean).join("") : void 0;
|
|
1559
1615
|
}
|
|
1560
1616
|
function schemaToExample(schema, depth = 0) {
|
|
1561
1617
|
if (!isRecord$1(schema) || depth > 3) return void 0;
|
|
@@ -1563,10 +1619,12 @@ function schemaToExample(schema, depth = 0) {
|
|
|
1563
1619
|
if (typeof schema.default !== "undefined") return schema.default;
|
|
1564
1620
|
if (Array.isArray(schema.enum)) return schema.enum[0];
|
|
1565
1621
|
if (isReference(schema)) return { id: resolveReferenceName(schema.$ref) };
|
|
1622
|
+
const variant = Array.isArray(schema.oneOf) ? schema.oneOf[0] : Array.isArray(schema.anyOf) ? schema.anyOf[0] : void 0;
|
|
1623
|
+
if (typeof variant !== "undefined") return schemaToExample(variant, depth + 1);
|
|
1566
1624
|
if (schemaHasType(schema, "array")) return [schemaToExample(schema.items, depth + 1) ?? "string"];
|
|
1567
1625
|
if (schemaHasType(schema, "object") || isRecord$1(schema.properties)) {
|
|
1568
1626
|
const properties = isRecord$1(schema.properties) ? schema.properties : {};
|
|
1569
|
-
return Object.fromEntries(Object.entries(properties).slice(0, 8).map(([name, propertySchema]) => [name, schemaToExample(propertySchema, depth + 1) ?? exampleForType(schemaToType(propertySchema))]));
|
|
1627
|
+
return Object.fromEntries(Object.entries(properties).filter(([, propertySchema]) => !isRecord$1(propertySchema) || propertySchema.readOnly !== true).slice(0, 8).map(([name, propertySchema]) => [name, schemaToExample(propertySchema, depth + 1) ?? exampleForType(schemaToType(propertySchema))]));
|
|
1570
1628
|
}
|
|
1571
1629
|
return exampleForType(schemaToType(schema));
|
|
1572
1630
|
}
|
|
@@ -1804,10 +1862,10 @@ function getQueryString(parameters, auth = []) {
|
|
|
1804
1862
|
});
|
|
1805
1863
|
return queryString;
|
|
1806
1864
|
}
|
|
1807
|
-
function isFormMediaType(mediaType) {
|
|
1865
|
+
function isFormMediaType$1(mediaType) {
|
|
1808
1866
|
return mediaType.includes("multipart/form-data") || mediaType.includes("application/x-www-form-urlencoded");
|
|
1809
1867
|
}
|
|
1810
|
-
function isBinarySchema(schema) {
|
|
1868
|
+
function isBinarySchema$1(schema) {
|
|
1811
1869
|
return isRecord$1(schema) && schema.type === "string" && schema.format === "binary";
|
|
1812
1870
|
}
|
|
1813
1871
|
function getSchemaProperties(schema) {
|
|
@@ -1815,7 +1873,7 @@ function getSchemaProperties(schema) {
|
|
|
1815
1873
|
}
|
|
1816
1874
|
function getFieldValue(name, value, schema) {
|
|
1817
1875
|
if (isRecord$1(value) && typeof value[name] !== "undefined") return value[name];
|
|
1818
|
-
if (isBinarySchema(schema)) return `@${name}`;
|
|
1876
|
+
if (isBinarySchema$1(schema)) return `@${name}`;
|
|
1819
1877
|
}
|
|
1820
1878
|
function getFormParams(value, requestContent) {
|
|
1821
1879
|
const properties = getSchemaProperties(requestContent.value.schema);
|
|
@@ -1837,7 +1895,7 @@ function getBodySize(requestBody) {
|
|
|
1837
1895
|
function getRequestBody(requestContent) {
|
|
1838
1896
|
const value = getContentExample(requestContent?.value);
|
|
1839
1897
|
if (!requestContent || typeof value === "undefined") return void 0;
|
|
1840
|
-
if (isFormMediaType(requestContent.mediaType)) {
|
|
1898
|
+
if (isFormMediaType$1(requestContent.mediaType)) {
|
|
1841
1899
|
const params = getFormParams(value, requestContent);
|
|
1842
1900
|
return params.length > 0 ? { params } : void 0;
|
|
1843
1901
|
}
|
|
@@ -2342,7 +2400,8 @@ function getAuthOptions(spec, operation) {
|
|
|
2342
2400
|
return getSecurityRequirements(spec, operation).map((requirement, index) => {
|
|
2343
2401
|
const requirementSchemes = Object.keys(requirement).map((name) => ({
|
|
2344
2402
|
name,
|
|
2345
|
-
scheme: schemes[name]
|
|
2403
|
+
scheme: schemes[name],
|
|
2404
|
+
scopes: requirement[name] ?? []
|
|
2346
2405
|
})).filter((option) => Boolean(option.scheme));
|
|
2347
2406
|
return {
|
|
2348
2407
|
key: `requirement:${index}`,
|
|
@@ -2649,6 +2708,84 @@ function ResponseExamplesPanel(arg0) {
|
|
|
2649
2708
|
});
|
|
2650
2709
|
}
|
|
2651
2710
|
//#endregion
|
|
2711
|
+
//#region source/openapi/components/OpenApiAuthDocumentation.tsx
|
|
2712
|
+
function authSchemeType(option, apiKeyLabel) {
|
|
2713
|
+
const { scheme } = option;
|
|
2714
|
+
if (scheme.type === "http") return scheme.scheme?.toUpperCase() || "HTTP";
|
|
2715
|
+
if (scheme.type === "apiKey") return apiKeyLabel;
|
|
2716
|
+
if (scheme.type === "oauth2") return "OAUTH 2.0";
|
|
2717
|
+
if (scheme.type === "openIdConnect") return "OPENID CONNECT";
|
|
2718
|
+
return scheme.type?.toUpperCase() || "AUTH";
|
|
2719
|
+
}
|
|
2720
|
+
function OpenApiAuthDocumentation({ options }) {
|
|
2721
|
+
const t = require_i18n.useBuiltInText();
|
|
2722
|
+
if (options.length === 0) return null;
|
|
2723
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", { children: t("openapi.authentication") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2724
|
+
className: "not-prose my-6 border-y border-(--clarify-theme-tokens-colors-border)",
|
|
2725
|
+
children: options.map((option, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [index > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2726
|
+
className: "flex items-center gap-3 py-1",
|
|
2727
|
+
"aria-label": t("openapi.authOr"),
|
|
2728
|
+
children: [
|
|
2729
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "h-px flex-1 bg-(--clarify-theme-tokens-colors-border)" }),
|
|
2730
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2731
|
+
className: "text-2xs font-semibold text-(--clarify-ui-text-faint)",
|
|
2732
|
+
children: t("openapi.authOr")
|
|
2733
|
+
}),
|
|
2734
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "h-px flex-1 bg-(--clarify-theme-tokens-colors-border)" })
|
|
2735
|
+
]
|
|
2736
|
+
}) : null, option.schemes.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2737
|
+
className: "py-4 text-sm/6 font-medium text-(--clarify-theme-tokens-colors-foreground)",
|
|
2738
|
+
children: t("openapi.authNoAuth")
|
|
2739
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2740
|
+
className: "divide-y divide-(--clarify-theme-tokens-colors-border)",
|
|
2741
|
+
children: option.schemes.map((schemeOption, schemeIndex) => {
|
|
2742
|
+
const { scheme } = schemeOption;
|
|
2743
|
+
const details = [
|
|
2744
|
+
scheme.type === "apiKey" && scheme.in && scheme.name ? t("openapi.authLocation", {
|
|
2745
|
+
in: scheme.in,
|
|
2746
|
+
name: scheme.name
|
|
2747
|
+
}) : void 0,
|
|
2748
|
+
scheme.type === "http" && scheme.bearerFormat ? t("openapi.authBearerFormat", { format: scheme.bearerFormat }) : void 0,
|
|
2749
|
+
scheme.type === "openIdConnect" ? scheme.openIdConnectUrl : void 0,
|
|
2750
|
+
schemeOption.scopes.length > 0 ? t("openapi.authScopes", { scopes: schemeOption.scopes.join(", ") }) : void 0
|
|
2751
|
+
].filter((value) => Boolean(value));
|
|
2752
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [schemeIndex > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2753
|
+
className: "relative h-0",
|
|
2754
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2755
|
+
className: "absolute top-0 left-4 -translate-y-1/2 bg-(--clarify-theme-tokens-colors-background) px-1.5 text-2xs font-semibold text-(--clarify-ui-text-faint)",
|
|
2756
|
+
children: t("openapi.authAnd")
|
|
2757
|
+
})
|
|
2758
|
+
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2759
|
+
className: "py-4",
|
|
2760
|
+
children: [
|
|
2761
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
2762
|
+
className: "flex flex-wrap items-center gap-2",
|
|
2763
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2764
|
+
className: "font-mono text-sm/6 font-semibold text-(--clarify-theme-tokens-colors-foreground)",
|
|
2765
|
+
children: schemeOption.name
|
|
2766
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2767
|
+
className: "rounded bg-(--clarify-ui-subtle-background) px-1.5 py-0.5 text-2xs font-semibold text-(--clarify-ui-text-soft)",
|
|
2768
|
+
children: authSchemeType(schemeOption, t("openapi.authApiKey"))
|
|
2769
|
+
})]
|
|
2770
|
+
}),
|
|
2771
|
+
scheme.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, {
|
|
2772
|
+
className: "mt-2 text-sm/6 text-(--clarify-ui-text-soft) *:first:mt-0 *:last:mb-0",
|
|
2773
|
+
children: scheme.description
|
|
2774
|
+
}) : null,
|
|
2775
|
+
details.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
2776
|
+
className: "mt-2 flex min-w-0 flex-wrap gap-x-4 gap-y-1 text-xs/5 text-(--clarify-ui-text-faint)",
|
|
2777
|
+
children: details.map((detail) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
2778
|
+
className: "min-w-0 break-all font-mono",
|
|
2779
|
+
children: detail
|
|
2780
|
+
}, detail))
|
|
2781
|
+
}) : null
|
|
2782
|
+
]
|
|
2783
|
+
})] }, schemeOption.name);
|
|
2784
|
+
})
|
|
2785
|
+
})] }, option.key))
|
|
2786
|
+
})] });
|
|
2787
|
+
}
|
|
2788
|
+
//#endregion
|
|
2652
2789
|
//#region source/openapi/components/SchemaProperties.tsx
|
|
2653
2790
|
function getEnumDescriptions(schema) {
|
|
2654
2791
|
const descriptions = schema["x-enumDescriptions"];
|
|
@@ -3038,7 +3175,7 @@ function ResponseList(arg0) {
|
|
|
3038
3175
|
//#endregion
|
|
3039
3176
|
//#region source/openapi/components/EndpointSections.tsx
|
|
3040
3177
|
function EndpointRequest(arg0) {
|
|
3041
|
-
const { spec, path, method, operationSource = "path", description, groupedParameters, parameters, requestBody, requestContents, requestSchema, selectedRequestMediaType, onSelectRequestMediaType, selectedServer, serverVariables, auth, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
3178
|
+
const { spec, path, method, operationSource = "path", description, groupedParameters, parameters, requestBody, requestContents, requestSchema, selectedRequestMediaType, onSelectRequestMediaType, selectedServer, serverVariables, authOptions, auth, sharedExampleKey, onSelectExampleKey } = arg0;
|
|
3042
3179
|
const t = require_i18n.useBuiltInText();
|
|
3043
3180
|
const hasRequestBody = Boolean(requestBody && requestContents.length > 0);
|
|
3044
3181
|
const renderDescription = () => {
|
|
@@ -3061,6 +3198,7 @@ function EndpointRequest(arg0) {
|
|
|
3061
3198
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Col, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3062
3199
|
className: "w-full",
|
|
3063
3200
|
children: [
|
|
3201
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiAuthDocumentation, { options: authOptions }),
|
|
3064
3202
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ParameterList, {
|
|
3065
3203
|
title: t("openapi.pathParameters"),
|
|
3066
3204
|
parameters: groupedParameters.path
|
|
@@ -3156,7 +3294,7 @@ function OptionContent(arg0) {
|
|
|
3156
3294
|
})] });
|
|
3157
3295
|
}
|
|
3158
3296
|
function InlineListbox(arg0) {
|
|
3159
|
-
const { label, value, options, onChange, compact = false, buttonContent, buttonClassName, className, invalid, describedBy, disabled = false } = arg0;
|
|
3297
|
+
const { label, value, options, onChange, compact = false, buttonContent, buttonClassName, className, invalid, describedBy, disabled = false, title } = arg0;
|
|
3160
3298
|
const selected = options.find((option) => option.value === value);
|
|
3161
3299
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_headlessui_react.Listbox, {
|
|
3162
3300
|
value,
|
|
@@ -3168,6 +3306,7 @@ function InlineListbox(arg0) {
|
|
|
3168
3306
|
"aria-label": label,
|
|
3169
3307
|
"aria-invalid": invalid || void 0,
|
|
3170
3308
|
"aria-describedby": describedBy,
|
|
3309
|
+
title,
|
|
3171
3310
|
className: (0, clsx.default)(buttonClassName ?? defaultButtonClassName, buttonClassName ? null : compact ? "min-h-7 max-w-32 px-2 py-0.5 text-xs" : "min-h-8 w-full px-2 text-xs"),
|
|
3172
3311
|
children: buttonContent ?? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3173
3312
|
className: "truncate",
|
|
@@ -3345,7 +3484,8 @@ function parseBodyObject(body) {
|
|
|
3345
3484
|
return;
|
|
3346
3485
|
}
|
|
3347
3486
|
}
|
|
3348
|
-
function buildRequestBody(body, mediaType) {
|
|
3487
|
+
function buildRequestBody(body, mediaType, files) {
|
|
3488
|
+
if (files[""] && !mediaType.includes("multipart/form-data")) return files[""];
|
|
3349
3489
|
const values = parseBodyObject(body);
|
|
3350
3490
|
if (mediaType.includes("application/x-www-form-urlencoded") && values) {
|
|
3351
3491
|
const params = new URLSearchParams();
|
|
@@ -3354,7 +3494,18 @@ function buildRequestBody(body, mediaType) {
|
|
|
3354
3494
|
}
|
|
3355
3495
|
if (mediaType.includes("multipart/form-data") && values) {
|
|
3356
3496
|
const form = new FormData();
|
|
3357
|
-
Object.entries(values).forEach(([name, value]) =>
|
|
3497
|
+
Object.entries(values).forEach(([name, value]) => {
|
|
3498
|
+
const file = files[name];
|
|
3499
|
+
form.append(name, file ?? (typeof value === "string" ? value : JSON.stringify(value)));
|
|
3500
|
+
});
|
|
3501
|
+
Object.entries(files).forEach(([name, file]) => {
|
|
3502
|
+
if (name && !(name in values)) form.append(name, file);
|
|
3503
|
+
});
|
|
3504
|
+
return form;
|
|
3505
|
+
}
|
|
3506
|
+
if (mediaType.includes("multipart/form-data") && Object.keys(files).length > 0) {
|
|
3507
|
+
const form = new FormData();
|
|
3508
|
+
Object.entries(files).forEach(([name, file]) => form.append(name, file));
|
|
3358
3509
|
return form;
|
|
3359
3510
|
}
|
|
3360
3511
|
return body;
|
|
@@ -3457,9 +3608,9 @@ function buildApiRequest(input) {
|
|
|
3457
3608
|
}
|
|
3458
3609
|
const url = new URL(joinPath(expandServerUrl(input.server, input.serverVariables ?? {}), path), input.baseUrl);
|
|
3459
3610
|
query.forEach((value, key) => url.searchParams.append(key, value));
|
|
3460
|
-
const body = input.body?.trim();
|
|
3611
|
+
const body = input.body?.trim() ?? "";
|
|
3461
3612
|
const mediaType = input.mediaType || "application/json";
|
|
3462
|
-
const requestBody = body && input.method.toUpperCase() !== "GET" && input.method.toUpperCase() !== "HEAD" ? buildRequestBody(body, mediaType) : void 0;
|
|
3613
|
+
const requestBody = (Boolean(body) || Object.keys(input.bodyFiles ?? {}).length > 0) && input.method.toUpperCase() !== "GET" && input.method.toUpperCase() !== "HEAD" ? buildRequestBody(body, mediaType, input.bodyFiles ?? {}) : void 0;
|
|
3463
3614
|
if (requestBody && !(requestBody instanceof FormData)) headers.set("Content-Type", mediaType);
|
|
3464
3615
|
return {
|
|
3465
3616
|
url: url.toString(),
|
|
@@ -3518,6 +3669,157 @@ function OpenApiAuthPanel(arg0) {
|
|
|
3518
3669
|
});
|
|
3519
3670
|
}
|
|
3520
3671
|
//#endregion
|
|
3672
|
+
//#region source/openapi/components/OpenApiRequestBodyEditor.tsx
|
|
3673
|
+
function parseBodyRecord(body) {
|
|
3674
|
+
try {
|
|
3675
|
+
const value = JSON.parse(body);
|
|
3676
|
+
return isRecord$1(value) ? value : {};
|
|
3677
|
+
} catch {
|
|
3678
|
+
return {};
|
|
3679
|
+
}
|
|
3680
|
+
}
|
|
3681
|
+
function isBinarySchema(schema) {
|
|
3682
|
+
return isRecord$1(schema) && schema.format === "binary";
|
|
3683
|
+
}
|
|
3684
|
+
function isTextMediaType(mediaType) {
|
|
3685
|
+
return mediaType.startsWith("text/") || mediaType.includes("json") || mediaType.includes("xml") || mediaType.includes("yaml") || mediaType.includes("javascript") || mediaType.includes("form");
|
|
3686
|
+
}
|
|
3687
|
+
function isFormMediaType(mediaType) {
|
|
3688
|
+
const normalized = mediaType.split(";", 1)[0].trim().toLowerCase();
|
|
3689
|
+
return normalized === "application/x-www-form-urlencoded" || normalized === "multipart/form-data";
|
|
3690
|
+
}
|
|
3691
|
+
function valueFromInput(schema, value) {
|
|
3692
|
+
if (!isRecord$1(schema)) return value;
|
|
3693
|
+
if (schemaHasType(schema, "integer")) return value === "" ? "" : Number.parseInt(value, 10);
|
|
3694
|
+
if (schemaHasType(schema, "number")) return value === "" ? "" : Number(value);
|
|
3695
|
+
if (schemaHasType(schema, "boolean")) return value === "true";
|
|
3696
|
+
if (schemaHasType(schema, "array") || schemaHasType(schema, "object")) try {
|
|
3697
|
+
return JSON.parse(value);
|
|
3698
|
+
} catch {
|
|
3699
|
+
return value;
|
|
3700
|
+
}
|
|
3701
|
+
return value;
|
|
3702
|
+
}
|
|
3703
|
+
function OpenApiRequestBodyEditor(arg0) {
|
|
3704
|
+
const { spec, mediaType, content, body, files, onBodyChange, onFileChange } = arg0;
|
|
3705
|
+
const schema = resolveSchema(spec, content?.schema);
|
|
3706
|
+
const schemaRecord = isRecord$1(schema) ? schema : void 0;
|
|
3707
|
+
const properties = isRecord$1(schemaRecord?.properties) ? schemaRecord.properties : void 0;
|
|
3708
|
+
const required = new Set(Array.isArray(schemaRecord?.required) ? schemaRecord.required.map(String) : []);
|
|
3709
|
+
const values = parseBodyRecord(body);
|
|
3710
|
+
function updateProperty(name, propertySchema, value) {
|
|
3711
|
+
onBodyChange(JSON.stringify({
|
|
3712
|
+
...values,
|
|
3713
|
+
[name]: valueFromInput(propertySchema, value)
|
|
3714
|
+
}, null, 2));
|
|
3715
|
+
}
|
|
3716
|
+
function renderProperty(name, unresolvedSchema) {
|
|
3717
|
+
const propertySchema = resolveSchema(spec, unresolvedSchema);
|
|
3718
|
+
const propertyRecord = isRecord$1(propertySchema) ? propertySchema : void 0;
|
|
3719
|
+
const type = schemaToType(propertySchema) ?? "string";
|
|
3720
|
+
const value = values[name];
|
|
3721
|
+
const fieldId = `openapi-request-body-${name}`.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
3722
|
+
const options = Array.isArray(propertyRecord?.enum) ? propertyRecord.enum : [];
|
|
3723
|
+
const structured = schemaHasType(propertySchema, "array") || schemaHasType(propertySchema, "object");
|
|
3724
|
+
const serializedValue = structured && typeof value !== "undefined" ? JSON.stringify(value, null, 2) : String(value ?? "");
|
|
3725
|
+
let control;
|
|
3726
|
+
if (isBinarySchema(propertySchema)) control = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3727
|
+
id: fieldId,
|
|
3728
|
+
"aria-label": name,
|
|
3729
|
+
type: "file",
|
|
3730
|
+
required: required.has(name),
|
|
3731
|
+
onChange: (event) => onFileChange(name, event.target.files?.[0]),
|
|
3732
|
+
className: "min-h-8 w-full px-2 py-1 text-xs text-(--clarify-theme-tokens-colors-foreground) file:mr-2 file:rounded-(--clarify-theme-tokens-radius-md) file:border file:border-(--clarify-theme-tokens-colors-border) file:bg-(--clarify-ui-subtle-background) file:px-2 file:py-1 file:text-xs file:text-(--clarify-ui-text-strong)"
|
|
3733
|
+
});
|
|
3734
|
+
else if (options.length > 0) control = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
3735
|
+
id: fieldId,
|
|
3736
|
+
"aria-label": name,
|
|
3737
|
+
value: serializedValue,
|
|
3738
|
+
required: required.has(name),
|
|
3739
|
+
onChange: (event) => updateProperty(name, propertySchema, event.target.value),
|
|
3740
|
+
className: "h-8 w-full border-0 bg-transparent px-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden focus:bg-(--clarify-ui-hover-background)",
|
|
3741
|
+
children: [!required.has(name) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", { value: "" }) : null, options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
3742
|
+
value: String(option),
|
|
3743
|
+
children: String(option)
|
|
3744
|
+
}, String(option)))]
|
|
3745
|
+
});
|
|
3746
|
+
else if (schemaHasType(propertySchema, "boolean")) control = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3747
|
+
id: fieldId,
|
|
3748
|
+
"aria-label": name,
|
|
3749
|
+
type: "checkbox",
|
|
3750
|
+
checked: value === true,
|
|
3751
|
+
onChange: (event) => updateProperty(name, propertySchema, String(event.target.checked)),
|
|
3752
|
+
className: "size-4 accent-(--clarify-theme-tokens-colors-primary)"
|
|
3753
|
+
});
|
|
3754
|
+
else if (structured) control = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
3755
|
+
id: fieldId,
|
|
3756
|
+
"aria-label": name,
|
|
3757
|
+
value: serializedValue,
|
|
3758
|
+
required: required.has(name),
|
|
3759
|
+
rows: 3,
|
|
3760
|
+
spellCheck: false,
|
|
3761
|
+
onChange: (event) => updateProperty(name, propertySchema, event.target.value),
|
|
3762
|
+
className: "w-full resize-y border-0 bg-transparent p-2 font-mono text-xs/5 text-(--clarify-theme-tokens-colors-foreground) outline-hidden focus:bg-(--clarify-ui-hover-background)"
|
|
3763
|
+
});
|
|
3764
|
+
else control = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3765
|
+
id: fieldId,
|
|
3766
|
+
"aria-label": name,
|
|
3767
|
+
value: serializedValue,
|
|
3768
|
+
type: schemaHasType(propertySchema, "integer") || schemaHasType(propertySchema, "number") ? "number" : propertyRecord?.format === "date" ? "date" : propertyRecord?.format === "date-time" ? "datetime-local" : "text",
|
|
3769
|
+
required: required.has(name),
|
|
3770
|
+
onChange: (event) => updateProperty(name, propertySchema, event.target.value),
|
|
3771
|
+
className: "h-8 w-full border-0 bg-transparent px-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground) outline-hidden focus:bg-(--clarify-ui-hover-background)"
|
|
3772
|
+
});
|
|
3773
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3774
|
+
className: "grid min-w-0 grid-cols-[minmax(0,1fr)_minmax(0,1.3fr)]",
|
|
3775
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
3776
|
+
htmlFor: fieldId,
|
|
3777
|
+
className: "flex min-h-8 min-w-0 items-center gap-1.5 border-r border-(--clarify-theme-tokens-colors-border) px-2 text-xs text-(--clarify-ui-text-strong)",
|
|
3778
|
+
children: [
|
|
3779
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3780
|
+
className: "truncate font-mono",
|
|
3781
|
+
children: name
|
|
3782
|
+
}),
|
|
3783
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3784
|
+
className: "font-mono text-2xs text-(--clarify-ui-text-faint)",
|
|
3785
|
+
children: type
|
|
3786
|
+
}),
|
|
3787
|
+
required.has(name) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3788
|
+
className: "text-(--clarify-error-accent-text)",
|
|
3789
|
+
children: "*"
|
|
3790
|
+
}) : null
|
|
3791
|
+
]
|
|
3792
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3793
|
+
className: "flex min-w-0 items-center",
|
|
3794
|
+
children: [control, files[name] ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3795
|
+
className: "sr-only",
|
|
3796
|
+
children: files[name].name
|
|
3797
|
+
}) : null]
|
|
3798
|
+
})]
|
|
3799
|
+
}, name);
|
|
3800
|
+
}
|
|
3801
|
+
if (properties && isFormMediaType(mediaType)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3802
|
+
className: "divide-y divide-(--clarify-theme-tokens-colors-border)",
|
|
3803
|
+
children: Object.entries(properties).map(([name, propertySchema]) => renderProperty(name, propertySchema))
|
|
3804
|
+
});
|
|
3805
|
+
if (isBinarySchema(schema) || !isTextMediaType(mediaType)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3806
|
+
className: "flex min-h-44 items-start p-3",
|
|
3807
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
3808
|
+
"aria-label": mediaType,
|
|
3809
|
+
type: "file",
|
|
3810
|
+
onChange: (event) => onFileChange("", event.target.files?.[0]),
|
|
3811
|
+
className: "w-full text-xs text-(--clarify-theme-tokens-colors-foreground) file:mr-2 file:rounded-(--clarify-theme-tokens-radius-md) file:border file:border-(--clarify-theme-tokens-colors-border) file:bg-(--clarify-ui-subtle-background) file:px-2 file:py-1 file:text-xs file:text-(--clarify-ui-text-strong)"
|
|
3812
|
+
})
|
|
3813
|
+
});
|
|
3814
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
|
|
3815
|
+
"aria-label": mediaType,
|
|
3816
|
+
value: body,
|
|
3817
|
+
onChange: (event) => onBodyChange(event.target.value),
|
|
3818
|
+
spellCheck: false,
|
|
3819
|
+
className: "block h-full min-h-44 w-full resize-none border-0 bg-(--clarify-code-background) p-3 font-mono text-xs/5 text-(--clarify-code-text) outline-hidden focus:ring-2 focus:ring-inset focus:ring-(--clarify-theme-tokens-colors-primary)"
|
|
3820
|
+
});
|
|
3821
|
+
}
|
|
3822
|
+
//#endregion
|
|
3521
3823
|
//#region source/openapi/components/OpenApiRequestFields.tsx
|
|
3522
3824
|
function RequestField(arg0) {
|
|
3523
3825
|
const { spec, parameter, value, enabled, onChange, onEnabledChange, issue } = arg0;
|
|
@@ -3554,7 +3856,7 @@ function RequestField(arg0) {
|
|
|
3554
3856
|
children: description
|
|
3555
3857
|
}),
|
|
3556
3858
|
side: "bottom",
|
|
3557
|
-
className: "mr-1 shrink-0 [
|
|
3859
|
+
className: "mr-1 shrink-0 *:[[role=tooltip]]:w-80 *:[[role=tooltip]]:max-w-[min(20rem,calc(100vw-2rem))] *:[[role=tooltip]]:border *:[[role=tooltip]]:border-(--clarify-theme-tokens-colors-border) *:[[role=tooltip]]:bg-(--clarify-theme-tokens-colors-surface) *:[[role=tooltip]]:p-3 *:[[role=tooltip]]:text-(--clarify-ui-text) *:[[role=tooltip]]:shadow-xl",
|
|
3558
3860
|
triggerClassName: "clarify-field-description-trigger clarify-ui-control inline-flex size-7 items-center justify-center rounded-md !border-b-0 text-(--clarify-ui-text-faint) transition-colors",
|
|
3559
3861
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.InfoIcon, {
|
|
3560
3862
|
className: "size-4",
|
|
@@ -3600,7 +3902,7 @@ function RequestField(arg0) {
|
|
|
3600
3902
|
})
|
|
3601
3903
|
}),
|
|
3602
3904
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3603
|
-
className: (0, clsx.default)("col-start-2 flex min-w-0 items-center border-t border-(--clarify-theme-tokens-colors-border) sm:col-start-3 sm:row-start-1 sm:border-t-0", !enabled && "
|
|
3905
|
+
className: (0, clsx.default)("col-start-2 flex min-w-0 items-center border-t border-(--clarify-theme-tokens-colors-border) sm:col-start-3 sm:row-start-1 sm:border-t-0", !enabled && "bg-(--clarify-ui-subtle-background)"),
|
|
3604
3906
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3605
3907
|
className: "min-w-0 flex-1",
|
|
3606
3908
|
children: itemOptions.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MultiInlineListbox, {
|
|
@@ -3713,6 +4015,57 @@ function parseJson(value) {
|
|
|
3713
4015
|
return;
|
|
3714
4016
|
}
|
|
3715
4017
|
}
|
|
4018
|
+
var textLanguages = {
|
|
4019
|
+
"application/graphql": "graphql",
|
|
4020
|
+
"application/javascript": "javascript",
|
|
4021
|
+
"application/sql": "sql",
|
|
4022
|
+
"application/typescript": "typescript",
|
|
4023
|
+
"application/xml": "xml",
|
|
4024
|
+
"application/x-httpd-php": "php",
|
|
4025
|
+
"application/x-sh": "shellscript",
|
|
4026
|
+
"application/xhtml+xml": "html",
|
|
4027
|
+
"application/x-www-form-urlencoded": "http",
|
|
4028
|
+
"text/css": "css",
|
|
4029
|
+
"text/csv": "csv",
|
|
4030
|
+
"text/html": "html",
|
|
4031
|
+
"text/javascript": "javascript",
|
|
4032
|
+
"text/markdown": "markdown",
|
|
4033
|
+
"text/plain": "text",
|
|
4034
|
+
"text/xml": "xml"
|
|
4035
|
+
};
|
|
4036
|
+
function normalizedMediaType(contentType) {
|
|
4037
|
+
return contentType.split(";", 1)[0].trim().toLowerCase();
|
|
4038
|
+
}
|
|
4039
|
+
function getResponseTextPreview(contentType, body) {
|
|
4040
|
+
const mediaType = normalizedMediaType(contentType);
|
|
4041
|
+
if (mediaType === "application/json" || mediaType.endsWith("+json")) {
|
|
4042
|
+
const parsed = parseJson(body);
|
|
4043
|
+
return {
|
|
4044
|
+
code: typeof parsed === "undefined" ? body : JSON.stringify(parsed, null, 2),
|
|
4045
|
+
language: "json"
|
|
4046
|
+
};
|
|
4047
|
+
}
|
|
4048
|
+
if (mediaType === "application/yaml" || mediaType === "application/x-yaml" || mediaType === "text/yaml" || mediaType === "text/x-yaml" || mediaType.endsWith("+yaml")) try {
|
|
4049
|
+
return {
|
|
4050
|
+
code: (0, yaml.stringify)((0, yaml.parse)(body)).trimEnd(),
|
|
4051
|
+
language: "yaml"
|
|
4052
|
+
};
|
|
4053
|
+
} catch {
|
|
4054
|
+
return {
|
|
4055
|
+
code: body,
|
|
4056
|
+
language: "yaml"
|
|
4057
|
+
};
|
|
4058
|
+
}
|
|
4059
|
+
const language = textLanguages[mediaType] ?? (mediaType.startsWith("text/") ? mediaType.slice(5) || "text" : void 0);
|
|
4060
|
+
return language ? {
|
|
4061
|
+
code: body,
|
|
4062
|
+
language
|
|
4063
|
+
} : void 0;
|
|
4064
|
+
}
|
|
4065
|
+
function canPreviewResponse(contentType) {
|
|
4066
|
+
const mediaType = normalizedMediaType(contentType);
|
|
4067
|
+
return Boolean(getResponseTextPreview(contentType, "") || mediaType.startsWith("image/") || mediaType.startsWith("audio/") || mediaType.startsWith("video/"));
|
|
4068
|
+
}
|
|
3716
4069
|
function ResponseState(arg0) {
|
|
3717
4070
|
const { icon: Icon, title, description, tone = "default" } = arg0;
|
|
3718
4071
|
const error = tone === "error";
|
|
@@ -3741,38 +4094,6 @@ function ResponseState(arg0) {
|
|
|
3741
4094
|
})
|
|
3742
4095
|
});
|
|
3743
4096
|
}
|
|
3744
|
-
function JsonPreview(arg0) {
|
|
3745
|
-
const { value } = arg0;
|
|
3746
|
-
if (Array.isArray(value)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3747
|
-
className: "space-y-1 border-l border-(--clarify-code-border) pl-3",
|
|
3748
|
-
children: value.map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3749
|
-
className: "mr-2 text-(--clarify-code-faint)",
|
|
3750
|
-
children: index
|
|
3751
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(JsonPreview, { value: item })] }, index))
|
|
3752
|
-
});
|
|
3753
|
-
if (isRecord$1(value)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3754
|
-
className: "space-y-1 border-l border-(--clarify-code-border) pl-3",
|
|
3755
|
-
children: Object.entries(value).map(([key, item]) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3756
|
-
className: "grid grid-cols-[minmax(5rem,auto)_1fr] gap-3",
|
|
3757
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3758
|
-
className: "text-(--clarify-code-property)",
|
|
3759
|
-
children: key
|
|
3760
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(JsonPreview, { value: item })]
|
|
3761
|
-
}, key))
|
|
3762
|
-
});
|
|
3763
|
-
if (value === null) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3764
|
-
className: "text-(--clarify-code-faint)",
|
|
3765
|
-
children: "null"
|
|
3766
|
-
});
|
|
3767
|
-
if (typeof value === "string") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3768
|
-
className: "wrap-break-word text-(--clarify-code-string)",
|
|
3769
|
-
children: value
|
|
3770
|
-
});
|
|
3771
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
3772
|
-
className: "text-(--clarify-code-number)",
|
|
3773
|
-
children: String(value)
|
|
3774
|
-
});
|
|
3775
|
-
}
|
|
3776
4097
|
function CopyButton(arg0) {
|
|
3777
4098
|
const { value } = arg0;
|
|
3778
4099
|
const t = require_i18n.useBuiltInText();
|
|
@@ -3829,22 +4150,12 @@ function ResponseMedia(arg0) {
|
|
|
3829
4150
|
function ResponsePreview(arg0) {
|
|
3830
4151
|
const { exchange } = arg0;
|
|
3831
4152
|
const t = require_i18n.useBuiltInText();
|
|
3832
|
-
const contentType = exchange.contentType
|
|
4153
|
+
const contentType = normalizedMediaType(exchange.contentType);
|
|
3833
4154
|
if (!exchange.size) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseState, {
|
|
3834
4155
|
icon: lucide_react.FileX2Icon,
|
|
3835
4156
|
title: t("openapi.responseBodyEmptyTitle"),
|
|
3836
4157
|
description: t("openapi.responseBodyEmpty")
|
|
3837
4158
|
});
|
|
3838
|
-
if (contentType.includes("json")) {
|
|
3839
|
-
const parsed = parseJson(exchange.body);
|
|
3840
|
-
return typeof parsed === "undefined" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
3841
|
-
className: "whitespace-pre-wrap wrap-break-word font-mono text-xs/5",
|
|
3842
|
-
children: exchange.body
|
|
3843
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3844
|
-
className: "overflow-auto font-mono text-xs/5",
|
|
3845
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(JsonPreview, { value: parsed })
|
|
3846
|
-
});
|
|
3847
|
-
}
|
|
3848
4159
|
if (contentType.startsWith("image/")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponseMedia, {
|
|
3849
4160
|
blob: exchange.blob,
|
|
3850
4161
|
type: "image"
|
|
@@ -3857,15 +4168,19 @@ function ResponsePreview(arg0) {
|
|
|
3857
4168
|
blob: exchange.blob,
|
|
3858
4169
|
type: "video"
|
|
3859
4170
|
});
|
|
3860
|
-
if (contentType
|
|
4171
|
+
if (contentType === "text/html" || contentType === "application/xhtml+xml") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("iframe", {
|
|
3861
4172
|
srcDoc: exchange.body,
|
|
3862
4173
|
sandbox: "",
|
|
3863
4174
|
title: "Response preview",
|
|
3864
4175
|
className: "h-96 w-full border-0 bg-white"
|
|
3865
4176
|
});
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
4177
|
+
const textPreview = getResponseTextPreview(exchange.contentType, exchange.body);
|
|
4178
|
+
if (textPreview) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
4179
|
+
className: "max-h-128 overflow-auto whitespace-pre-wrap wrap-break-word font-mono text-xs/5",
|
|
4180
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(HighlightedCode, {
|
|
4181
|
+
code: textPreview.code,
|
|
4182
|
+
language: textPreview.language
|
|
4183
|
+
})
|
|
3869
4184
|
});
|
|
3870
4185
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3871
4186
|
className: "grid min-h-56 place-items-center text-xs text-(--clarify-code-faint)",
|
|
@@ -3972,7 +4287,10 @@ function HiddenCookies() {
|
|
|
3972
4287
|
function OpenApiResponseViewer(arg0) {
|
|
3973
4288
|
const { exchange, error } = arg0;
|
|
3974
4289
|
const t = require_i18n.useBuiltInText();
|
|
3975
|
-
const [
|
|
4290
|
+
const [bodyModeSelection, setBodyModeSelection] = (0, react.useState)();
|
|
4291
|
+
const previewAvailable = exchange ? canPreviewResponse(exchange.contentType) : false;
|
|
4292
|
+
const selectedBodyMode = bodyModeSelection && bodyModeSelection.exchange === exchange ? bodyModeSelection.mode : "preview";
|
|
4293
|
+
const activeBodyMode = previewAvailable ? selectedBodyMode : "raw";
|
|
3976
4294
|
function downloadBody() {
|
|
3977
4295
|
if (!exchange) return;
|
|
3978
4296
|
const url = URL.createObjectURL(exchange.blob);
|
|
@@ -4054,12 +4372,15 @@ function OpenApiResponseViewer(arg0) {
|
|
|
4054
4372
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4055
4373
|
role: "tablist",
|
|
4056
4374
|
className: "flex",
|
|
4057
|
-
children: ["preview", "raw"].map((mode) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4375
|
+
children: ["preview", "raw"].filter((mode) => mode === "raw" || previewAvailable).map((mode) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4058
4376
|
type: "button",
|
|
4059
4377
|
role: "tab",
|
|
4060
|
-
"aria-selected":
|
|
4061
|
-
onClick: () =>
|
|
4062
|
-
|
|
4378
|
+
"aria-selected": activeBodyMode === mode,
|
|
4379
|
+
onClick: () => setBodyModeSelection({
|
|
4380
|
+
exchange,
|
|
4381
|
+
mode
|
|
4382
|
+
}),
|
|
4383
|
+
className: (0, clsx.default)("border-b-2 px-2.5 py-1 text-2xs font-semibold", activeBodyMode === mode ? "border-(--clarify-theme-tokens-colors-primary) text-(--clarify-code-text)" : "border-transparent text-(--clarify-code-muted)"),
|
|
4063
4384
|
children: mode === "preview" ? t("openapi.preview") : t("openapi.raw")
|
|
4064
4385
|
}, mode))
|
|
4065
4386
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -4078,7 +4399,7 @@ function OpenApiResponseViewer(arg0) {
|
|
|
4078
4399
|
})]
|
|
4079
4400
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4080
4401
|
className: "p-4",
|
|
4081
|
-
children:
|
|
4402
|
+
children: activeBodyMode === "preview" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ResponsePreview, { exchange }) : exchange.size ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
|
|
4082
4403
|
className: "max-h-128 overflow-auto whitespace-pre-wrap wrap-break-word font-mono text-xs/5",
|
|
4083
4404
|
children: exchange.body
|
|
4084
4405
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -4200,6 +4521,23 @@ function validateRequestParameters(spec, parameters, values) {
|
|
|
4200
4521
|
}
|
|
4201
4522
|
//#endregion
|
|
4202
4523
|
//#region source/openapi/components/useOpenApiRequestState.ts
|
|
4524
|
+
function initialRequestBody(spec, content) {
|
|
4525
|
+
const example = getExampleEntries(content, spec)[0];
|
|
4526
|
+
if (!example?.generated) return stringifyExample(example?.value);
|
|
4527
|
+
const schema = resolveSchema(spec, content?.schema);
|
|
4528
|
+
if (isRecord$1(schema) && schema.format === "binary") return "";
|
|
4529
|
+
if (!isRecord$1(example.value) || !isRecord$1(schema) || !isRecord$1(schema.properties)) return stringifyExample(example.value);
|
|
4530
|
+
const value = { ...example.value };
|
|
4531
|
+
Object.entries(schema.properties).forEach(([name, propertySchema]) => {
|
|
4532
|
+
const resolved = resolveSchema(spec, propertySchema);
|
|
4533
|
+
if (isRecord$1(resolved) && resolved.format === "binary") delete value[name];
|
|
4534
|
+
});
|
|
4535
|
+
return stringifyExample(value);
|
|
4536
|
+
}
|
|
4537
|
+
function requestBodyForExample(spec, content, exampleKey) {
|
|
4538
|
+
const example = getExampleEntries(content, spec).find((entry) => !entry.generated && entry.key === exampleKey);
|
|
4539
|
+
return example ? stringifyExample(example.value) : initialRequestBody(spec, content);
|
|
4540
|
+
}
|
|
4203
4541
|
function useOpenApiRequestTarget(spec, path, operation, operationSource) {
|
|
4204
4542
|
const servers = getServers(spec, operation, path, operationSource);
|
|
4205
4543
|
const [selectedServerKey, setSelectedServerKey] = (0, react.useState)(getServerKey(servers[0], 0));
|
|
@@ -4214,7 +4552,9 @@ function useOpenApiRequestTarget(spec, path, operation, operationSource) {
|
|
|
4214
4552
|
const clearCredential = useOpenApiStore((state) => state.clearCredential);
|
|
4215
4553
|
const requestContents = getMediaTypeEntries(getRequestBody$1(spec, operation)?.content, spec);
|
|
4216
4554
|
const [mediaType, setMediaType] = (0, react.useState)(requestContents[0]?.mediaType ?? "");
|
|
4217
|
-
const
|
|
4555
|
+
const selectedContent = requestContents.find((entry) => entry.mediaType === mediaType) ?? requestContents[0];
|
|
4556
|
+
const [body, setBody] = (0, react.useState)(initialRequestBody(spec, selectedContent?.value));
|
|
4557
|
+
const [bodyFiles, setBodyFiles] = (0, react.useState)({});
|
|
4218
4558
|
function selectServer(value) {
|
|
4219
4559
|
const nextServer = servers.find((server, index) => getServerKey(server, index) === value) ?? servers[0];
|
|
4220
4560
|
setSelectedServerKey(value);
|
|
@@ -4223,7 +4563,20 @@ function useOpenApiRequestTarget(spec, path, operation, operationSource) {
|
|
|
4223
4563
|
function selectMediaType(value) {
|
|
4224
4564
|
const content = requestContents.find((entry) => entry.mediaType === value)?.value;
|
|
4225
4565
|
setMediaType(value);
|
|
4226
|
-
setBody(
|
|
4566
|
+
setBody(initialRequestBody(spec, content));
|
|
4567
|
+
setBodyFiles({});
|
|
4568
|
+
}
|
|
4569
|
+
function applyBodyExample(exampleKey) {
|
|
4570
|
+
setBody(requestBodyForExample(spec, selectedContent?.value, exampleKey));
|
|
4571
|
+
setBodyFiles({});
|
|
4572
|
+
}
|
|
4573
|
+
function setBodyFile(name, file) {
|
|
4574
|
+
setBodyFiles((current) => {
|
|
4575
|
+
const next = { ...current };
|
|
4576
|
+
if (file) next[name] = file;
|
|
4577
|
+
else delete next[name];
|
|
4578
|
+
return next;
|
|
4579
|
+
});
|
|
4227
4580
|
}
|
|
4228
4581
|
return {
|
|
4229
4582
|
servers,
|
|
@@ -4243,13 +4596,20 @@ function useOpenApiRequestTarget(spec, path, operation, operationSource) {
|
|
|
4243
4596
|
clearCredential,
|
|
4244
4597
|
requestContents,
|
|
4245
4598
|
mediaType,
|
|
4599
|
+
selectedContent,
|
|
4246
4600
|
body,
|
|
4247
4601
|
setBody,
|
|
4602
|
+
bodyFiles,
|
|
4603
|
+
setBodyFile,
|
|
4604
|
+
applyBodyExample,
|
|
4248
4605
|
selectMediaType
|
|
4249
4606
|
};
|
|
4250
4607
|
}
|
|
4251
|
-
function useOpenApiParameterState(spec, parameters, initialParameterValue) {
|
|
4252
|
-
const [parameterValues, setParameterValues] = (0, react.useState)(() => Object.fromEntries(parameters.map((parameter) =>
|
|
4608
|
+
function useOpenApiParameterState(spec, parameters, initialParameterValue, initialExampleKey = "") {
|
|
4609
|
+
const [parameterValues, setParameterValues] = (0, react.useState)(() => Object.fromEntries(parameters.map((parameter) => {
|
|
4610
|
+
const example = getParameterExampleEntries(parameter).find((entry) => entry.key === initialExampleKey);
|
|
4611
|
+
return [parameterKey(parameter), example ? stringifyExample(example.value) : initialParameterValue(parameter)];
|
|
4612
|
+
})));
|
|
4253
4613
|
const [parameterEnabled, setParameterEnabled] = (0, react.useState)(() => Object.fromEntries(parameters.map((parameter) => [parameterKey(parameter), true])));
|
|
4254
4614
|
const [parameterIssues, setParameterIssues] = (0, react.useState)({});
|
|
4255
4615
|
function setParameterGroupValues(grouped, mode) {
|
|
@@ -4284,6 +4644,13 @@ function useOpenApiParameterState(spec, parameters, initialParameterValue) {
|
|
|
4284
4644
|
return next;
|
|
4285
4645
|
});
|
|
4286
4646
|
}
|
|
4647
|
+
function applyParameterExample(exampleKey) {
|
|
4648
|
+
setParameterValues(Object.fromEntries(parameters.map((parameter) => {
|
|
4649
|
+
const example = getParameterExampleEntries(parameter).find((entry) => entry.key === exampleKey);
|
|
4650
|
+
return [parameterKey(parameter), example ? stringifyExample(example.value) : initialParameterValue(parameter)];
|
|
4651
|
+
})));
|
|
4652
|
+
setParameterIssues({});
|
|
4653
|
+
}
|
|
4287
4654
|
function validate(parametersToValidate) {
|
|
4288
4655
|
const issues = validateRequestParameters(spec, parametersToValidate, parameterValues);
|
|
4289
4656
|
setParameterIssues(issues);
|
|
@@ -4296,6 +4663,7 @@ function useOpenApiParameterState(spec, parameters, initialParameterValue) {
|
|
|
4296
4663
|
setParameterGroupValues,
|
|
4297
4664
|
setParameterIncluded,
|
|
4298
4665
|
updateParameterValue,
|
|
4666
|
+
applyParameterExample,
|
|
4299
4667
|
validate
|
|
4300
4668
|
};
|
|
4301
4669
|
}
|
|
@@ -4335,6 +4703,7 @@ function useOpenApiRequestExecution() {
|
|
|
4335
4703
|
//#endregion
|
|
4336
4704
|
//#region source/openapi/components/OpenApiRequest.tsx
|
|
4337
4705
|
function initialParameterValue(spec, parameter) {
|
|
4706
|
+
if (typeof parameter.example !== "undefined") return stringifyExample(parameter.example);
|
|
4338
4707
|
const schema = resolveSchema(spec, parameter.schema);
|
|
4339
4708
|
if (!isRecord$1(schema)) return "";
|
|
4340
4709
|
return stringifyExample(schema.example ?? schema.default ?? (Array.isArray(schema.enum) ? schema.enum[0] : void 0));
|
|
@@ -4349,9 +4718,12 @@ function OpenApiRequestWorkbench(arg0) {
|
|
|
4349
4718
|
const { spec, path, method, operation, operationSource = "path", compact = false, onClose } = arg0;
|
|
4350
4719
|
const t = require_i18n.useBuiltInText();
|
|
4351
4720
|
const parameters = getOperationParameters(spec, path, operation, operationSource);
|
|
4352
|
-
const { servers, selectedServer, selectedServerKey, serverVariables, setServerVariables, serverVariableEntries, selectServer, authOptions, selectedAuthName, setSelectedAuthName, selectedAuth, credentialScope, credentials, setCredential, clearCredential, requestContents, mediaType, body, setBody, selectMediaType } = useOpenApiRequestTarget(spec, path, operation, operationSource);
|
|
4353
|
-
const
|
|
4354
|
-
const
|
|
4721
|
+
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);
|
|
4722
|
+
const requestExamples = getRequestExampleEntries(parameters, selectedContent?.value);
|
|
4723
|
+
const [selectedRequestExampleKey, setSelectedRequestExampleKey] = (0, react.useState)(requestExamples[0]?.key ?? "");
|
|
4724
|
+
const currentRequestExampleKey = requestExamples.some((example) => example.key === selectedRequestExampleKey) ? selectedRequestExampleKey : requestExamples[0]?.key ?? "";
|
|
4725
|
+
const parameterState = useOpenApiParameterState(spec, parameters, (parameter) => initialParameterValue(spec, parameter), currentRequestExampleKey);
|
|
4726
|
+
const { parameterValues, parameterEnabled, parameterIssues, setParameterGroupValues, setParameterIncluded, updateParameterValue, applyParameterExample } = parameterState;
|
|
4355
4727
|
const { exchange, error, sending, execute } = useOpenApiRequestExecution();
|
|
4356
4728
|
const parameterGroups = [
|
|
4357
4729
|
"cookie",
|
|
@@ -4363,6 +4735,18 @@ function OpenApiRequestWorkbench(arg0) {
|
|
|
4363
4735
|
})).filter((group) => group.parameters.length > 0);
|
|
4364
4736
|
const pathParameters = parameters.filter((parameter) => parameter.in === "path");
|
|
4365
4737
|
const hasRequestConfiguration = authOptions.length > 0 || serverVariableEntries.length > 0 || parameters.length > 0 || requestContents.length > 0;
|
|
4738
|
+
function applyRequestExample(exampleKey) {
|
|
4739
|
+
setSelectedRequestExampleKey(exampleKey);
|
|
4740
|
+
applyParameterExample(exampleKey);
|
|
4741
|
+
applyBodyExample(exampleKey);
|
|
4742
|
+
}
|
|
4743
|
+
function selectRequestMediaType(value) {
|
|
4744
|
+
const content = requestContents.find((entry) => entry.mediaType === value)?.value;
|
|
4745
|
+
const nextExampleKey = getRequestExampleEntries(parameters, content)[0]?.key ?? "";
|
|
4746
|
+
selectMediaType(value);
|
|
4747
|
+
setSelectedRequestExampleKey(nextExampleKey);
|
|
4748
|
+
applyParameterExample(nextExampleKey);
|
|
4749
|
+
}
|
|
4366
4750
|
async function sendRequest() {
|
|
4367
4751
|
const enabledParameters = parameters.filter((parameter) => parameterEnabled[parameterKey(parameter)] !== false);
|
|
4368
4752
|
const issues = parameterState.validate(enabledParameters);
|
|
@@ -4381,6 +4765,7 @@ function OpenApiRequestWorkbench(arg0) {
|
|
|
4381
4765
|
})),
|
|
4382
4766
|
mediaType,
|
|
4383
4767
|
body,
|
|
4768
|
+
bodyFiles,
|
|
4384
4769
|
baseUrl: window.location.href
|
|
4385
4770
|
}), t("openapi.requestCorsHint"));
|
|
4386
4771
|
}
|
|
@@ -4431,44 +4816,84 @@ function OpenApiRequestWorkbench(arg0) {
|
|
|
4431
4816
|
}, location);
|
|
4432
4817
|
}
|
|
4433
4818
|
function renderHeader() {
|
|
4434
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
4435
|
-
className: "
|
|
4436
|
-
children:
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4819
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4820
|
+
className: "border-b border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface)",
|
|
4821
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4822
|
+
className: "grid min-w-0 grid-cols-[auto_auto_minmax(0,1fr)_auto_auto] items-center gap-1.5 px-2.5 py-2 lg:grid-cols-[auto_auto_minmax(0,1fr)_minmax(0,14rem)_auto_auto]",
|
|
4823
|
+
children: [
|
|
4824
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4825
|
+
className: "col-start-1 row-start-1",
|
|
4826
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EndpointMethodBadge, { method: method.toUpperCase() })
|
|
4827
|
+
}),
|
|
4828
|
+
servers.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
|
|
4829
|
+
label: t("openapi.server"),
|
|
4830
|
+
value: selectedServerKey,
|
|
4831
|
+
options: servers.map((server, index) => ({
|
|
4832
|
+
value: getServerKey(server, index),
|
|
4833
|
+
label: server.url ?? `Server ${index + 1}`,
|
|
4834
|
+
description: server.description
|
|
4835
|
+
})),
|
|
4836
|
+
onChange: selectServer,
|
|
4837
|
+
title: selectedServer.url ?? t("openapi.server"),
|
|
4838
|
+
buttonContent: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ServerIcon, {
|
|
4839
|
+
className: "size-4",
|
|
4840
|
+
"aria-hidden": "true"
|
|
4841
|
+
}),
|
|
4842
|
+
className: "col-start-2 row-start-1 size-8 shrink-0",
|
|
4843
|
+
buttonClassName: "grid size-8 place-items-center rounded-(--clarify-theme-tokens-radius-md) bg-(--clarify-ui-subtle-background) text-(--clarify-ui-text-soft) outline-hidden transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong) focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--clarify-theme-tokens-colors-primary) data-open:bg-(--clarify-ui-active-background)"
|
|
4844
|
+
}) : null,
|
|
4845
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
4846
|
+
className: "col-start-3 row-start-1 min-w-0 truncate border-l border-(--clarify-theme-tokens-colors-border) pl-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground)",
|
|
4847
|
+
title: path || "/",
|
|
4848
|
+
children: path || "/"
|
|
4849
|
+
}),
|
|
4850
|
+
requestExamples.length > 1 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
4851
|
+
className: "col-span-full row-start-2 flex min-w-0 items-center gap-0.5 border-t border-(--clarify-theme-tokens-colors-border) pt-2 lg:col-span-1 lg:col-start-4 lg:row-start-1 lg:border-t-0 lg:pt-0",
|
|
4852
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(InlineListbox, {
|
|
4853
|
+
label: t("openapi.requestExample"),
|
|
4854
|
+
value: currentRequestExampleKey,
|
|
4855
|
+
options: requestExamples.map((example) => ({
|
|
4856
|
+
value: example.key,
|
|
4857
|
+
label: example.title,
|
|
4858
|
+
description: example.summary
|
|
4859
|
+
})),
|
|
4860
|
+
onChange: applyRequestExample,
|
|
4861
|
+
className: "min-w-0 flex-1",
|
|
4862
|
+
buttonClassName: "flex h-8 w-full min-w-0 max-w-full items-center gap-1 rounded-(--clarify-theme-tokens-radius-md) px-2 text-xs font-medium text-(--clarify-ui-text-strong) outline-hidden transition hover:bg-(--clarify-ui-hover-background) focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-(--clarify-theme-tokens-colors-primary)"
|
|
4863
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4864
|
+
type: "button",
|
|
4865
|
+
title: t("openapi.resetToExample"),
|
|
4866
|
+
"aria-label": t("openapi.resetToExample"),
|
|
4867
|
+
onClick: () => applyRequestExample(currentRequestExampleKey),
|
|
4868
|
+
className: "grid size-8 shrink-0 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-faint) hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
4869
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.RotateCcwIcon, {
|
|
4870
|
+
className: "size-3.5",
|
|
4871
|
+
"aria-hidden": "true"
|
|
4872
|
+
})
|
|
4873
|
+
})]
|
|
4874
|
+
}) : null,
|
|
4875
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
4876
|
+
className: "col-start-4 row-start-1 lg:col-start-5",
|
|
4877
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SendRequestButton, {
|
|
4878
|
+
label: sending ? t("openapi.sendingRequest") : t("openapi.sendRequest"),
|
|
4879
|
+
busy: sending,
|
|
4880
|
+
text: t("openapi.sendRequest"),
|
|
4881
|
+
onClick: sendRequest
|
|
4882
|
+
})
|
|
4883
|
+
}),
|
|
4884
|
+
onClose ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
4885
|
+
type: "button",
|
|
4886
|
+
onClick: onClose,
|
|
4887
|
+
"aria-label": t("openapi.closeRequest"),
|
|
4888
|
+
title: t("openapi.closeRequest"),
|
|
4889
|
+
className: "col-start-5 row-start-1 grid size-8 shrink-0 place-items-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-soft) transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-theme-tokens-colors-foreground) focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary) lg:col-start-6",
|
|
4890
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.XIcon, {
|
|
4891
|
+
className: "size-4",
|
|
4892
|
+
"aria-hidden": "true"
|
|
4893
|
+
})
|
|
4894
|
+
}) : null
|
|
4895
|
+
]
|
|
4896
|
+
})
|
|
4472
4897
|
});
|
|
4473
4898
|
}
|
|
4474
4899
|
function renderVariables() {
|
|
@@ -4508,13 +4933,15 @@ function OpenApiRequestWorkbench(arg0) {
|
|
|
4508
4933
|
value: entry.mediaType,
|
|
4509
4934
|
label: entry.mediaType
|
|
4510
4935
|
})),
|
|
4511
|
-
onChange:
|
|
4512
|
-
}) }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4936
|
+
onChange: selectRequestMediaType
|
|
4937
|
+
}) }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(OpenApiRequestBodyEditor, {
|
|
4938
|
+
spec,
|
|
4939
|
+
mediaType,
|
|
4940
|
+
content: selectedContent?.value,
|
|
4941
|
+
body,
|
|
4942
|
+
files: bodyFiles,
|
|
4943
|
+
onBodyChange: setBody,
|
|
4944
|
+
onFileChange: setBodyFile
|
|
4518
4945
|
})]
|
|
4519
4946
|
});
|
|
4520
4947
|
}
|
|
@@ -4902,6 +5329,7 @@ function OpenApiOperation(arg0) {
|
|
|
4902
5329
|
onSelectRequestMediaType: requestState.setSelectedRequestMediaType,
|
|
4903
5330
|
selectedServer: serverState.selectedServer,
|
|
4904
5331
|
serverVariables: serverState.serverVariables,
|
|
5332
|
+
authOptions: authState.authOptions,
|
|
4905
5333
|
auth: authState.authInput,
|
|
4906
5334
|
sharedExampleKey: linkedExampleKey,
|
|
4907
5335
|
onSelectExampleKey: setLinkedExampleKey
|
|
@@ -5142,4 +5570,4 @@ Object.defineProperty(exports, "primitives_exports", {
|
|
|
5142
5570
|
}
|
|
5143
5571
|
});
|
|
5144
5572
|
|
|
5145
|
-
//# sourceMappingURL=OpenApiOperation-
|
|
5573
|
+
//# sourceMappingURL=OpenApiOperation-bdALspAY.cjs.map
|