@clarify-labs/renderer 0.11.17 → 0.11.18
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/{OpenApiOperation-DxJl8ziP.cjs → OpenApiOperation-XH6b7ntf.cjs} +81 -45
- package/output/OpenApiOperation-XH6b7ntf.cjs.map +1 -0
- package/output/{OpenApiOperation-kL4Fxi0g.js → OpenApiOperation-hxX828Il.js} +81 -45
- package/output/OpenApiOperation-hxX828Il.js.map +1 -0
- package/output/index.cjs +1 -1
- package/output/index.js +1 -1
- package/output/openapi/components/SchemaProperties.d.ts +1 -0
- package/output/openapi/lib/enum-options.d.ts +8 -0
- package/output/preview.cjs +1 -1
- package/output/preview.js +1 -1
- package/output/renderer.css +4 -0
- package/package.json +1 -1
- package/output/OpenApiOperation-DxJl8ziP.cjs.map +0 -1
- package/output/OpenApiOperation-kL4Fxi0g.js.map +0 -1
|
@@ -2908,16 +2908,41 @@ function OpenApiAuthDocumentation(props) {
|
|
|
2908
2908
|
});
|
|
2909
2909
|
}
|
|
2910
2910
|
//#endregion
|
|
2911
|
-
//#region source/openapi/
|
|
2912
|
-
function
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2911
|
+
//#region source/openapi/lib/enum-options.ts
|
|
2912
|
+
function enumValueKey(value) {
|
|
2913
|
+
return `${value === null ? "null" : typeof value}:${JSON.stringify(value)}`;
|
|
2914
|
+
}
|
|
2915
|
+
function enumMetadata(schema, keys, values) {
|
|
2916
|
+
const metadata = keys.map((key) => schema[key]).find((value) => Array.isArray(value) || isRecord$1(value));
|
|
2917
|
+
if (Array.isArray(metadata)) return values.map((_, index) => typeof metadata[index] === "string" ? metadata[index] : void 0);
|
|
2918
|
+
if (isRecord$1(metadata)) return values.map((value) => {
|
|
2919
|
+
const item = metadata[String(value)];
|
|
2920
|
+
return typeof item === "string" ? item : void 0;
|
|
2921
|
+
});
|
|
2922
|
+
return values.map(() => void 0);
|
|
2923
|
+
}
|
|
2924
|
+
function getEnumOptions(schema) {
|
|
2925
|
+
if (!isRecord$1(schema) || !Array.isArray(schema.enum)) return [];
|
|
2926
|
+
const values = schema.enum;
|
|
2927
|
+
const labels = enumMetadata(schema, [
|
|
2928
|
+
"x-enumLabels",
|
|
2929
|
+
"x-enumNames",
|
|
2930
|
+
"x-enum-varnames"
|
|
2931
|
+
], values);
|
|
2932
|
+
const descriptions = enumMetadata(schema, ["x-enumDescriptions"], values);
|
|
2933
|
+
return values.map((value, index) => {
|
|
2934
|
+
const valueText = String(value);
|
|
2935
|
+
return {
|
|
2936
|
+
key: enumValueKey(value),
|
|
2937
|
+
value,
|
|
2938
|
+
valueText,
|
|
2939
|
+
label: labels[index] ?? valueText,
|
|
2940
|
+
description: descriptions[index]
|
|
2941
|
+
};
|
|
2942
|
+
});
|
|
2920
2943
|
}
|
|
2944
|
+
//#endregion
|
|
2945
|
+
//#region source/openapi/components/SchemaProperties.tsx
|
|
2921
2946
|
function getSchemaDetails(schema) {
|
|
2922
2947
|
const details = [
|
|
2923
2948
|
typeof schema.const !== "undefined" ? `const: ${String(schema.const)}` : void 0,
|
|
@@ -2937,12 +2962,11 @@ function getSchemaNodeType(schema) {
|
|
|
2937
2962
|
}
|
|
2938
2963
|
function getEnumChildren(schema, path) {
|
|
2939
2964
|
if (!Array.isArray(schema.enum) || schema.enum.length === 0) return [];
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
name: String(value),
|
|
2965
|
+
return getEnumOptions(schema).map((option) => ({
|
|
2966
|
+
key: `${path || "root"}.enum.${option.key}`,
|
|
2967
|
+
name: option.valueText,
|
|
2944
2968
|
kind: "enum",
|
|
2945
|
-
description:
|
|
2969
|
+
description: option.description,
|
|
2946
2970
|
required: false,
|
|
2947
2971
|
children: []
|
|
2948
2972
|
}));
|
|
@@ -3103,6 +3127,9 @@ function getRootSchemaNode(spec, schema, defaultExpanded) {
|
|
|
3103
3127
|
})
|
|
3104
3128
|
};
|
|
3105
3129
|
}
|
|
3130
|
+
function shouldToggleSchemaRow(interactiveTarget, selectionInRow) {
|
|
3131
|
+
return !interactiveTarget && !selectionInRow;
|
|
3132
|
+
}
|
|
3106
3133
|
function EnumValueWithDescription(arg0) {
|
|
3107
3134
|
const { node } = arg0;
|
|
3108
3135
|
return /* @__PURE__ */ jsx("li", {
|
|
@@ -3161,8 +3188,8 @@ function SchemaNode(arg0) {
|
|
|
3161
3188
|
const type = [node.type, node.required ? t("openapi.requiredBadge") : void 0].filter(Boolean).join(", ") || void 0;
|
|
3162
3189
|
const fallbackDescription = hasChildren ? void 0 : node.required ? t("openapi.required") : t("openapi.optional");
|
|
3163
3190
|
const rowClassName = "flex w-full min-w-0 items-start rounded-(--clarify-theme-tokens-radius-md) px-2 py-2 text-left";
|
|
3164
|
-
const content = /* @__PURE__ */ jsxs(
|
|
3165
|
-
className: "min-w-0 flex-1",
|
|
3191
|
+
const content = /* @__PURE__ */ jsxs("div", {
|
|
3192
|
+
className: "min-w-0 flex-1 select-text",
|
|
3166
3193
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
3167
3194
|
className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5",
|
|
3168
3195
|
children: [/* @__PURE__ */ jsx("span", {
|
|
@@ -3182,20 +3209,25 @@ function SchemaNode(arg0) {
|
|
|
3182
3209
|
children: node.details
|
|
3183
3210
|
}) : null]
|
|
3184
3211
|
})]
|
|
3185
|
-
})
|
|
3186
|
-
className: "ml-2 flex h-5 w-5 flex-none items-center justify-center text-(--clarify-ui-text-faint)",
|
|
3187
|
-
"aria-hidden": "true",
|
|
3188
|
-
children: expanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })
|
|
3189
|
-
}) : null] });
|
|
3212
|
+
});
|
|
3190
3213
|
return /* @__PURE__ */ jsxs("li", {
|
|
3191
3214
|
className: clsx("clarify-schema-node m-0 p-0", node.visible === false && "hidden"),
|
|
3192
|
-
children: [hasChildren ? /* @__PURE__ */
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3215
|
+
children: [hasChildren ? /* @__PURE__ */ jsxs("div", {
|
|
3216
|
+
onClick: (event) => {
|
|
3217
|
+
const target = event.target instanceof Element ? event.target : void 0;
|
|
3218
|
+
const interactiveTarget = Boolean(target?.closest("button, a, input, select, textarea, [role=\"button\"]"));
|
|
3219
|
+
const selection = window.getSelection();
|
|
3220
|
+
if (shouldToggleSchemaRow(interactiveTarget, Boolean(selection && !selection.isCollapsed && selection.containsNode(event.currentTarget, true)))) setLocallyExpanded((value) => !value);
|
|
3221
|
+
},
|
|
3222
|
+
className: clsx(rowClassName, "cursor-pointer transition hover:bg-(--clarify-ui-hover-background)"),
|
|
3223
|
+
children: [content, /* @__PURE__ */ jsx("button", {
|
|
3224
|
+
type: "button",
|
|
3225
|
+
"aria-label": `${expanded ? t("openapi.collapse") : t("openapi.expand")}: ${node.name}`,
|
|
3226
|
+
"aria-expanded": expanded,
|
|
3227
|
+
onClick: () => setLocallyExpanded((value) => !value),
|
|
3228
|
+
className: "ml-2 flex h-5 w-5 flex-none cursor-pointer items-center justify-center rounded-(--clarify-theme-tokens-radius-md) text-(--clarify-ui-text-faint) outline-hidden transition hover:bg-(--clarify-ui-active-background) focus-visible:ring-2 focus-visible:ring-(--clarify-theme-tokens-colors-primary)",
|
|
3229
|
+
children: expanded ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })
|
|
3230
|
+
})]
|
|
3199
3231
|
}) : /* @__PURE__ */ jsx("div", {
|
|
3200
3232
|
className: rowClassName,
|
|
3201
3233
|
children: content
|
|
@@ -3977,6 +4009,8 @@ function isFormMediaType(mediaType) {
|
|
|
3977
4009
|
}
|
|
3978
4010
|
function valueFromInput(schema, value) {
|
|
3979
4011
|
if (!isRecord$1(schema)) return value;
|
|
4012
|
+
const enumOption = getEnumOptions(schema).find((option) => option.valueText === value);
|
|
4013
|
+
if (enumOption) return enumOption.value;
|
|
3980
4014
|
if (schemaHasType(schema, "integer")) return value === "" ? "" : Number.parseInt(value, 10);
|
|
3981
4015
|
if (schemaHasType(schema, "number")) return value === "" ? "" : Number(value);
|
|
3982
4016
|
if (schemaHasType(schema, "boolean")) return value === "true";
|
|
@@ -4006,7 +4040,7 @@ function OpenApiRequestBodyEditor(arg0) {
|
|
|
4006
4040
|
const type = schemaToType(propertySchema) ?? "string";
|
|
4007
4041
|
const value = values[name];
|
|
4008
4042
|
const fieldId = `openapi-request-body-${name}`.replace(/[^a-zA-Z0-9_-]/g, "-");
|
|
4009
|
-
const options =
|
|
4043
|
+
const options = getEnumOptions(propertySchema);
|
|
4010
4044
|
const structured = schemaHasType(propertySchema, "array") || schemaHasType(propertySchema, "object");
|
|
4011
4045
|
const serializedValue = structured && typeof value !== "undefined" ? JSON.stringify(value, null, 2) : String(value ?? "");
|
|
4012
4046
|
let control;
|
|
@@ -4026,9 +4060,9 @@ function OpenApiRequestBodyEditor(arg0) {
|
|
|
4026
4060
|
onChange: (event) => updateProperty(name, propertySchema, event.target.value),
|
|
4027
4061
|
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)",
|
|
4028
4062
|
children: [!required.has(name) ? /* @__PURE__ */ jsx("option", { value: "" }) : null, options.map((option) => /* @__PURE__ */ jsx("option", {
|
|
4029
|
-
value:
|
|
4030
|
-
children:
|
|
4031
|
-
},
|
|
4063
|
+
value: option.valueText,
|
|
4064
|
+
children: option.label
|
|
4065
|
+
}, option.key))]
|
|
4032
4066
|
});
|
|
4033
4067
|
else if (schemaHasType(propertySchema, "boolean")) control = /* @__PURE__ */ jsx("input", {
|
|
4034
4068
|
id: fieldId,
|
|
@@ -4114,8 +4148,16 @@ function RequestField(arg0) {
|
|
|
4114
4148
|
const schema = resolveSchema(spec, parameter.schema);
|
|
4115
4149
|
const schemaRecord = isRecord$1(schema) ? schema : void 0;
|
|
4116
4150
|
const itemSchema = isRecord$1(schemaRecord?.items) ? schemaRecord.items : void 0;
|
|
4117
|
-
const options =
|
|
4118
|
-
|
|
4151
|
+
const options = getEnumOptions(schema).map(({ valueText, label, description }) => ({
|
|
4152
|
+
value: valueText,
|
|
4153
|
+
label,
|
|
4154
|
+
description
|
|
4155
|
+
}));
|
|
4156
|
+
const itemOptions = getEnumOptions(itemSchema).map(({ valueText, label, description }) => ({
|
|
4157
|
+
value: valueText,
|
|
4158
|
+
label,
|
|
4159
|
+
description
|
|
4160
|
+
}));
|
|
4119
4161
|
const type = schemaToType(schema) ?? "string";
|
|
4120
4162
|
const description = parameter.description ?? (typeof schemaRecord?.description === "string" ? schemaRecord.description : void 0);
|
|
4121
4163
|
const structured = type.includes("[]") || type.includes("object");
|
|
@@ -4195,10 +4237,7 @@ function RequestField(arg0) {
|
|
|
4195
4237
|
children: itemOptions.length > 0 ? /* @__PURE__ */ jsx(MultiInlineListbox, {
|
|
4196
4238
|
label: parameter.name ?? "",
|
|
4197
4239
|
value: arrayValue,
|
|
4198
|
-
options: itemOptions
|
|
4199
|
-
value: option,
|
|
4200
|
-
label: option
|
|
4201
|
-
})),
|
|
4240
|
+
options: itemOptions,
|
|
4202
4241
|
onChange: (next) => onChange(JSON.stringify(next)),
|
|
4203
4242
|
invalid: Boolean(issue),
|
|
4204
4243
|
describedBy: issue ? `${fieldId}-issue` : void 0,
|
|
@@ -4209,10 +4248,7 @@ function RequestField(arg0) {
|
|
|
4209
4248
|
options: [...parameter.required ? [] : [{
|
|
4210
4249
|
value: "",
|
|
4211
4250
|
label: t("openapi.none")
|
|
4212
|
-
}], ...options
|
|
4213
|
-
value: option,
|
|
4214
|
-
label: option
|
|
4215
|
-
}))],
|
|
4251
|
+
}], ...options],
|
|
4216
4252
|
onChange,
|
|
4217
4253
|
invalid: Boolean(issue),
|
|
4218
4254
|
describedBy: issue ? `${fieldId}-issue` : void 0,
|
|
@@ -4846,7 +4882,7 @@ function validateRequestParameter(spec, parameter, value) {
|
|
|
4846
4882
|
const schema = resolveSchema(spec, parameter.schema);
|
|
4847
4883
|
const schemaRecord = isRecord$1(schema) ? schema : void 0;
|
|
4848
4884
|
const type = schemaToType(schema) ?? "string";
|
|
4849
|
-
const options =
|
|
4885
|
+
const options = getEnumOptions(schema).map(({ valueText }) => valueText);
|
|
4850
4886
|
if (options.length > 0 && !options.includes(value)) return "invalidEnum";
|
|
4851
4887
|
return structuredIssue(value, type) ?? scalarIssue(value, type, schemaRecord?.format);
|
|
4852
4888
|
}
|
|
@@ -5371,7 +5407,7 @@ function EndpointPath(arg0) {
|
|
|
5371
5407
|
className: "min-w-0 flex-1 overflow-x-auto text-sm font-bold leading-6 whitespace-nowrap",
|
|
5372
5408
|
children: /* @__PURE__ */ jsx("span", {
|
|
5373
5409
|
className: "select-text font-mono text-(--clarify-theme-tokens-colors-foreground)",
|
|
5374
|
-
children: path
|
|
5410
|
+
children: path ? path.startsWith("/") ? path : `/${path}` : "/"
|
|
5375
5411
|
})
|
|
5376
5412
|
}), onCopy ? /* @__PURE__ */ jsx("button", {
|
|
5377
5413
|
type: "button",
|
|
@@ -5694,4 +5730,4 @@ function OpenApiOperation(arg0) {
|
|
|
5694
5730
|
//#endregion
|
|
5695
5731
|
export { Heading as A, Callout as B, Tabs as C, GridPattern as D, Prose as E, CodeGroup as F, LocalizedLink as H, Pre as I, Mermaid as L, Feedback as M, Collapse as N, HeroPattern as O, Code as P, Card as R, TabItem as S, Steps as T, Button as V, Markdown as _, ResponseExamplesPanel as a, primitives_exports as b, getAuthOptions as c, EndpointMethodBadge as d, getOpenApiOperationEntryById as f, getRequestBody$1 as g, getMediaTypeEntries as h, RequestExamplesPanel as i, Tag as j, Logo as k, getServerKey as l, listOpenApiOperations as m, OpenApiOperation as n, authPlaceholder as o, getOpenApiOperationSectionId as p, OpenApiRequestWorkbench as r, defaultServerVariables as s, EndpointIdentity as t, getServers as u, Release as v, Step as w, WebFrame as x, ReleaseItem as y, CardGroup as z };
|
|
5696
5732
|
|
|
5697
|
-
//# sourceMappingURL=OpenApiOperation-
|
|
5733
|
+
//# sourceMappingURL=OpenApiOperation-hxX828Il.js.map
|