@alepha/ui 0.35.0 → 0.36.1
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/README.md +54 -1
- package/dist/account/AccountBrand.d.ts +10 -3
- package/dist/account/AccountBrand.d.ts.map +1 -1
- package/dist/account/AccountBrand.js +12 -6
- package/dist/account/AccountBrand.js.map +1 -1
- package/dist/account/AccountLayout.d.ts.map +1 -1
- package/dist/account/AccountLayout.js +1 -1
- package/dist/account/AccountLayout.js.map +1 -1
- package/dist/admin/AdminUserDetail.d.ts +3 -3
- package/dist/admin/AdminUserDetail.js +3 -3
- package/dist/admin/AdminUserDetail.js.map +1 -1
- package/dist/ai/AiChat.d.ts +36 -6
- package/dist/ai/AiChat.d.ts.map +1 -1
- package/dist/ai/AiChat.js +101 -63
- package/dist/ai/AiChat.js.map +1 -1
- package/dist/ai/AiChatComposer.d.ts +22 -0
- package/dist/ai/AiChatComposer.d.ts.map +1 -0
- package/dist/ai/AiChatComposer.js +75 -0
- package/dist/ai/AiChatComposer.js.map +1 -0
- package/dist/ai/AiChatConfirmCard.d.ts +5 -2
- package/dist/ai/AiChatConfirmCard.d.ts.map +1 -1
- package/dist/ai/AiChatConfirmCard.js +7 -6
- package/dist/ai/AiChatConfirmCard.js.map +1 -1
- package/dist/ai/AiChatConfirmFields.d.ts +9 -0
- package/dist/ai/AiChatConfirmFields.d.ts.map +1 -0
- package/dist/ai/AiChatConfirmFields.js +45 -0
- package/dist/ai/AiChatConfirmFields.js.map +1 -0
- package/dist/ai/AiChatEmpty.d.ts +26 -0
- package/dist/ai/AiChatEmpty.d.ts.map +1 -0
- package/dist/ai/AiChatEmpty.js +47 -0
- package/dist/ai/AiChatEmpty.js.map +1 -0
- package/dist/ai/AiChatHistory.d.ts +3 -2
- package/dist/ai/AiChatHistory.d.ts.map +1 -1
- package/dist/ai/AiChatHistory.js +51 -22
- package/dist/ai/AiChatHistory.js.map +1 -1
- package/dist/ai/AiChatMessage.d.ts +14 -0
- package/dist/ai/AiChatMessage.d.ts.map +1 -1
- package/dist/ai/AiChatMessage.js +24 -12
- package/dist/ai/AiChatMessage.js.map +1 -1
- package/dist/ai/index.d.ts +3 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +4 -1
- package/dist/ai/useAiChat.d.ts +9 -0
- package/dist/ai/useAiChat.d.ts.map +1 -1
- package/dist/ai/useAiChat.js +21 -3
- package/dist/ai/useAiChat.js.map +1 -1
- package/dist/core/Sidebar.js +2 -2
- package/dist/core/Sidebar.js.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -1
- package/dist/core/useToast.d.ts +22 -1
- package/dist/core/useToast.d.ts.map +1 -1
- package/dist/core/useToast.js +4 -1
- package/dist/core/useToast.js.map +1 -1
- package/dist/core/useUndoable.d.ts +93 -0
- package/dist/core/useUndoable.d.ts.map +1 -0
- package/dist/core/useUndoable.js +172 -0
- package/dist/core/useUndoable.js.map +1 -0
- package/dist/i18n/fr/uiFr.d.ts.map +1 -1
- package/dist/i18n/fr/uiFr.js +51 -1
- package/dist/i18n/fr/uiFr.js.map +1 -1
- package/dist/markdown/MarkdownView.d.ts +15 -0
- package/dist/markdown/MarkdownView.d.ts.map +1 -1
- package/dist/markdown/MarkdownView.js +4 -1
- package/dist/markdown/MarkdownView.js.map +1 -1
- package/dist/organizations/useInviteOrganizationMember.d.ts +2 -2
- package/dist/organizations/useInviteOrganizationMember.js.map +1 -1
- package/dist/shell/AppShellSidebarNavItem.d.ts.map +1 -1
- package/dist/shell/AppShellSidebarNavItem.js +25 -2
- package/dist/shell/AppShellSidebarNavItem.js.map +1 -1
- package/dist/shell/PlateTabBar.d.ts.map +1 -1
- package/dist/shell/PlateTabBar.js +2 -2
- package/dist/shell/PlateTabBar.js.map +1 -1
- package/dist/shell/SidebarBackHeader.d.ts +35 -0
- package/dist/shell/SidebarBackHeader.d.ts.map +1 -0
- package/dist/shell/SidebarBackHeader.js +34 -0
- package/dist/shell/SidebarBackHeader.js.map +1 -0
- package/dist/shell/appShellNav.d.ts +30 -0
- package/dist/shell/appShellNav.d.ts.map +1 -1
- package/dist/shell/appShellNav.js.map +1 -1
- package/dist/shell/index.d.ts +2 -1
- package/dist/shell/index.d.ts.map +1 -1
- package/dist/shell/index.js +2 -1
- package/dist/swagger/$uiSwagger.d.ts +75 -0
- package/dist/swagger/$uiSwagger.d.ts.map +1 -0
- package/dist/swagger/$uiSwagger.js +51 -0
- package/dist/swagger/$uiSwagger.js.map +1 -0
- package/dist/swagger/OpenApiSpec.d.ts +113 -0
- package/dist/swagger/OpenApiSpec.d.ts.map +1 -0
- package/dist/swagger/OpenApiSpec.js +186 -0
- package/dist/swagger/OpenApiSpec.js.map +1 -0
- package/dist/swagger/SwaggerAccessBadge.d.ts +16 -0
- package/dist/swagger/SwaggerAccessBadge.d.ts.map +1 -0
- package/dist/swagger/SwaggerAccessBadge.js +40 -0
- package/dist/swagger/SwaggerAccessBadge.js.map +1 -0
- package/dist/swagger/SwaggerAlephaMeta.d.ts +11 -0
- package/dist/swagger/SwaggerAlephaMeta.d.ts.map +1 -0
- package/dist/swagger/SwaggerAlephaMeta.js +103 -0
- package/dist/swagger/SwaggerAlephaMeta.js.map +1 -0
- package/dist/swagger/SwaggerCredentials.d.ts +11 -0
- package/dist/swagger/SwaggerCredentials.d.ts.map +1 -0
- package/dist/swagger/SwaggerCredentials.js +35 -0
- package/dist/swagger/SwaggerCredentials.js.map +1 -0
- package/dist/swagger/SwaggerExplorer.d.ts +31 -0
- package/dist/swagger/SwaggerExplorer.d.ts.map +1 -0
- package/dist/swagger/SwaggerExplorer.js +156 -0
- package/dist/swagger/SwaggerExplorer.js.map +1 -0
- package/dist/swagger/SwaggerMethodBadge.d.ts +10 -0
- package/dist/swagger/SwaggerMethodBadge.d.ts.map +1 -0
- package/dist/swagger/SwaggerMethodBadge.js +27 -0
- package/dist/swagger/SwaggerMethodBadge.js.map +1 -0
- package/dist/swagger/SwaggerNav.d.ts +16 -0
- package/dist/swagger/SwaggerNav.d.ts.map +1 -0
- package/dist/swagger/SwaggerNav.js +63 -0
- package/dist/swagger/SwaggerNav.js.map +1 -0
- package/dist/swagger/SwaggerOperationView.d.ts +22 -0
- package/dist/swagger/SwaggerOperationView.d.ts.map +1 -0
- package/dist/swagger/SwaggerOperationView.js +89 -0
- package/dist/swagger/SwaggerOperationView.js.map +1 -0
- package/dist/swagger/SwaggerParameters.d.ts +11 -0
- package/dist/swagger/SwaggerParameters.d.ts.map +1 -0
- package/dist/swagger/SwaggerParameters.js +80 -0
- package/dist/swagger/SwaggerParameters.js.map +1 -0
- package/dist/swagger/SwaggerRequestBuilder.d.ts +83 -0
- package/dist/swagger/SwaggerRequestBuilder.d.ts.map +1 -0
- package/dist/swagger/SwaggerRequestBuilder.js +231 -0
- package/dist/swagger/SwaggerRequestBuilder.js.map +1 -0
- package/dist/swagger/SwaggerResponseView.d.ts +25 -0
- package/dist/swagger/SwaggerResponseView.d.ts.map +1 -0
- package/dist/swagger/SwaggerResponseView.js +94 -0
- package/dist/swagger/SwaggerResponseView.js.map +1 -0
- package/dist/swagger/SwaggerResponses.d.ts +12 -0
- package/dist/swagger/SwaggerResponses.d.ts.map +1 -0
- package/dist/swagger/SwaggerResponses.js +75 -0
- package/dist/swagger/SwaggerResponses.js.map +1 -0
- package/dist/swagger/SwaggerSchemaView.d.ts +19 -0
- package/dist/swagger/SwaggerSchemaView.d.ts.map +1 -0
- package/dist/swagger/SwaggerSchemaView.js +98 -0
- package/dist/swagger/SwaggerSchemaView.js.map +1 -0
- package/dist/swagger/SwaggerSection.d.ts +14 -0
- package/dist/swagger/SwaggerSection.d.ts.map +1 -0
- package/dist/swagger/SwaggerSection.js +23 -0
- package/dist/swagger/SwaggerSection.js.map +1 -0
- package/dist/swagger/SwaggerTryIt.d.ts +31 -0
- package/dist/swagger/SwaggerTryIt.d.ts.map +1 -0
- package/dist/swagger/SwaggerTryIt.js +68 -0
- package/dist/swagger/SwaggerTryIt.js.map +1 -0
- package/dist/swagger/SwaggerTryItForm.d.ts +20 -0
- package/dist/swagger/SwaggerTryItForm.d.ts.map +1 -0
- package/dist/swagger/SwaggerTryItForm.js +52 -0
- package/dist/swagger/SwaggerTryItForm.js.map +1 -0
- package/dist/swagger/index.d.ts +29 -0
- package/dist/swagger/index.d.ts.map +1 -0
- package/dist/swagger/index.js +18 -0
- package/dist/swagger/useSwaggerAccess.d.ts +24 -0
- package/dist/swagger/useSwaggerAccess.d.ts.map +1 -0
- package/dist/swagger/useSwaggerAccess.js +33 -0
- package/dist/swagger/useSwaggerAccess.js.map +1 -0
- package/dist/table/DataTable.d.ts.map +1 -1
- package/dist/table/DataTable.js +50 -13
- package/dist/table/DataTable.js.map +1 -1
- package/dist/table/DataTableBody.d.ts +18 -1
- package/dist/table/DataTableBody.d.ts.map +1 -1
- package/dist/table/DataTableBody.js +83 -58
- package/dist/table/DataTableBody.js.map +1 -1
- package/dist/table/DataTableRowActionsInline.d.ts +17 -0
- package/dist/table/DataTableRowActionsInline.d.ts.map +1 -0
- package/dist/table/DataTableRowActionsInline.js +45 -0
- package/dist/table/DataTableRowActionsInline.js.map +1 -0
- package/dist/table/PermissionMatrix.d.ts +4 -4
- package/dist/table/PermissionMatrix.js +2 -2
- package/dist/table/PermissionMatrix.js.map +1 -1
- package/dist/table/dataTableBaseProps.d.ts +31 -0
- package/dist/table/dataTableBaseProps.d.ts.map +1 -1
- package/dist/table/dataTableTypes.d.ts +16 -2
- package/dist/table/dataTableTypes.d.ts.map +1 -1
- package/dist/table/useDataTableData.d.ts +3 -0
- package/dist/table/useDataTableData.d.ts.map +1 -1
- package/dist/table/useDataTableData.js +9 -2
- package/dist/table/useDataTableData.js.map +1 -1
- package/dist/table/useDataTableRefresh.d.ts +1 -0
- package/dist/table/useDataTableRefresh.d.ts.map +1 -1
- package/dist/table/useDataTableRefresh.js +13 -1
- package/dist/table/useDataTableRefresh.js.map +1 -1
- package/dist/table/useOptimisticRows.d.ts +64 -0
- package/dist/table/useOptimisticRows.d.ts.map +1 -0
- package/dist/table/useOptimisticRows.js +185 -0
- package/dist/table/useOptimisticRows.js.map +1 -0
- package/dist/table/useRowMotion.d.ts +27 -0
- package/dist/table/useRowMotion.d.ts.map +1 -0
- package/dist/table/useRowMotion.js +112 -0
- package/dist/table/useRowMotion.js.map +1 -0
- package/docs/packages-alepha-ui-core.md +1 -0
- package/docs/packages-alepha-ui-overview.md +53 -1
- package/docs/packages-alepha-ui-swagger.md +35 -0
- package/package.json +11 -3
- package/src/account/AccountBrand.tsx +25 -6
- package/src/account/AccountLayout.tsx +5 -1
- package/src/admin/AdminUserDetail.tsx +3 -3
- package/src/admin/__tests__/AdminUserDetail.spec.ts +2 -2
- package/src/ai/AiChat.tsx +160 -82
- package/src/ai/AiChatComposer.tsx +117 -0
- package/src/ai/AiChatConfirmCard.tsx +7 -5
- package/src/ai/AiChatConfirmFields.tsx +65 -0
- package/src/ai/AiChatEmpty.tsx +73 -0
- package/src/ai/AiChatHistory.tsx +64 -28
- package/src/ai/AiChatMessage.tsx +47 -15
- package/src/ai/__tests__/AiChat.browser.spec.tsx +156 -5
- package/src/ai/index.ts +3 -0
- package/src/ai/useAiChat.ts +35 -0
- package/src/core/Sidebar.tsx +2 -2
- package/src/core/__tests__/useUndoable.browser.spec.tsx +201 -0
- package/src/core/index.ts +7 -0
- package/src/core/useToast.tsx +30 -2
- package/src/core/useUndoable.tsx +285 -0
- package/src/form/__tests__/ControlChoices.browser.spec.tsx +2 -1
- package/src/i18n/fr/uiFr.ts +53 -0
- package/src/markdown/MarkdownView.tsx +27 -9
- package/src/organizations/useInviteOrganizationMember.ts +2 -2
- package/src/shell/AppShellSidebarNavItem.tsx +51 -1
- package/src/shell/PlateTabBar.tsx +8 -2
- package/src/shell/SidebarBackHeader.tsx +58 -0
- package/src/shell/appShellNav.tsx +31 -0
- package/src/shell/index.ts +5 -1
- package/src/swagger/$uiSwagger.tsx +95 -0
- package/src/swagger/OpenApiSpec.ts +300 -0
- package/src/swagger/SwaggerAccessBadge.tsx +64 -0
- package/src/swagger/SwaggerAlephaMeta.tsx +141 -0
- package/src/swagger/SwaggerCredentials.tsx +44 -0
- package/src/swagger/SwaggerExplorer.tsx +208 -0
- package/src/swagger/SwaggerMethodBadge.tsx +32 -0
- package/src/swagger/SwaggerNav.tsx +92 -0
- package/src/swagger/SwaggerOperationView.tsx +102 -0
- package/src/swagger/SwaggerParameters.tsx +74 -0
- package/src/swagger/SwaggerRequestBuilder.ts +331 -0
- package/src/swagger/SwaggerResponseView.tsx +107 -0
- package/src/swagger/SwaggerResponses.tsx +83 -0
- package/src/swagger/SwaggerSchemaView.tsx +134 -0
- package/src/swagger/SwaggerSection.tsx +29 -0
- package/src/swagger/SwaggerTryIt.tsx +95 -0
- package/src/swagger/SwaggerTryItForm.tsx +87 -0
- package/src/swagger/__tests__/$uiSwagger.spec.ts +52 -0
- package/src/swagger/__tests__/OpenApiSpec.spec.ts +139 -0
- package/src/swagger/__tests__/SwaggerAccess.browser.spec.tsx +124 -0
- package/src/swagger/__tests__/SwaggerOperationView.browser.spec.tsx +194 -0
- package/src/swagger/__tests__/SwaggerRequestBuilder.spec.ts +250 -0
- package/src/swagger/index.ts +75 -0
- package/src/swagger/useSwaggerAccess.ts +59 -0
- package/src/table/DataTable.tsx +85 -34
- package/src/table/DataTableBody.tsx +51 -7
- package/src/table/DataTableRowActionsInline.tsx +80 -0
- package/src/table/PermissionMatrix.tsx +4 -4
- package/src/table/__tests__/DataTableEmptyState.browser.spec.tsx +1 -1
- package/src/table/__tests__/DataTableListMode.browser.spec.tsx +174 -0
- package/src/table/__tests__/DataTableOptimistic.browser.spec.tsx +173 -0
- package/src/table/__tests__/PermissionMatrix.browser.spec.tsx +2 -2
- package/src/table/__tests__/queryFilters.spec.ts +10 -12
- package/src/table/dataTableBaseProps.ts +31 -0
- package/src/table/dataTableTypes.ts +16 -2
- package/src/table/useDataTableData.ts +18 -2
- package/src/table/useDataTableRefresh.ts +26 -2
- package/src/table/useOptimisticRows.ts +265 -0
- package/src/table/useRowMotion.ts +152 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Badge } from "../core/Badge.js";
|
|
2
|
+
import { SwaggerAlephaMeta } from "./SwaggerAlephaMeta.js";
|
|
3
|
+
import { SwaggerMethodBadge } from "./SwaggerMethodBadge.js";
|
|
4
|
+
import { SwaggerParameters } from "./SwaggerParameters.js";
|
|
5
|
+
import { SwaggerResponses } from "./SwaggerResponses.js";
|
|
6
|
+
import { SwaggerSchemaView } from "./SwaggerSchemaView.js";
|
|
7
|
+
import { SwaggerSection } from "./SwaggerSection.js";
|
|
8
|
+
import { useI18n } from "alepha/react/i18n";
|
|
9
|
+
import { Lock } from "lucide-react";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
// src/swagger/SwaggerOperationView.tsx
|
|
12
|
+
/**
|
|
13
|
+
* One operation in full: method and path, summary and description, what
|
|
14
|
+
* Alepha declared about it, then its parameters, request body and responses.
|
|
15
|
+
*/
|
|
16
|
+
const SwaggerOperationView = (props) => {
|
|
17
|
+
const { tr } = useI18n();
|
|
18
|
+
const { spec, entry } = props;
|
|
19
|
+
const operation = entry.operation;
|
|
20
|
+
const body = Object.entries(operation.requestBody?.content ?? {});
|
|
21
|
+
return /* @__PURE__ */ jsxs("article", {
|
|
22
|
+
className: "flex flex-col gap-6",
|
|
23
|
+
children: [
|
|
24
|
+
/* @__PURE__ */ jsxs("header", {
|
|
25
|
+
className: "flex flex-col gap-2",
|
|
26
|
+
children: [
|
|
27
|
+
/* @__PURE__ */ jsxs("div", {
|
|
28
|
+
className: "flex flex-wrap items-center gap-2",
|
|
29
|
+
children: [
|
|
30
|
+
/* @__PURE__ */ jsx(SwaggerMethodBadge, { method: entry.method }),
|
|
31
|
+
/* @__PURE__ */ jsx("code", {
|
|
32
|
+
className: "font-mono text-sm break-all",
|
|
33
|
+
children: entry.path
|
|
34
|
+
}),
|
|
35
|
+
spec.isSecured(operation) && /* @__PURE__ */ jsx(Lock, {
|
|
36
|
+
className: "text-muted-foreground size-3.5",
|
|
37
|
+
"aria-label": tr("swagger.secured", { default: "Requires sign-in" })
|
|
38
|
+
}),
|
|
39
|
+
props.badge,
|
|
40
|
+
operation.deprecated && /* @__PURE__ */ jsx(Badge, {
|
|
41
|
+
variant: "tint",
|
|
42
|
+
tone: "warning",
|
|
43
|
+
children: tr("swagger.deprecated", { default: "deprecated" })
|
|
44
|
+
})
|
|
45
|
+
]
|
|
46
|
+
}),
|
|
47
|
+
operation.summary && /* @__PURE__ */ jsx("h2", {
|
|
48
|
+
className: "text-lg font-semibold",
|
|
49
|
+
children: operation.summary
|
|
50
|
+
}),
|
|
51
|
+
operation.description && /* @__PURE__ */ jsx("p", {
|
|
52
|
+
className: "text-muted-foreground text-sm whitespace-pre-line",
|
|
53
|
+
children: operation.description
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
}),
|
|
57
|
+
/* @__PURE__ */ jsx(SwaggerAlephaMeta, { metadata: spec.metadata(operation) }),
|
|
58
|
+
props.children,
|
|
59
|
+
operation.parameters?.length ? /* @__PURE__ */ jsx(SwaggerSection, {
|
|
60
|
+
title: tr("swagger.section.parameters", { default: "Parameters" }),
|
|
61
|
+
children: /* @__PURE__ */ jsx(SwaggerParameters, {
|
|
62
|
+
spec,
|
|
63
|
+
parameters: operation.parameters
|
|
64
|
+
})
|
|
65
|
+
}) : null,
|
|
66
|
+
body.length ? /* @__PURE__ */ jsx(SwaggerSection, {
|
|
67
|
+
title: tr("swagger.section.body", { default: "Request body" }),
|
|
68
|
+
aside: body.map(([type]) => type).join(", "),
|
|
69
|
+
children: body.map(([type, media]) => /* @__PURE__ */ jsx("div", {
|
|
70
|
+
className: "rounded-lg border p-3",
|
|
71
|
+
children: /* @__PURE__ */ jsx(SwaggerSchemaView, {
|
|
72
|
+
spec,
|
|
73
|
+
schema: media.schema
|
|
74
|
+
})
|
|
75
|
+
}, type))
|
|
76
|
+
}) : null,
|
|
77
|
+
/* @__PURE__ */ jsx(SwaggerSection, {
|
|
78
|
+
title: tr("swagger.section.responses", { default: "Responses" }),
|
|
79
|
+
children: /* @__PURE__ */ jsx(SwaggerResponses, {
|
|
80
|
+
spec,
|
|
81
|
+
responses: operation.responses
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
]
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
export { SwaggerOperationView };
|
|
88
|
+
|
|
89
|
+
//# sourceMappingURL=SwaggerOperationView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwaggerOperationView.js","names":[],"sources":["../../src/swagger/SwaggerOperationView.tsx"],"sourcesContent":["import { useI18n } from \"alepha/react/i18n\";\nimport { Lock } from \"lucide-react\";\nimport type { ReactNode } from \"react\";\n\nimport { Badge } from \"../core/Badge.tsx\";\nimport type { OpenApiSpec, SwaggerEntry } from \"./OpenApiSpec.ts\";\nimport { SwaggerAlephaMeta } from \"./SwaggerAlephaMeta.tsx\";\nimport { SwaggerMethodBadge } from \"./SwaggerMethodBadge.tsx\";\nimport { SwaggerParameters } from \"./SwaggerParameters.tsx\";\nimport { SwaggerResponses } from \"./SwaggerResponses.tsx\";\nimport { SwaggerSchemaView } from \"./SwaggerSchemaView.tsx\";\nimport { SwaggerSection } from \"./SwaggerSection.tsx\";\n\nexport interface SwaggerOperationViewProps {\n spec: OpenApiSpec;\n entry: SwaggerEntry;\n /**\n * Shown at the end of the header line: where the explorer says whether the\n * viewer may call the operation.\n */\n badge?: ReactNode;\n /**\n * Rendered under the header, before the reference sections: where the\n * explorer puts its request panel.\n */\n children?: ReactNode;\n}\n\n/**\n * One operation in full: method and path, summary and description, what\n * Alepha declared about it, then its parameters, request body and responses.\n */\nexport const SwaggerOperationView = (props: SwaggerOperationViewProps) => {\n const { tr } = useI18n();\n const { spec, entry } = props;\n const operation = entry.operation;\n const body = Object.entries(operation.requestBody?.content ?? {});\n\n return (\n <article className=\"flex flex-col gap-6\">\n <header className=\"flex flex-col gap-2\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <SwaggerMethodBadge method={entry.method} />\n <code className=\"font-mono text-sm break-all\">{entry.path}</code>\n {spec.isSecured(operation) && (\n <Lock\n className=\"text-muted-foreground size-3.5\"\n aria-label={tr(\"swagger.secured\", {\n default: \"Requires sign-in\",\n })}\n />\n )}\n {props.badge}\n {operation.deprecated && (\n <Badge variant=\"tint\" tone=\"warning\">\n {tr(\"swagger.deprecated\", { default: \"deprecated\" })}\n </Badge>\n )}\n </div>\n {operation.summary && (\n <h2 className=\"text-lg font-semibold\">{operation.summary}</h2>\n )}\n {operation.description && (\n <p className=\"text-muted-foreground text-sm whitespace-pre-line\">\n {operation.description}\n </p>\n )}\n </header>\n\n <SwaggerAlephaMeta metadata={spec.metadata(operation)} />\n\n {props.children}\n\n {operation.parameters?.length ? (\n <SwaggerSection\n title={tr(\"swagger.section.parameters\", { default: \"Parameters\" })}\n >\n <SwaggerParameters spec={spec} parameters={operation.parameters} />\n </SwaggerSection>\n ) : null}\n\n {body.length ? (\n <SwaggerSection\n title={tr(\"swagger.section.body\", { default: \"Request body\" })}\n aside={body.map(([type]) => type).join(\", \")}\n >\n {body.map(([type, media]) => (\n <div key={type} className=\"rounded-lg border p-3\">\n <SwaggerSchemaView spec={spec} schema={media.schema} />\n </div>\n ))}\n </SwaggerSection>\n ) : null}\n\n <SwaggerSection\n title={tr(\"swagger.section.responses\", { default: \"Responses\" })}\n >\n <SwaggerResponses spec={spec} responses={operation.responses} />\n </SwaggerSection>\n </article>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AAgCA,MAAa,wBAAwB,UAAqC;CACxE,MAAM,EAAE,OAAO,QAAQ;CACvB,MAAM,EAAE,MAAM,UAAU;CACxB,MAAM,YAAY,MAAM;CACxB,MAAM,OAAO,OAAO,QAAQ,UAAU,aAAa,WAAW,CAAC,CAAC;CAEhE,OACE,qBAAC,WAAD;EAAS,WAAU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6B,EAAE,SAAS,YAAY,CAAC;IAE/D,UAAA,oBAAC,kBAAD;KAAwB;KAAM,WAAW,UAAU;IAAY,CAAA;GACjD,CAAA;EACT;;AAEb"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { OpenApiOperation } from "alepha/server/swagger";
|
|
2
|
+
import type { OpenApiSpec } from "./OpenApiSpec.ts";
|
|
3
|
+
export interface SwaggerParametersProps {
|
|
4
|
+
spec: OpenApiSpec;
|
|
5
|
+
parameters: NonNullable<OpenApiOperation["parameters"]>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The path, query and header parameters of an operation, one row each.
|
|
9
|
+
*/
|
|
10
|
+
export declare const SwaggerParameters: (props: SwaggerParametersProps) => import("react").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=SwaggerParameters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwaggerParameters.d.ts","sourceRoot":"","sources":["../../src/swagger/SwaggerParameters.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,WAAW,CAAC;IAClB,UAAU,EAAE,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC;CACzD;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,UAAW,sBAAsB,gCA4D9D,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { useI18n } from "alepha/react/i18n";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
// src/swagger/SwaggerParameters.tsx
|
|
4
|
+
/**
|
|
5
|
+
* The path, query and header parameters of an operation, one row each.
|
|
6
|
+
*/
|
|
7
|
+
const SwaggerParameters = (props) => {
|
|
8
|
+
const { tr } = useI18n();
|
|
9
|
+
return /* @__PURE__ */ jsx("div", {
|
|
10
|
+
className: "overflow-x-auto rounded-lg border",
|
|
11
|
+
children: /* @__PURE__ */ jsxs("table", {
|
|
12
|
+
className: "w-full text-sm",
|
|
13
|
+
children: [/* @__PURE__ */ jsx("thead", {
|
|
14
|
+
className: "text-muted-foreground bg-muted/40 text-left text-xs",
|
|
15
|
+
children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
16
|
+
/* @__PURE__ */ jsx("th", {
|
|
17
|
+
className: "px-3 py-2 font-medium",
|
|
18
|
+
children: tr("swagger.parameters.name", { default: "Name" })
|
|
19
|
+
}),
|
|
20
|
+
/* @__PURE__ */ jsx("th", {
|
|
21
|
+
className: "px-3 py-2 font-medium",
|
|
22
|
+
children: tr("swagger.parameters.in", { default: "In" })
|
|
23
|
+
}),
|
|
24
|
+
/* @__PURE__ */ jsx("th", {
|
|
25
|
+
className: "px-3 py-2 font-medium",
|
|
26
|
+
children: tr("swagger.parameters.type", { default: "Type" })
|
|
27
|
+
}),
|
|
28
|
+
/* @__PURE__ */ jsx("th", {
|
|
29
|
+
className: "px-3 py-2 font-medium",
|
|
30
|
+
children: tr("swagger.parameters.description", { default: "Description" })
|
|
31
|
+
})
|
|
32
|
+
] })
|
|
33
|
+
}), /* @__PURE__ */ jsx("tbody", { children: props.parameters.map((param) => {
|
|
34
|
+
const resolved = props.spec.resolve(param.schema);
|
|
35
|
+
const example = param.example;
|
|
36
|
+
return /* @__PURE__ */ jsxs("tr", {
|
|
37
|
+
className: "border-t",
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ jsxs("td", {
|
|
40
|
+
className: "px-3 py-2 align-top",
|
|
41
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
42
|
+
className: "font-mono",
|
|
43
|
+
children: param.name
|
|
44
|
+
}), param.required && /* @__PURE__ */ jsx("span", {
|
|
45
|
+
className: "text-danger-text ml-1",
|
|
46
|
+
"aria-hidden": true,
|
|
47
|
+
children: "*"
|
|
48
|
+
})]
|
|
49
|
+
}),
|
|
50
|
+
/* @__PURE__ */ jsx("td", {
|
|
51
|
+
className: "text-muted-foreground px-3 py-2 align-top text-xs",
|
|
52
|
+
children: param.in
|
|
53
|
+
}),
|
|
54
|
+
/* @__PURE__ */ jsx("td", {
|
|
55
|
+
className: "text-muted-foreground px-3 py-2 align-top font-mono text-xs break-all",
|
|
56
|
+
children: props.spec.typeLabel(param.schema)
|
|
57
|
+
}),
|
|
58
|
+
/* @__PURE__ */ jsxs("td", {
|
|
59
|
+
className: "px-3 py-2 align-top text-xs",
|
|
60
|
+
children: [param.description ?? resolved?.description, example !== void 0 && /* @__PURE__ */ jsxs("div", {
|
|
61
|
+
className: "text-muted-foreground mt-0.5",
|
|
62
|
+
children: [
|
|
63
|
+
tr("swagger.parameters.example", { default: "Example" }),
|
|
64
|
+
": ",
|
|
65
|
+
/* @__PURE__ */ jsx("code", {
|
|
66
|
+
className: "font-mono",
|
|
67
|
+
children: JSON.stringify(example)
|
|
68
|
+
})
|
|
69
|
+
]
|
|
70
|
+
})]
|
|
71
|
+
})
|
|
72
|
+
]
|
|
73
|
+
}, `${param.in}:${param.name}`);
|
|
74
|
+
}) })]
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
export { SwaggerParameters };
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=SwaggerParameters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwaggerParameters.js","names":[],"sources":["../../src/swagger/SwaggerParameters.tsx"],"sourcesContent":["import { useI18n } from \"alepha/react/i18n\";\nimport type { OpenApiOperation } from \"alepha/server/swagger\";\n\nimport type { OpenApiSpec } from \"./OpenApiSpec.ts\";\n\nexport interface SwaggerParametersProps {\n spec: OpenApiSpec;\n parameters: NonNullable<OpenApiOperation[\"parameters\"]>;\n}\n\n/**\n * The path, query and header parameters of an operation, one row each.\n */\nexport const SwaggerParameters = (props: SwaggerParametersProps) => {\n const { tr } = useI18n();\n return (\n <div className=\"overflow-x-auto rounded-lg border\">\n <table className=\"w-full text-sm\">\n <thead className=\"text-muted-foreground bg-muted/40 text-left text-xs\">\n <tr>\n <th className=\"px-3 py-2 font-medium\">\n {tr(\"swagger.parameters.name\", { default: \"Name\" })}\n </th>\n <th className=\"px-3 py-2 font-medium\">\n {tr(\"swagger.parameters.in\", { default: \"In\" })}\n </th>\n <th className=\"px-3 py-2 font-medium\">\n {tr(\"swagger.parameters.type\", { default: \"Type\" })}\n </th>\n <th className=\"px-3 py-2 font-medium\">\n {tr(\"swagger.parameters.description\", { default: \"Description\" })}\n </th>\n </tr>\n </thead>\n <tbody>\n {props.parameters.map((param) => {\n const resolved = props.spec.resolve(param.schema);\n const example = (param as { example?: unknown }).example;\n return (\n <tr key={`${param.in}:${param.name}`} className=\"border-t\">\n <td className=\"px-3 py-2 align-top\">\n <span className=\"font-mono\">{param.name}</span>\n {param.required && (\n <span className=\"text-danger-text ml-1\" aria-hidden>\n *\n </span>\n )}\n </td>\n <td className=\"text-muted-foreground px-3 py-2 align-top text-xs\">\n {param.in}\n </td>\n <td className=\"text-muted-foreground px-3 py-2 align-top font-mono text-xs break-all\">\n {props.spec.typeLabel(param.schema)}\n </td>\n <td className=\"px-3 py-2 align-top text-xs\">\n {param.description ?? resolved?.description}\n {example !== undefined && (\n <div className=\"text-muted-foreground mt-0.5\">\n {tr(\"swagger.parameters.example\", { default: \"Example\" })}\n {\": \"}\n <code className=\"font-mono\">\n {JSON.stringify(example)}\n </code>\n </div>\n )}\n </td>\n </tr>\n );\n })}\n </tbody>\n </table>\n </div>\n );\n};\n"],"mappings":";;;;;;AAaA,MAAa,qBAAqB,UAAkC;CAClE,MAAM,EAAE,OAAO,QAAQ;CACvB,OACE,oBAAC,OAAD;EAAK,WAAU;EACb,UAAA,qBAAC,SAAD;GAAO,WAAU;GAAjB,UAAA,CACE,oBAAC,SAAD;IAAO,WAAU;IACf,UAAA,qBAAC,MAAD,EAAA,UAAA;KACE,oBAAC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AER,CAAC,EACI,CAAA,CACF;;CACJ,CAAA;AAET"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { type ZObject } from "alepha";
|
|
2
|
+
import type { ControlProps } from "../form/Control.tsx";
|
|
3
|
+
import type { OpenApiSpec, SwaggerEntry } from "./OpenApiSpec.ts";
|
|
4
|
+
import type { SwaggerResponseResult } from "./SwaggerResponseView.tsx";
|
|
5
|
+
/**
|
|
6
|
+
* How the request body is edited: as fields built from its schema, or as raw
|
|
7
|
+
* JSON in a textarea.
|
|
8
|
+
*/
|
|
9
|
+
export type SwaggerBodyMode = "form" | "json";
|
|
10
|
+
/**
|
|
11
|
+
* Where a form field goes in the request.
|
|
12
|
+
*/
|
|
13
|
+
export interface SwaggerFieldTarget {
|
|
14
|
+
in: "path" | "query" | "header" | "cookie" | "body" | "field" | "part";
|
|
15
|
+
name: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The form a "try it" panel renders for one operation, and how to read it back.
|
|
19
|
+
*/
|
|
20
|
+
export interface SwaggerRequestModel {
|
|
21
|
+
schema: ZObject;
|
|
22
|
+
fields: Record<string, Partial<Omit<ControlProps, "input">>>;
|
|
23
|
+
initialValues: Record<string, unknown>;
|
|
24
|
+
targets: Record<string, SwaggerFieldTarget>;
|
|
25
|
+
/**
|
|
26
|
+
* The body's media type, when the operation takes one.
|
|
27
|
+
*/
|
|
28
|
+
mediaType?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the body can be edited as fields at all: an object body can, an
|
|
31
|
+
* array or a scalar only as JSON.
|
|
32
|
+
*/
|
|
33
|
+
formable: boolean;
|
|
34
|
+
mode: SwaggerBodyMode;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A request ready for `fetch`.
|
|
38
|
+
*/
|
|
39
|
+
export interface SwaggerRequest {
|
|
40
|
+
method: string;
|
|
41
|
+
url: string;
|
|
42
|
+
headers: Record<string, string>;
|
|
43
|
+
body?: BodyInit;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Turns an operation into a form, and a submitted form into a request.
|
|
47
|
+
*
|
|
48
|
+
* The form is an ordinary `useForm` schema, built with `jsonSchemaToZod` from
|
|
49
|
+
* the operation's (dereferenced) JSON schemas, so every field is a `Control`
|
|
50
|
+
* and validation is the one the rest of the UI uses:
|
|
51
|
+
*
|
|
52
|
+
* - each path, query and header parameter is a top-level field;
|
|
53
|
+
* - a JSON object body is flattened, one field per property (a nested object
|
|
54
|
+
* stays a group), or a textarea of raw JSON in `json` mode, which is also
|
|
55
|
+
* the only mode for a body that is not an object;
|
|
56
|
+
* - a `multipart/form-data` body is flattened, one field per part, a binary
|
|
57
|
+
* part becoming a file input.
|
|
58
|
+
*/
|
|
59
|
+
export declare class SwaggerRequestBuilder {
|
|
60
|
+
protected readonly spec: OpenApiSpec;
|
|
61
|
+
constructor(spec: OpenApiSpec);
|
|
62
|
+
build(entry: SwaggerEntry, mode: SwaggerBodyMode): SwaggerRequestModel;
|
|
63
|
+
/**
|
|
64
|
+
* The request a submitted form describes. `origin` prefixes the path; leave
|
|
65
|
+
* it empty for the page's own origin.
|
|
66
|
+
*/
|
|
67
|
+
request(entry: SwaggerEntry, model: SwaggerRequestModel, values: Record<string, unknown>, origin?: string): SwaggerRequest;
|
|
68
|
+
/**
|
|
69
|
+
* Read a response as a stream, reporting it after the headers, after each
|
|
70
|
+
* chunk, and once more when it ends (`done`): a server-sent event or a
|
|
71
|
+
* chunked body shows as it arrives rather than when it closes. `elapsed`
|
|
72
|
+
* gives the milliseconds since the request left.
|
|
73
|
+
*/
|
|
74
|
+
read(res: Response, elapsed: () => number, onResult: (result: SwaggerResponseResult) => void): Promise<SwaggerResponseResult>;
|
|
75
|
+
/**
|
|
76
|
+
* A sample value for a schema, to seed the raw JSON editor: the schema's
|
|
77
|
+
* own example or default when it has one, else a value of the right shape.
|
|
78
|
+
*/
|
|
79
|
+
example(schema: any, depth?: number): unknown;
|
|
80
|
+
protected scalar(value: unknown): string;
|
|
81
|
+
protected uniqueKey(name: string, shape: Record<string, unknown>): string;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=SwaggerRequestBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwaggerRequestBuilder.d.ts","sourceRoot":"","sources":["../../src/swagger/SwaggerRequestBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,OAAO,EAAiB,MAAM,QAAQ,CAAC;AAEtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAEvE;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IACvE,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAC7D,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC5C;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,eAAe,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,QAAQ,CAAC;CACjB;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,qBAAqB;IAChC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAErC,YAAY,IAAI,EAAE,WAAW,EAE5B;IAEM,KAAK,CACV,KAAK,EAAE,YAAY,EACnB,IAAI,EAAE,eAAe,GACpB,mBAAmB,CAqErB;IAED;;;OAGG;IACI,OAAO,CACZ,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,mBAAmB,EAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,SAAK,GACV,cAAc,CAoEhB;IAED;;;;;OAKG;IACU,IAAI,CACf,GAAG,EAAE,QAAQ,EACb,OAAO,EAAE,MAAM,MAAM,EACrB,QAAQ,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,IAAI,GAChD,OAAO,CAAC,qBAAqB,CAAC,CA2BhC;IAED;;;OAGG;IACI,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,SAAI,GAAG,OAAO,CAwC9C;IAED,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAWvC;IAED,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAOxE;CACF"}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { jsonSchemaToZod, z } from "alepha";
|
|
2
|
+
// src/swagger/SwaggerRequestBuilder.ts
|
|
3
|
+
/**
|
|
4
|
+
* Turns an operation into a form, and a submitted form into a request.
|
|
5
|
+
*
|
|
6
|
+
* The form is an ordinary `useForm` schema, built with `jsonSchemaToZod` from
|
|
7
|
+
* the operation's (dereferenced) JSON schemas, so every field is a `Control`
|
|
8
|
+
* and validation is the one the rest of the UI uses:
|
|
9
|
+
*
|
|
10
|
+
* - each path, query and header parameter is a top-level field;
|
|
11
|
+
* - a JSON object body is flattened, one field per property (a nested object
|
|
12
|
+
* stays a group), or a textarea of raw JSON in `json` mode, which is also
|
|
13
|
+
* the only mode for a body that is not an object;
|
|
14
|
+
* - a `multipart/form-data` body is flattened, one field per part, a binary
|
|
15
|
+
* part becoming a file input.
|
|
16
|
+
*/
|
|
17
|
+
var SwaggerRequestBuilder = class {
|
|
18
|
+
spec;
|
|
19
|
+
constructor(spec) {
|
|
20
|
+
this.spec = spec;
|
|
21
|
+
}
|
|
22
|
+
build(entry, mode) {
|
|
23
|
+
const shape = {};
|
|
24
|
+
const fields = {};
|
|
25
|
+
const initialValues = {};
|
|
26
|
+
const targets = {};
|
|
27
|
+
for (const param of entry.operation.parameters ?? []) {
|
|
28
|
+
const key = this.uniqueKey(param.name, shape);
|
|
29
|
+
const schema = this.spec.dereference(param.schema);
|
|
30
|
+
let field = jsonSchemaToZod(schema);
|
|
31
|
+
if (param.description) field = field.meta({ description: param.description });
|
|
32
|
+
shape[key] = param.required ? field : field.optional();
|
|
33
|
+
targets[key] = {
|
|
34
|
+
in: param.in,
|
|
35
|
+
name: param.name
|
|
36
|
+
};
|
|
37
|
+
const example = param.example;
|
|
38
|
+
if (example !== void 0) initialValues[key] = example;
|
|
39
|
+
}
|
|
40
|
+
const content = entry.operation.requestBody?.content ?? {};
|
|
41
|
+
const [mediaType, media] = Object.entries(content)[0] ?? [];
|
|
42
|
+
const required = entry.operation.requestBody?.required !== false;
|
|
43
|
+
const bodySchema = media ? this.spec.dereference(media.schema) : void 0;
|
|
44
|
+
const formable = !!bodySchema?.properties;
|
|
45
|
+
const effective = formable ? mode : "json";
|
|
46
|
+
if (mediaType === "multipart/form-data" && bodySchema?.properties) {
|
|
47
|
+
const requiredParts = new Set(bodySchema.required ?? []);
|
|
48
|
+
for (const [name, part] of Object.entries(bodySchema.properties)) {
|
|
49
|
+
const key = this.uniqueKey(name, shape);
|
|
50
|
+
const binary = part?.format === "binary";
|
|
51
|
+
const field = binary ? z.file() : jsonSchemaToZod(part);
|
|
52
|
+
shape[key] = requiredParts.has(name) ? field : field.optional();
|
|
53
|
+
targets[key] = {
|
|
54
|
+
in: "part",
|
|
55
|
+
name
|
|
56
|
+
};
|
|
57
|
+
if (binary) fields[key] = { file: true };
|
|
58
|
+
}
|
|
59
|
+
} else if (mediaType && bodySchema && effective === "form") {
|
|
60
|
+
const requiredProps = new Set(bodySchema.required ?? []);
|
|
61
|
+
for (const [name, prop] of Object.entries(bodySchema.properties)) {
|
|
62
|
+
const key = this.uniqueKey(name, shape);
|
|
63
|
+
const field = jsonSchemaToZod(prop);
|
|
64
|
+
shape[key] = requiredProps.has(name) ? field : field.optional();
|
|
65
|
+
targets[key] = {
|
|
66
|
+
in: "field",
|
|
67
|
+
name
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
} else if (mediaType && bodySchema) {
|
|
71
|
+
const key = this.uniqueKey("body", shape);
|
|
72
|
+
targets[key] = {
|
|
73
|
+
in: "body",
|
|
74
|
+
name: "body"
|
|
75
|
+
};
|
|
76
|
+
shape[key] = required ? z.richText() : z.richText().optional();
|
|
77
|
+
fields[key] = {
|
|
78
|
+
area: true,
|
|
79
|
+
rows: 10
|
|
80
|
+
};
|
|
81
|
+
initialValues[key] = JSON.stringify(this.example(bodySchema), null, 2);
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
schema: z.object(shape),
|
|
85
|
+
fields,
|
|
86
|
+
initialValues,
|
|
87
|
+
targets,
|
|
88
|
+
mediaType,
|
|
89
|
+
formable,
|
|
90
|
+
mode: effective
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The request a submitted form describes. `origin` prefixes the path; leave
|
|
95
|
+
* it empty for the page's own origin.
|
|
96
|
+
*/
|
|
97
|
+
request(entry, model, values, origin = "") {
|
|
98
|
+
let path = entry.path;
|
|
99
|
+
const query = new URLSearchParams();
|
|
100
|
+
const headers = {};
|
|
101
|
+
const parts = new FormData();
|
|
102
|
+
let hasParts = false;
|
|
103
|
+
let body;
|
|
104
|
+
const json = {};
|
|
105
|
+
let hasJson = false;
|
|
106
|
+
for (const [key, target] of Object.entries(model.targets)) {
|
|
107
|
+
const value = values[key];
|
|
108
|
+
if (value === void 0 || value === null || value === "") continue;
|
|
109
|
+
switch (target.in) {
|
|
110
|
+
case "path":
|
|
111
|
+
path = path.replace(`{${target.name}}`, encodeURIComponent(this.scalar(value)));
|
|
112
|
+
break;
|
|
113
|
+
case "query":
|
|
114
|
+
for (const item of Array.isArray(value) ? value : [value]) query.append(target.name, this.scalar(item));
|
|
115
|
+
break;
|
|
116
|
+
case "header":
|
|
117
|
+
headers[target.name] = this.scalar(value);
|
|
118
|
+
break;
|
|
119
|
+
case "part":
|
|
120
|
+
hasParts = true;
|
|
121
|
+
if (value instanceof Blob) parts.append(target.name, value);
|
|
122
|
+
else parts.append(target.name, this.scalar(value));
|
|
123
|
+
break;
|
|
124
|
+
case "field":
|
|
125
|
+
hasJson = true;
|
|
126
|
+
json[target.name] = value;
|
|
127
|
+
break;
|
|
128
|
+
case "body":
|
|
129
|
+
headers["content-type"] = model.mediaType ?? "application/json";
|
|
130
|
+
body = model.mode === "json" && typeof value === "string" ? value : JSON.stringify(value);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (hasJson) {
|
|
134
|
+
headers["content-type"] = model.mediaType ?? "application/json";
|
|
135
|
+
body = JSON.stringify(json);
|
|
136
|
+
}
|
|
137
|
+
if (hasParts) body = parts;
|
|
138
|
+
const search = query.toString();
|
|
139
|
+
return {
|
|
140
|
+
method: entry.method.toUpperCase(),
|
|
141
|
+
url: `${origin}${path}${search ? `?${search}` : ""}`,
|
|
142
|
+
headers,
|
|
143
|
+
body
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Read a response as a stream, reporting it after the headers, after each
|
|
148
|
+
* chunk, and once more when it ends (`done`): a server-sent event or a
|
|
149
|
+
* chunked body shows as it arrives rather than when it closes. `elapsed`
|
|
150
|
+
* gives the milliseconds since the request left.
|
|
151
|
+
*/
|
|
152
|
+
async read(res, elapsed, onResult) {
|
|
153
|
+
const base = {
|
|
154
|
+
status: res.status,
|
|
155
|
+
statusText: res.statusText,
|
|
156
|
+
headers: [...res.headers.entries()],
|
|
157
|
+
contentType: res.headers.get("content-type") ?? void 0,
|
|
158
|
+
body: "",
|
|
159
|
+
durationMs: elapsed(),
|
|
160
|
+
done: !res.body
|
|
161
|
+
};
|
|
162
|
+
onResult(base);
|
|
163
|
+
if (!res.body) return base;
|
|
164
|
+
const reader = res.body.getReader();
|
|
165
|
+
const decoder = new TextDecoder();
|
|
166
|
+
let body = "";
|
|
167
|
+
for (;;) {
|
|
168
|
+
const chunk = await reader.read();
|
|
169
|
+
if (chunk.done) break;
|
|
170
|
+
body += decoder.decode(chunk.value, { stream: true });
|
|
171
|
+
onResult({
|
|
172
|
+
...base,
|
|
173
|
+
body,
|
|
174
|
+
durationMs: elapsed()
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
body += decoder.decode();
|
|
178
|
+
const result = {
|
|
179
|
+
...base,
|
|
180
|
+
body,
|
|
181
|
+
durationMs: elapsed(),
|
|
182
|
+
done: true
|
|
183
|
+
};
|
|
184
|
+
onResult(result);
|
|
185
|
+
return result;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* A sample value for a schema, to seed the raw JSON editor: the schema's
|
|
189
|
+
* own example or default when it has one, else a value of the right shape.
|
|
190
|
+
*/
|
|
191
|
+
example(schema, depth = 0) {
|
|
192
|
+
if (!schema || typeof schema !== "object" || depth > 6) return null;
|
|
193
|
+
if (schema.example !== void 0) return schema.example;
|
|
194
|
+
if (Array.isArray(schema.examples) && schema.examples.length) return schema.examples[0];
|
|
195
|
+
if (schema.default !== void 0) return schema.default;
|
|
196
|
+
if (schema.const !== void 0) return schema.const;
|
|
197
|
+
if (Array.isArray(schema.enum) && schema.enum.length) return schema.enum[0];
|
|
198
|
+
const variant = (schema.oneOf ?? schema.anyOf)?.find((it) => it?.type !== "null");
|
|
199
|
+
if (variant) return this.example(variant, depth + 1);
|
|
200
|
+
switch (Array.isArray(schema.type) ? schema.type[0] : schema.type) {
|
|
201
|
+
case "object": {
|
|
202
|
+
const out = {};
|
|
203
|
+
for (const [name, prop] of Object.entries(schema.properties ?? {})) out[name] = this.example(prop, depth + 1);
|
|
204
|
+
return out;
|
|
205
|
+
}
|
|
206
|
+
case "array": return schema.items ? [this.example(schema.items, depth + 1)] : [];
|
|
207
|
+
case "integer":
|
|
208
|
+
case "number": return 0;
|
|
209
|
+
case "boolean": return false;
|
|
210
|
+
case "string": return "";
|
|
211
|
+
default: return schema.properties ? this.example({
|
|
212
|
+
...schema,
|
|
213
|
+
type: "object"
|
|
214
|
+
}, depth) : null;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
scalar(value) {
|
|
218
|
+
if (value instanceof Date) return value.toISOString();
|
|
219
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") return String(value);
|
|
220
|
+
return JSON.stringify(value) ?? "";
|
|
221
|
+
}
|
|
222
|
+
uniqueKey(name, shape) {
|
|
223
|
+
let key = name;
|
|
224
|
+
let index = 2;
|
|
225
|
+
while (key in shape) key = `${name}${index++}`;
|
|
226
|
+
return key;
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
export { SwaggerRequestBuilder };
|
|
230
|
+
|
|
231
|
+
//# sourceMappingURL=SwaggerRequestBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwaggerRequestBuilder.js","names":[],"sources":["../../src/swagger/SwaggerRequestBuilder.ts"],"sourcesContent":["import { jsonSchemaToZod, type ZObject, type ZType, z } from \"alepha\";\n\nimport type { ControlProps } from \"../form/Control.tsx\";\nimport type { OpenApiSpec, SwaggerEntry } from \"./OpenApiSpec.ts\";\nimport type { SwaggerResponseResult } from \"./SwaggerResponseView.tsx\";\n\n/**\n * How the request body is edited: as fields built from its schema, or as raw\n * JSON in a textarea.\n */\nexport type SwaggerBodyMode = \"form\" | \"json\";\n\n/**\n * Where a form field goes in the request.\n */\nexport interface SwaggerFieldTarget {\n in: \"path\" | \"query\" | \"header\" | \"cookie\" | \"body\" | \"field\" | \"part\";\n name: string;\n}\n\n/**\n * The form a \"try it\" panel renders for one operation, and how to read it back.\n */\nexport interface SwaggerRequestModel {\n schema: ZObject;\n fields: Record<string, Partial<Omit<ControlProps, \"input\">>>;\n initialValues: Record<string, unknown>;\n targets: Record<string, SwaggerFieldTarget>;\n /**\n * The body's media type, when the operation takes one.\n */\n mediaType?: string;\n /**\n * Whether the body can be edited as fields at all: an object body can, an\n * array or a scalar only as JSON.\n */\n formable: boolean;\n mode: SwaggerBodyMode;\n}\n\n/**\n * A request ready for `fetch`.\n */\nexport interface SwaggerRequest {\n method: string;\n url: string;\n headers: Record<string, string>;\n body?: BodyInit;\n}\n\n/**\n * Turns an operation into a form, and a submitted form into a request.\n *\n * The form is an ordinary `useForm` schema, built with `jsonSchemaToZod` from\n * the operation's (dereferenced) JSON schemas, so every field is a `Control`\n * and validation is the one the rest of the UI uses:\n *\n * - each path, query and header parameter is a top-level field;\n * - a JSON object body is flattened, one field per property (a nested object\n * stays a group), or a textarea of raw JSON in `json` mode, which is also\n * the only mode for a body that is not an object;\n * - a `multipart/form-data` body is flattened, one field per part, a binary\n * part becoming a file input.\n */\nexport class SwaggerRequestBuilder {\n protected readonly spec: OpenApiSpec;\n\n constructor(spec: OpenApiSpec) {\n this.spec = spec;\n }\n\n public build(\n entry: SwaggerEntry,\n mode: SwaggerBodyMode,\n ): SwaggerRequestModel {\n const shape: Record<string, ZType> = {};\n const fields: SwaggerRequestModel[\"fields\"] = {};\n const initialValues: Record<string, unknown> = {};\n const targets: Record<string, SwaggerFieldTarget> = {};\n\n for (const param of entry.operation.parameters ?? []) {\n const key = this.uniqueKey(param.name, shape);\n const schema = this.spec.dereference(param.schema);\n let field = jsonSchemaToZod(schema);\n if (param.description) {\n field = field.meta({ description: param.description }) as ZType;\n }\n shape[key] = param.required ? field : (field.optional() as ZType);\n targets[key] = { in: param.in, name: param.name };\n const example = (param as { example?: unknown }).example;\n if (example !== undefined) {\n initialValues[key] = example;\n }\n }\n\n const content = entry.operation.requestBody?.content ?? {};\n const [mediaType, media] = Object.entries(content)[0] ?? [];\n const required = entry.operation.requestBody?.required !== false;\n const bodySchema = media ? this.spec.dereference(media.schema) : undefined;\n const formable = !!bodySchema?.properties;\n const effective: SwaggerBodyMode = formable ? mode : \"json\";\n\n if (mediaType === \"multipart/form-data\" && bodySchema?.properties) {\n const requiredParts = new Set<string>(bodySchema.required ?? []);\n for (const [name, part] of Object.entries<any>(bodySchema.properties)) {\n const key = this.uniqueKey(name, shape);\n const binary = part?.format === \"binary\";\n const field = binary ? (z.file() as ZType) : jsonSchemaToZod(part);\n shape[key] = requiredParts.has(name)\n ? field\n : (field.optional() as ZType);\n targets[key] = { in: \"part\", name };\n if (binary) {\n fields[key] = { file: true };\n }\n }\n } else if (mediaType && bodySchema && effective === \"form\") {\n const requiredProps = new Set<string>(bodySchema.required ?? []);\n for (const [name, prop] of Object.entries<any>(bodySchema.properties)) {\n const key = this.uniqueKey(name, shape);\n const field = jsonSchemaToZod(prop);\n shape[key] = requiredProps.has(name)\n ? field\n : (field.optional() as ZType);\n targets[key] = { in: \"field\", name };\n }\n } else if (mediaType && bodySchema) {\n const key = this.uniqueKey(\"body\", shape);\n targets[key] = { in: \"body\", name: \"body\" };\n shape[key] = required ? z.richText() : (z.richText().optional() as ZType);\n fields[key] = { area: true, rows: 10 };\n initialValues[key] = JSON.stringify(this.example(bodySchema), null, 2);\n }\n\n return {\n schema: z.object(shape) as ZObject,\n fields,\n initialValues,\n targets,\n mediaType,\n formable,\n mode: effective,\n };\n }\n\n /**\n * The request a submitted form describes. `origin` prefixes the path; leave\n * it empty for the page's own origin.\n */\n public request(\n entry: SwaggerEntry,\n model: SwaggerRequestModel,\n values: Record<string, unknown>,\n origin = \"\",\n ): SwaggerRequest {\n let path = entry.path;\n const query = new URLSearchParams();\n const headers: Record<string, string> = {};\n const parts = new FormData();\n let hasParts = false;\n let body: BodyInit | undefined;\n const json: Record<string, unknown> = {};\n let hasJson = false;\n\n for (const [key, target] of Object.entries(model.targets)) {\n const value = values[key];\n if (value === undefined || value === null || value === \"\") {\n continue;\n }\n switch (target.in) {\n case \"path\":\n path = path.replace(\n `{${target.name}}`,\n encodeURIComponent(this.scalar(value)),\n );\n break;\n case \"query\":\n for (const item of Array.isArray(value) ? value : [value]) {\n query.append(target.name, this.scalar(item));\n }\n break;\n case \"header\":\n headers[target.name] = this.scalar(value);\n break;\n case \"part\":\n hasParts = true;\n if (value instanceof Blob) {\n parts.append(target.name, value);\n } else {\n parts.append(target.name, this.scalar(value));\n }\n break;\n case \"field\":\n hasJson = true;\n json[target.name] = value;\n break;\n case \"body\":\n headers[\"content-type\"] = model.mediaType ?? \"application/json\";\n body =\n model.mode === \"json\" && typeof value === \"string\"\n ? value\n : JSON.stringify(value);\n break;\n }\n }\n\n if (hasJson) {\n headers[\"content-type\"] = model.mediaType ?? \"application/json\";\n body = JSON.stringify(json);\n }\n if (hasParts) {\n // No content-type: the browser writes the multipart boundary itself.\n body = parts;\n }\n\n const search = query.toString();\n return {\n method: entry.method.toUpperCase(),\n url: `${origin}${path}${search ? `?${search}` : \"\"}`,\n headers,\n body,\n };\n }\n\n /**\n * Read a response as a stream, reporting it after the headers, after each\n * chunk, and once more when it ends (`done`): a server-sent event or a\n * chunked body shows as it arrives rather than when it closes. `elapsed`\n * gives the milliseconds since the request left.\n */\n public async read(\n res: Response,\n elapsed: () => number,\n onResult: (result: SwaggerResponseResult) => void,\n ): Promise<SwaggerResponseResult> {\n const base: SwaggerResponseResult = {\n status: res.status,\n statusText: res.statusText,\n headers: [...res.headers.entries()],\n contentType: res.headers.get(\"content-type\") ?? undefined,\n body: \"\",\n durationMs: elapsed(),\n done: !res.body,\n };\n onResult(base);\n if (!res.body) {\n return base;\n }\n const reader = res.body.getReader();\n const decoder = new TextDecoder();\n let body = \"\";\n for (;;) {\n const chunk = await reader.read();\n if (chunk.done) break;\n body += decoder.decode(chunk.value, { stream: true });\n onResult({ ...base, body, durationMs: elapsed() });\n }\n body += decoder.decode();\n const result = { ...base, body, durationMs: elapsed(), done: true };\n onResult(result);\n return result;\n }\n\n /**\n * A sample value for a schema, to seed the raw JSON editor: the schema's\n * own example or default when it has one, else a value of the right shape.\n */\n public example(schema: any, depth = 0): unknown {\n if (!schema || typeof schema !== \"object\" || depth > 6) {\n return null;\n }\n if (schema.example !== undefined) return schema.example;\n if (Array.isArray(schema.examples) && schema.examples.length) {\n return schema.examples[0];\n }\n if (schema.default !== undefined) return schema.default;\n if (schema.const !== undefined) return schema.const;\n if (Array.isArray(schema.enum) && schema.enum.length) return schema.enum[0];\n const variant = (schema.oneOf ?? schema.anyOf)?.find(\n (it: any) => it?.type !== \"null\",\n );\n if (variant) return this.example(variant, depth + 1);\n const type = Array.isArray(schema.type) ? schema.type[0] : schema.type;\n switch (type) {\n case \"object\": {\n const out: Record<string, unknown> = {};\n for (const [name, prop] of Object.entries<any>(\n schema.properties ?? {},\n )) {\n out[name] = this.example(prop, depth + 1);\n }\n return out;\n }\n case \"array\":\n return schema.items ? [this.example(schema.items, depth + 1)] : [];\n case \"integer\":\n case \"number\":\n return 0;\n case \"boolean\":\n return false;\n case \"string\":\n return \"\";\n default:\n return schema.properties\n ? this.example({ ...schema, type: \"object\" }, depth)\n : null;\n }\n }\n\n protected scalar(value: unknown): string {\n if (value instanceof Date) return value.toISOString();\n if (\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"boolean\" ||\n typeof value === \"bigint\"\n ) {\n return String(value);\n }\n return JSON.stringify(value) ?? \"\";\n }\n\n protected uniqueKey(name: string, shape: Record<string, unknown>): string {\n let key = name;\n let index = 2;\n while (key in shape) {\n key = `${name}${index++}`;\n }\n return key;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgEA,IAAa,wBAAb,MAAmC;CACjC;CAEA,YAAY,MAAmB;EAC7B,KAAK,OAAO;CACd;CAEA,MACE,OACA,MACqB;EACrB,MAAM,QAA+B,CAAC;EACtC,MAAM,SAAwC,CAAC;EAC/C,MAAM,gBAAyC,CAAC;EAChD,MAAM,UAA8C,CAAC;EAErD,KAAK,MAAM,SAAS,MAAM,UAAU,cAAc,CAAC,GAAG;GACpD,MAAM,MAAM,KAAK,UAAU,MAAM,MAAM,KAAK;GAC5C,MAAM,SAAS,KAAK,KAAK,YAAY,MAAM,MAAM;GACjD,IAAI,QAAQ,gBAAgB,MAAM;GAClC,IAAI,MAAM,aACR,QAAQ,MAAM,KAAK,EAAE,aAAa,MAAM,YAAY,CAAC;GAEvD,MAAM,OAAO,MAAM,WAAW,QAAS,MAAM,SAAS;GACtD,QAAQ,OAAO;IAAE,IAAI,MAAM;IAAI,MAAM,MAAM;GAAK;GAChD,MAAM,UAAW,MAAgC;GACjD,IAAI,YAAY,KAAA,GACd,cAAc,OAAO;EAEzB;EAEA,MAAM,UAAU,MAAM,UAAU,aAAa,WAAW,CAAC;EACzD,MAAM,CAAC,WAAW,SAAS,OAAO,QAAQ,OAAO,CAAC,CAAC,MAAM,CAAC;EAC1D,MAAM,WAAW,MAAM,UAAU,aAAa,aAAa;EAC3D,MAAM,aAAa,QAAQ,KAAK,KAAK,YAAY,MAAM,MAAM,IAAI,KAAA;EACjE,MAAM,WAAW,CAAC,CAAC,YAAY;EAC/B,MAAM,YAA6B,WAAW,OAAO;EAErD,IAAI,cAAc,yBAAyB,YAAY,YAAY;GACjE,MAAM,gBAAgB,IAAI,IAAY,WAAW,YAAY,CAAC,CAAC;GAC/D,KAAK,MAAM,CAAC,MAAM,SAAS,OAAO,QAAa,WAAW,UAAU,GAAG;IACrE,MAAM,MAAM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,MAAM,CAAC,MAAM,SAAS,OAAO,QAChC,OAAO,cAAc,CAAC,CACxB,GACE,IAAI,QAAQ,KAAK,QAAQ,MAAM,QAAQ,CAAC;IAE1C,OAAO;GACT;GACA,KAAK,SACH,OAAO,OAAO,QAAQ,CAAC,KAAK,QAAQ,OAAO,OAAO,QAAQ,CAAC,CAAC,IAAI,CAAC;GACnE,KAAK;GACL,KAAK,UACH,OAAO;GACT,KAAK,WACH,OAAO;GACT,KAAK,UACH,OAAO;GACT,SACE,OAAO,OAAO,aACV,KAAK,QAAQ;IAAE,GAAG;IAAQ,MAAM;GAAS,GAAG,KAAK,IACjD;EACR;CACF;CAEA,OAAiB,OAAwB;EACvC,IAAI,iBAAiB,MAAM,OAAO,MAAM,YAAY;EACpD,IACE,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU,aACjB,OAAO,UAAU,UAEjB,OAAO,OAAO,KAAK;EAErB,OAAO,KAAK,UAAU,KAAK,KAAK;CAClC;CAEA,UAAoB,MAAc,OAAwC;EACxE,IAAI,MAAM;EACV,IAAI,QAAQ;EACZ,OAAO,OAAO,OACZ,MAAM,GAAG,OAAO;EAElB,OAAO;CACT;AACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What came back from a "try it" request, as it arrives.
|
|
3
|
+
*/
|
|
4
|
+
export interface SwaggerResponseResult {
|
|
5
|
+
status: number;
|
|
6
|
+
statusText: string;
|
|
7
|
+
headers: Array<[string, string]>;
|
|
8
|
+
/**
|
|
9
|
+
* The body as text so far. A streamed response grows while `done` is false.
|
|
10
|
+
*/
|
|
11
|
+
body: string;
|
|
12
|
+
contentType?: string;
|
|
13
|
+
durationMs: number;
|
|
14
|
+
done: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface SwaggerResponseViewProps {
|
|
17
|
+
result: SwaggerResponseResult;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The response of a sent request: status, time, size and headers, then the
|
|
21
|
+
* body, pretty-printed when it is JSON and left as text otherwise. A streamed
|
|
22
|
+
* body shows a spinner until the stream ends.
|
|
23
|
+
*/
|
|
24
|
+
export declare const SwaggerResponseView: (props: SwaggerResponseViewProps) => import("react").JSX.Element;
|
|
25
|
+
//# sourceMappingURL=SwaggerResponseView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwaggerResponseView.d.ts","sourceRoot":"","sources":["../../src/swagger/SwaggerResponseView.tsx"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACjC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,qBAAqB,CAAC;CAC/B;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,UAAW,wBAAwB,gCAyDlE,CAAC"}
|