@apiboost/omnispec 1.0.0 → 1.1.0-next.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/dist/cjs/asyncapi/index.js +5 -5
- package/dist/cjs/chunks/AsyncApiSpec-Bj1F8C5K.js +2601 -0
- package/dist/cjs/chunks/AsyncApiSpec-Bj1F8C5K.js.map +1 -0
- package/dist/cjs/chunks/{Collapsible-BHAHk_Ep.js → Collapsible-BTWyDBkX.js} +429 -209
- package/dist/cjs/chunks/Collapsible-BTWyDBkX.js.map +1 -0
- package/dist/cjs/chunks/{ErrorBoundary-c1piU8da.js → ErrorBoundary-CezYgQDG.js} +2 -2
- package/dist/cjs/chunks/{ErrorBoundary-c1piU8da.js.map → ErrorBoundary-CezYgQDG.js.map} +1 -1
- package/dist/cjs/chunks/{OmniSpecRenderer-CE4wxVTL.js → OmniSpecRenderer-CghCPNuw.js} +6 -6
- package/dist/cjs/chunks/{OmniSpecRenderer-CE4wxVTL.js.map → OmniSpecRenderer-CghCPNuw.js.map} +1 -1
- package/dist/cjs/chunks/{OpenApiSpec-D0JtmOVQ.js → OpenApiSpec-BOlesoUX.js} +12 -12
- package/dist/cjs/chunks/OpenApiSpec-BOlesoUX.js.map +1 -0
- package/dist/cjs/chunks/{OpenIdConnectManual-oEnN0QJ-.js → OpenIdConnectManual-Bh7tdxoH.js} +7 -227
- package/dist/cjs/chunks/OpenIdConnectManual-Bh7tdxoH.js.map +1 -0
- package/dist/cjs/chunks/{ref-resolver-DWu6Q6E5.js → ref-resolver-0A8GNRI3.js} +6 -2
- package/dist/cjs/chunks/{ref-resolver-DWu6Q6E5.js.map → ref-resolver-0A8GNRI3.js.map} +1 -1
- package/dist/cjs/chunks/{useSpecDetector-A4OwYrmY.js → useSpecDetector-BemsWW9u.js} +2 -2
- package/dist/cjs/chunks/{useSpecDetector-A4OwYrmY.js.map → useSpecDetector-BemsWW9u.js.map} +1 -1
- package/dist/cjs/chunks/{useSpecFetcher-BKz1jHTV.js → useSpecFetcher-BAbHnXax.js} +28 -1
- package/dist/{esm/chunks/useSpecFetcher-CZvAnU7Z.js.map → cjs/chunks/useSpecFetcher-BAbHnXax.js.map} +1 -1
- package/dist/cjs/core/public.js +5 -5
- package/dist/cjs/index.js +9 -9
- package/dist/cjs/openapi/index.js +6 -6
- package/dist/cjs/wc/index.js +4 -4
- package/dist/esm/asyncapi/index.js +5 -5
- package/dist/esm/chunks/AsyncApiSpec-BzhfaQ_T.js +2599 -0
- package/dist/esm/chunks/AsyncApiSpec-BzhfaQ_T.js.map +1 -0
- package/dist/esm/chunks/{Collapsible-DA6-nS46.js → Collapsible-MyJB2agz.js} +428 -211
- package/dist/esm/chunks/Collapsible-MyJB2agz.js.map +1 -0
- package/dist/esm/chunks/{ErrorBoundary-posRNrbt.js → ErrorBoundary-9pDlZFfM.js} +2 -2
- package/dist/esm/chunks/{ErrorBoundary-posRNrbt.js.map → ErrorBoundary-9pDlZFfM.js.map} +1 -1
- package/dist/esm/chunks/{OmniSpecRenderer-MqsQFXro.js → OmniSpecRenderer-BUJSl_2I.js} +6 -6
- package/dist/esm/chunks/{OmniSpecRenderer-MqsQFXro.js.map → OmniSpecRenderer-BUJSl_2I.js.map} +1 -1
- package/dist/esm/chunks/{OpenApiSpec-Cy-oW6jA.js → OpenApiSpec-wm3tH2vF.js} +6 -6
- package/dist/esm/chunks/OpenApiSpec-wm3tH2vF.js.map +1 -0
- package/dist/esm/chunks/{OpenIdConnectManual-COfITasf.js → OpenIdConnectManual-DPmTIIIy.js} +6 -223
- package/dist/esm/chunks/OpenIdConnectManual-DPmTIIIy.js.map +1 -0
- package/dist/esm/chunks/{ref-resolver-BIrHJOjz.js → ref-resolver-B0C36NuQ.js} +6 -3
- package/dist/esm/chunks/{ref-resolver-BIrHJOjz.js.map → ref-resolver-B0C36NuQ.js.map} +1 -1
- package/dist/esm/chunks/{useSpecDetector-5SGcKnJx.js → useSpecDetector-BJBNbfN5.js} +2 -2
- package/dist/esm/chunks/{useSpecDetector-5SGcKnJx.js.map → useSpecDetector-BJBNbfN5.js.map} +1 -1
- package/dist/esm/chunks/{useSpecFetcher-CZvAnU7Z.js → useSpecFetcher-BvVfMuzf.js} +28 -1
- package/dist/{cjs/chunks/useSpecFetcher-BKz1jHTV.js.map → esm/chunks/useSpecFetcher-BvVfMuzf.js.map} +1 -1
- package/dist/esm/core/public.js +4 -4
- package/dist/esm/index.js +9 -9
- package/dist/esm/openapi/index.js +6 -6
- package/dist/esm/wc/index.js +4 -4
- package/dist/types/asyncapi/AsyncApiSpec.d.ts +1 -1
- package/dist/types/asyncapi/AsyncApiSpec.d.ts.map +1 -1
- package/dist/types/asyncapi/components/AsyncOverview.d.ts.map +1 -1
- package/dist/types/asyncapi/components/BindingsSection.d.ts +26 -0
- package/dist/types/asyncapi/components/BindingsSection.d.ts.map +1 -0
- package/dist/types/asyncapi/components/ChannelDetail.d.ts +7 -2
- package/dist/types/asyncapi/components/ChannelDetail.d.ts.map +1 -1
- package/dist/types/asyncapi/components/ChannelReferenceDetail.d.ts +35 -0
- package/dist/types/asyncapi/components/ChannelReferenceDetail.d.ts.map +1 -0
- package/dist/types/asyncapi/components/ComponentsSection.d.ts +1 -1
- package/dist/types/asyncapi/components/ComponentsSection.d.ts.map +1 -1
- package/dist/types/asyncapi/components/ExternalDocsLink.d.ts +29 -0
- package/dist/types/asyncapi/components/ExternalDocsLink.d.ts.map +1 -0
- package/dist/types/asyncapi/components/MessagePayload.d.ts +22 -0
- package/dist/types/asyncapi/components/MessagePayload.d.ts.map +1 -0
- package/dist/types/asyncapi/components/SecurityRequirementBadges.d.ts +29 -0
- package/dist/types/asyncapi/components/SecurityRequirementBadges.d.ts.map +1 -0
- package/dist/types/asyncapi/components/SecuritySchemesSection.d.ts +23 -0
- package/dist/types/asyncapi/components/SecuritySchemesSection.d.ts.map +1 -0
- package/dist/types/asyncapi/components/ServerList.d.ts +1 -1
- package/dist/types/asyncapi/components/ServerList.d.ts.map +1 -1
- package/dist/types/asyncapi/components/TagGroupHeader.d.ts +18 -0
- package/dist/types/asyncapi/components/TagGroupHeader.d.ts.map +1 -0
- package/dist/types/asyncapi/components/field-display.d.ts +30 -0
- package/dist/types/asyncapi/components/field-display.d.ts.map +1 -0
- package/dist/types/asyncapi/parser/asyncapi-parser.d.ts.map +1 -1
- package/dist/types/asyncapi/schema-formats.d.ts +26 -0
- package/dist/types/asyncapi/schema-formats.d.ts.map +1 -0
- package/dist/types/asyncapi/tag-grouping.d.ts +43 -0
- package/dist/types/asyncapi/tag-grouping.d.ts.map +1 -0
- package/dist/types/asyncapi/types/asyncapi.types.d.ts +72 -8
- package/dist/types/asyncapi/types/asyncapi.types.d.ts.map +1 -1
- package/dist/types/core/components/Layout/DocLayout.d.ts.map +1 -1
- package/dist/types/core/types/auth.types.d.ts +1 -1
- package/dist/types/openapi/parser/ref-resolver.d.ts +8 -0
- package/dist/types/openapi/parser/ref-resolver.d.ts.map +1 -1
- package/dist/wc/standalone.js +1 -1
- package/dist/wc/standalone.js.map +1 -1
- package/package.json +2 -2
- package/dist/cjs/chunks/AsyncApiSpec-TBlyRxTP.js +0 -819
- package/dist/cjs/chunks/AsyncApiSpec-TBlyRxTP.js.map +0 -1
- package/dist/cjs/chunks/Collapsible-BHAHk_Ep.js.map +0 -1
- package/dist/cjs/chunks/OpenApiSpec-D0JtmOVQ.js.map +0 -1
- package/dist/cjs/chunks/OpenIdConnectManual-oEnN0QJ-.js.map +0 -1
- package/dist/esm/chunks/AsyncApiSpec-C3lsUpZk.js +0 -817
- package/dist/esm/chunks/AsyncApiSpec-C3lsUpZk.js.map +0 -1
- package/dist/esm/chunks/Collapsible-DA6-nS46.js.map +0 -1
- package/dist/esm/chunks/OpenApiSpec-Cy-oW6jA.js.map +0 -1
- package/dist/esm/chunks/OpenIdConnectManual-COfITasf.js.map +0 -1
|
@@ -1,817 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { useCallback, useState, useMemo } from 'react';
|
|
3
|
-
import { css, cx } from '@emotion/css';
|
|
4
|
-
import { a as useSpecFetcher, m as mq, r as resolveSchemaStyle, S as SpecType, T as ThemeProvider, L as LoadingScreen, b as SpecStatusScreen, E as ErrorMessage, h as buildSidebar, C as ConfigProvider, e as DocLayout, N as NavTree } from './useSpecFetcher-CZvAnU7Z.js';
|
|
5
|
-
import { M as MarkdownRenderer, d as ExpandableCard, f as MethodBar, T as Tabs, t as SchemaTree, A as schemaToNodes, C as CodeBlock, x as generateExample, a as Collapsible, w as flattenNavItemIds, G as useScrollSpy, H as ExpandProvider, v as SpecToolbar, z as resolveDownloadLink, u as SearchBar } from './Collapsible-DA6-nS46.js';
|
|
6
|
-
import { E as ErrorBoundary } from './ErrorBoundary-posRNrbt.js';
|
|
7
|
-
import { r as resolveRefs, p as parse } from './ref-resolver-BIrHJOjz.js';
|
|
8
|
-
import '@emotion/styled';
|
|
9
|
-
import './ssrf-guard-CsZoYdEq.js';
|
|
10
|
-
|
|
11
|
-
async function parseAsyncApiSpec(specInput) {
|
|
12
|
-
const raw = typeof specInput === "string" ? parseSpecString(specInput) : specInput;
|
|
13
|
-
const api = await resolveRefs(raw);
|
|
14
|
-
const majorVersion = parseInt(api.asyncapi.split(".")[0], 10);
|
|
15
|
-
const isV3 = majorVersion >= 3;
|
|
16
|
-
const servers = extractServers(api);
|
|
17
|
-
const channels = isV3 ? extractChannelsV3(api) : extractChannelsV2(api);
|
|
18
|
-
const components = extractComponents(api);
|
|
19
|
-
const root = api;
|
|
20
|
-
const tags = api.tags?.map((tag) => {
|
|
21
|
-
const raw2 = tag;
|
|
22
|
-
return {
|
|
23
|
-
name: tag.name,
|
|
24
|
-
description: tag.description,
|
|
25
|
-
displayName: raw2["x-displayName"],
|
|
26
|
-
externalDocs: raw2.externalDocs
|
|
27
|
-
};
|
|
28
|
-
})?.filter((tag) => !tag["x-internal"]);
|
|
29
|
-
return {
|
|
30
|
-
title: api.info.title,
|
|
31
|
-
description: api.info.description,
|
|
32
|
-
version: api.info.version,
|
|
33
|
-
specVersion: api.asyncapi,
|
|
34
|
-
servers,
|
|
35
|
-
channels: channels.filter((ch) => !ch.xInternal),
|
|
36
|
-
components,
|
|
37
|
-
tags,
|
|
38
|
-
tagGroups: root["x-tagGroups"],
|
|
39
|
-
externalDocs: api.externalDocs,
|
|
40
|
-
contact: api.info.contact,
|
|
41
|
-
license: api.info.license,
|
|
42
|
-
termsOfService: api.info.termsOfService,
|
|
43
|
-
logo: api.info["x-logo"]
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
function extractServers(api) {
|
|
47
|
-
if (!api.servers) return [];
|
|
48
|
-
if (Array.isArray(api.servers)) {
|
|
49
|
-
return api.servers.map((s, idx) => ({
|
|
50
|
-
name: s.name ?? `server-${idx}`,
|
|
51
|
-
url: s.host ? `${s.protocol}://${s.host}${s.pathname ?? ""}` : s.url ?? "",
|
|
52
|
-
protocol: s.protocol,
|
|
53
|
-
protocolVersion: s.protocolVersion,
|
|
54
|
-
description: s.description,
|
|
55
|
-
variables: s.variables,
|
|
56
|
-
security: s.security
|
|
57
|
-
}));
|
|
58
|
-
}
|
|
59
|
-
return Object.entries(api.servers).map(([name, s]) => ({
|
|
60
|
-
name,
|
|
61
|
-
url: s.host ? `${s.protocol}://${s.host}${s.pathname ?? ""}` : s.url ?? "",
|
|
62
|
-
protocol: s.protocol,
|
|
63
|
-
protocolVersion: s.protocolVersion,
|
|
64
|
-
description: s.description,
|
|
65
|
-
variables: s.variables,
|
|
66
|
-
security: s.security
|
|
67
|
-
}));
|
|
68
|
-
}
|
|
69
|
-
function extractChannelsV2(api) {
|
|
70
|
-
if (!api.channels) return [];
|
|
71
|
-
return Object.entries(api.channels).map(([channelName, ch]) => {
|
|
72
|
-
const operations = [];
|
|
73
|
-
if (ch.publish) {
|
|
74
|
-
operations.push(convertOperationV2("publish", ch.publish));
|
|
75
|
-
}
|
|
76
|
-
if (ch.subscribe) {
|
|
77
|
-
operations.push(convertOperationV2("subscribe", ch.subscribe));
|
|
78
|
-
}
|
|
79
|
-
const raw = ch;
|
|
80
|
-
return {
|
|
81
|
-
name: channelName,
|
|
82
|
-
address: channelName,
|
|
83
|
-
description: ch.description,
|
|
84
|
-
operations: operations.filter((op) => !op.xInternal),
|
|
85
|
-
parameters: ch.parameters,
|
|
86
|
-
bindings: ch.bindings,
|
|
87
|
-
xInternal: raw["x-internal"]
|
|
88
|
-
};
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
function convertOperationV2(action, op) {
|
|
92
|
-
let message;
|
|
93
|
-
if (op.message) {
|
|
94
|
-
if ("oneOf" in op.message) {
|
|
95
|
-
message = convertMessage(op.message.oneOf[0]);
|
|
96
|
-
} else {
|
|
97
|
-
message = convertMessage(op.message);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
const raw = op;
|
|
101
|
-
return {
|
|
102
|
-
action,
|
|
103
|
-
operationId: op.operationId,
|
|
104
|
-
summary: op.summary,
|
|
105
|
-
description: op.description,
|
|
106
|
-
message,
|
|
107
|
-
tags: op.tags,
|
|
108
|
-
bindings: op.bindings,
|
|
109
|
-
xBadges: raw["x-badges"],
|
|
110
|
-
xInternal: raw["x-internal"]
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
function extractChannelsV3(api) {
|
|
114
|
-
if (!api.channels) return [];
|
|
115
|
-
const channelMap = /* @__PURE__ */ new Map();
|
|
116
|
-
for (const [channelName, ch] of Object.entries(api.channels)) {
|
|
117
|
-
const raw = ch;
|
|
118
|
-
channelMap.set(channelName, {
|
|
119
|
-
name: channelName,
|
|
120
|
-
address: ch.address ?? channelName,
|
|
121
|
-
description: ch.description,
|
|
122
|
-
operations: [],
|
|
123
|
-
parameters: ch.parameters,
|
|
124
|
-
bindings: ch.bindings,
|
|
125
|
-
xInternal: raw["x-internal"]
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
if (api.operations) {
|
|
129
|
-
for (const [, op] of Object.entries(api.operations)) {
|
|
130
|
-
const channelRef = op.channel;
|
|
131
|
-
let channelName;
|
|
132
|
-
if (channelRef && "$ref" in channelRef && typeof channelRef.$ref === "string") {
|
|
133
|
-
channelName = channelRef.$ref.split("/").pop();
|
|
134
|
-
}
|
|
135
|
-
const messages = [];
|
|
136
|
-
if (op.messages) {
|
|
137
|
-
for (const msg of op.messages) {
|
|
138
|
-
if ("$ref" in msg) continue;
|
|
139
|
-
messages.push(convertMessage(msg));
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
const raw = op;
|
|
143
|
-
const operation = {
|
|
144
|
-
action: op.action,
|
|
145
|
-
summary: op.summary,
|
|
146
|
-
description: op.description,
|
|
147
|
-
message: messages[0],
|
|
148
|
-
tags: op.tags,
|
|
149
|
-
bindings: op.bindings,
|
|
150
|
-
xBadges: raw["x-badges"],
|
|
151
|
-
xInternal: raw["x-internal"]
|
|
152
|
-
};
|
|
153
|
-
if (operation.xInternal) continue;
|
|
154
|
-
if (channelName && channelMap.has(channelName)) {
|
|
155
|
-
channelMap.get(channelName).operations.push(operation);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return Array.from(channelMap.values());
|
|
160
|
-
}
|
|
161
|
-
function convertMessage(msg) {
|
|
162
|
-
return {
|
|
163
|
-
name: msg.name,
|
|
164
|
-
title: msg.title,
|
|
165
|
-
summary: msg.summary,
|
|
166
|
-
description: msg.description,
|
|
167
|
-
contentType: msg.contentType,
|
|
168
|
-
payload: msg.payload,
|
|
169
|
-
headers: msg.headers,
|
|
170
|
-
correlationId: msg.correlationId,
|
|
171
|
-
tags: msg.tags,
|
|
172
|
-
examples: msg.examples,
|
|
173
|
-
bindings: msg.bindings
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
function extractComponents(api) {
|
|
177
|
-
return {
|
|
178
|
-
schemas: api.components?.schemas ?? {},
|
|
179
|
-
messages: api.components?.messages ?? {}
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
function parseSpecString(input) {
|
|
183
|
-
const trimmed = input.trim();
|
|
184
|
-
if (trimmed.startsWith("{")) {
|
|
185
|
-
try {
|
|
186
|
-
return JSON.parse(trimmed);
|
|
187
|
-
} catch {
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
return parse(trimmed);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function useAsyncApiSpec(spec) {
|
|
194
|
-
const parser = useCallback(async (raw) => {
|
|
195
|
-
return parseAsyncApiSpec(raw);
|
|
196
|
-
}, []);
|
|
197
|
-
return useSpecFetcher(spec, parser);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const containerStyle$2 = css({
|
|
201
|
-
marginBottom: "32px",
|
|
202
|
-
paddingBottom: "24px",
|
|
203
|
-
borderBottom: "1px solid var(--omnispec-border-color)"
|
|
204
|
-
});
|
|
205
|
-
const titleStyle$2 = css({
|
|
206
|
-
margin: "0 0 4px",
|
|
207
|
-
fontSize: "var(--omnispec-h2-font-size)",
|
|
208
|
-
color: "var(--omnispec-h2-color)",
|
|
209
|
-
fontWeight: 700,
|
|
210
|
-
display: "inline"
|
|
211
|
-
});
|
|
212
|
-
const versionStyle$1 = css({
|
|
213
|
-
fontSize: "var(--omnispec-font-size-sm)",
|
|
214
|
-
color: "var(--omnispec-fg-muted)",
|
|
215
|
-
marginLeft: "12px",
|
|
216
|
-
fontFamily: "var(--omnispec-font-mono)"
|
|
217
|
-
});
|
|
218
|
-
const specBadgeStyle = css({
|
|
219
|
-
fontSize: "var(--omnispec-font-size-xs)",
|
|
220
|
-
color: "var(--omnispec-color-primary)",
|
|
221
|
-
border: "1px solid var(--omnispec-color-primary)",
|
|
222
|
-
borderRadius: "4px",
|
|
223
|
-
padding: "1px 6px",
|
|
224
|
-
marginLeft: "8px",
|
|
225
|
-
fontFamily: "var(--omnispec-font-mono)"
|
|
226
|
-
});
|
|
227
|
-
const metaStyle = css({
|
|
228
|
-
fontSize: "var(--omnispec-font-size-sm)",
|
|
229
|
-
color: "var(--omnispec-fg-secondary)",
|
|
230
|
-
marginTop: "4px"
|
|
231
|
-
});
|
|
232
|
-
const linkStyle = css({
|
|
233
|
-
color: "var(--omnispec-fg-link)",
|
|
234
|
-
textDecoration: "none",
|
|
235
|
-
"&:hover": {
|
|
236
|
-
textDecoration: "underline"
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
function AsyncOverview({ spec }) {
|
|
240
|
-
return /* @__PURE__ */ jsxs("div", { className: cx("omnispec-async-overview", containerStyle$2), children: [
|
|
241
|
-
/* @__PURE__ */ jsx("h1", { className: titleStyle$2, children: spec.title }),
|
|
242
|
-
/* @__PURE__ */ jsxs("span", { className: versionStyle$1, children: [
|
|
243
|
-
"v",
|
|
244
|
-
spec.version
|
|
245
|
-
] }),
|
|
246
|
-
/* @__PURE__ */ jsxs("span", { className: specBadgeStyle, children: [
|
|
247
|
-
"AsyncAPI ",
|
|
248
|
-
spec.specVersion
|
|
249
|
-
] }),
|
|
250
|
-
spec.description && /* @__PURE__ */ jsx(MarkdownRenderer, { content: spec.description }),
|
|
251
|
-
spec.contact && /* @__PURE__ */ jsxs("div", { className: metaStyle, children: [
|
|
252
|
-
spec.contact.name && /* @__PURE__ */ jsxs("span", { children: [
|
|
253
|
-
"Contact: ",
|
|
254
|
-
spec.contact.name
|
|
255
|
-
] }),
|
|
256
|
-
spec.contact.email && /* @__PURE__ */ jsxs("span", { children: [
|
|
257
|
-
" <",
|
|
258
|
-
/* @__PURE__ */ jsx("a", { href: `mailto:${spec.contact.email}`, className: linkStyle, children: spec.contact.email }),
|
|
259
|
-
">"
|
|
260
|
-
] }),
|
|
261
|
-
spec.contact.url && /* @__PURE__ */ jsxs("span", { children: [
|
|
262
|
-
" \xB7 ",
|
|
263
|
-
/* @__PURE__ */ jsx("a", { href: spec.contact.url, target: "_blank", rel: "noopener noreferrer", className: linkStyle, children: spec.contact.url })
|
|
264
|
-
] })
|
|
265
|
-
] }),
|
|
266
|
-
spec.license && /* @__PURE__ */ jsxs("div", { className: metaStyle, children: [
|
|
267
|
-
"License: ",
|
|
268
|
-
spec.license.url ? /* @__PURE__ */ jsx("a", { href: spec.license.url, target: "_blank", rel: "noopener noreferrer", className: linkStyle, children: spec.license.name }) : spec.license.name
|
|
269
|
-
] }),
|
|
270
|
-
spec.externalDocs && /* @__PURE__ */ jsx("div", { className: metaStyle, children: /* @__PURE__ */ jsx("a", { href: spec.externalDocs.url, target: "_blank", rel: "noopener noreferrer", className: linkStyle, children: spec.externalDocs.description ?? "External Documentation" }) })
|
|
271
|
-
] });
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
const protocolColors = {
|
|
275
|
-
kafka: "#231F20",
|
|
276
|
-
"kafka-secure": "#231F20",
|
|
277
|
-
mqtt: "#660066",
|
|
278
|
-
"mqtt5": "#660066",
|
|
279
|
-
amqp: "#FF6600",
|
|
280
|
-
"amqp1": "#FF6600",
|
|
281
|
-
ws: "#4A90D9",
|
|
282
|
-
wss: "#4A90D9",
|
|
283
|
-
http: "var(--omnispec-color-get)",
|
|
284
|
-
https: "var(--omnispec-color-get)",
|
|
285
|
-
nats: "#27AAE1",
|
|
286
|
-
redis: "#DC382D",
|
|
287
|
-
sns: "#FF9900",
|
|
288
|
-
sqs: "#FF9900",
|
|
289
|
-
stomp: "#6DB33F",
|
|
290
|
-
mercure: "#1D1D1D"
|
|
291
|
-
};
|
|
292
|
-
const badgeBase = css({
|
|
293
|
-
display: "inline-block",
|
|
294
|
-
padding: "2px 8px",
|
|
295
|
-
borderRadius: "4px",
|
|
296
|
-
fontSize: "10px",
|
|
297
|
-
fontWeight: 700,
|
|
298
|
-
fontFamily: "var(--omnispec-font-mono)",
|
|
299
|
-
color: "#ffffff",
|
|
300
|
-
letterSpacing: "0.5px"
|
|
301
|
-
});
|
|
302
|
-
const versionStyle = css({
|
|
303
|
-
fontWeight: 400,
|
|
304
|
-
opacity: 0.8
|
|
305
|
-
});
|
|
306
|
-
function ProtocolBadge({ protocol, version }) {
|
|
307
|
-
const color = protocolColors[protocol.toLowerCase()] ?? "var(--omnispec-fg-muted)";
|
|
308
|
-
return /* @__PURE__ */ jsxs("span", { className: cx(badgeBase, css({ backgroundColor: color })), children: [
|
|
309
|
-
protocol.toUpperCase(),
|
|
310
|
-
version && /* @__PURE__ */ jsxs("span", { className: versionStyle, children: [
|
|
311
|
-
" ",
|
|
312
|
-
version
|
|
313
|
-
] })
|
|
314
|
-
] });
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
const containerStyle$1 = css({
|
|
318
|
-
marginBottom: "24px"
|
|
319
|
-
});
|
|
320
|
-
const titleStyle$1 = css({
|
|
321
|
-
margin: "0 0 12px",
|
|
322
|
-
fontSize: "var(--omnispec-h3-font-size)",
|
|
323
|
-
color: "var(--omnispec-h3-color)",
|
|
324
|
-
fontWeight: 600
|
|
325
|
-
});
|
|
326
|
-
const gridStyle = css({
|
|
327
|
-
display: "flex",
|
|
328
|
-
flexDirection: "column",
|
|
329
|
-
gap: "8px"
|
|
330
|
-
});
|
|
331
|
-
const cardStyle = css({
|
|
332
|
-
padding: "12px",
|
|
333
|
-
border: "1px solid var(--omnispec-border-color)",
|
|
334
|
-
borderRadius: "var(--omnispec-border-radius)",
|
|
335
|
-
backgroundColor: "var(--omnispec-bg-secondary)",
|
|
336
|
-
"&:hover": {
|
|
337
|
-
borderColor: "var(--omnispec-color-primary)"
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
const cardHeaderStyle = css({
|
|
341
|
-
display: "flex",
|
|
342
|
-
alignItems: "center",
|
|
343
|
-
gap: "8px",
|
|
344
|
-
marginBottom: "6px"
|
|
345
|
-
});
|
|
346
|
-
const serverNameStyle = css({
|
|
347
|
-
fontWeight: 600,
|
|
348
|
-
fontSize: "var(--omnispec-font-size-sm)",
|
|
349
|
-
color: "var(--omnispec-fg-primary)"
|
|
350
|
-
});
|
|
351
|
-
const urlStyle = css({
|
|
352
|
-
fontFamily: "var(--omnispec-font-mono)",
|
|
353
|
-
fontSize: "var(--omnispec-font-size-sm)",
|
|
354
|
-
color: "var(--omnispec-fg-code)",
|
|
355
|
-
display: "block",
|
|
356
|
-
marginBottom: "4px"
|
|
357
|
-
});
|
|
358
|
-
const descriptionStyle = css({
|
|
359
|
-
margin: "4px 0 0",
|
|
360
|
-
fontSize: "var(--omnispec-font-size-xs)",
|
|
361
|
-
color: "var(--omnispec-fg-secondary)"
|
|
362
|
-
});
|
|
363
|
-
const variablesStyle = css({
|
|
364
|
-
marginTop: "8px",
|
|
365
|
-
fontSize: "var(--omnispec-font-size-xs)"
|
|
366
|
-
});
|
|
367
|
-
const varRowStyle = css({
|
|
368
|
-
display: "flex",
|
|
369
|
-
gap: "6px",
|
|
370
|
-
marginBottom: "2px"
|
|
371
|
-
});
|
|
372
|
-
const varNameStyle = css({
|
|
373
|
-
fontFamily: "var(--omnispec-font-mono)",
|
|
374
|
-
color: "var(--omnispec-fg-primary)",
|
|
375
|
-
fontWeight: 600
|
|
376
|
-
});
|
|
377
|
-
const varDefaultStyle = css({
|
|
378
|
-
fontFamily: "var(--omnispec-font-mono)",
|
|
379
|
-
color: "var(--omnispec-fg-muted)"
|
|
380
|
-
});
|
|
381
|
-
const varDescStyle = css({
|
|
382
|
-
color: "var(--omnispec-fg-secondary)"
|
|
383
|
-
});
|
|
384
|
-
function ServerList({ servers }) {
|
|
385
|
-
if (servers.length === 0) return null;
|
|
386
|
-
return /* @__PURE__ */ jsxs("div", { className: cx("omnispec-async-servers", containerStyle$1), children: [
|
|
387
|
-
/* @__PURE__ */ jsx("h3", { className: titleStyle$1, children: "Servers" }),
|
|
388
|
-
/* @__PURE__ */ jsx("div", { className: gridStyle, children: servers.map((server) => /* @__PURE__ */ jsxs("div", { className: cardStyle, children: [
|
|
389
|
-
/* @__PURE__ */ jsxs("div", { className: cardHeaderStyle, children: [
|
|
390
|
-
/* @__PURE__ */ jsx("span", { className: serverNameStyle, children: server.name }),
|
|
391
|
-
/* @__PURE__ */ jsx(ProtocolBadge, { protocol: server.protocol, version: server.protocolVersion })
|
|
392
|
-
] }),
|
|
393
|
-
/* @__PURE__ */ jsx("code", { className: urlStyle, children: server.url }),
|
|
394
|
-
server.description && /* @__PURE__ */ jsx("p", { className: descriptionStyle, children: server.description }),
|
|
395
|
-
server.variables && Object.entries(server.variables).length > 0 && /* @__PURE__ */ jsx("div", { className: variablesStyle, children: Object.entries(server.variables).map(([name, variable]) => /* @__PURE__ */ jsxs("div", { className: varRowStyle, children: [
|
|
396
|
-
/* @__PURE__ */ jsx("code", { className: varNameStyle, children: name }),
|
|
397
|
-
variable.default && /* @__PURE__ */ jsxs("span", { className: varDefaultStyle, children: [
|
|
398
|
-
"= ",
|
|
399
|
-
variable.default
|
|
400
|
-
] }),
|
|
401
|
-
variable.description && /* @__PURE__ */ jsx("span", { className: varDescStyle, children: variable.description })
|
|
402
|
-
] }, name)) })
|
|
403
|
-
] }, server.name)) })
|
|
404
|
-
] });
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
const actionLabels = {
|
|
408
|
-
publish: "PUB",
|
|
409
|
-
subscribe: "SUB",
|
|
410
|
-
send: "SEND",
|
|
411
|
-
receive: "RECV"
|
|
412
|
-
};
|
|
413
|
-
const actionColors = {
|
|
414
|
-
publish: "var(--omnispec-color-publish)",
|
|
415
|
-
subscribe: "var(--omnispec-color-subscribe)",
|
|
416
|
-
send: "var(--omnispec-color-publish)",
|
|
417
|
-
receive: "var(--omnispec-color-subscribe)"
|
|
418
|
-
};
|
|
419
|
-
function ChannelDetail({ channel, id, expandAll, expandGeneration }) {
|
|
420
|
-
const primaryAction = channel.operations[0]?.action;
|
|
421
|
-
const primaryLabel = actionLabels[primaryAction] ?? primaryAction?.toUpperCase() ?? "";
|
|
422
|
-
const primaryColor = actionColors[primaryAction] ?? "var(--omnispec-fg-muted)";
|
|
423
|
-
return /* @__PURE__ */ jsxs(
|
|
424
|
-
ExpandableCard,
|
|
425
|
-
{
|
|
426
|
-
id,
|
|
427
|
-
title: channel.address,
|
|
428
|
-
rightLabel: `${channel.operations.length} ${channel.operations.length === 1 ? "operation" : "operations"}`,
|
|
429
|
-
expandAll,
|
|
430
|
-
expandGeneration,
|
|
431
|
-
children: [
|
|
432
|
-
/* @__PURE__ */ jsx(MethodBar, { label: primaryLabel, path: channel.address, color: primaryColor }),
|
|
433
|
-
/* @__PURE__ */ jsxs("div", { className: bodyStyle, children: [
|
|
434
|
-
channel.description && /* @__PURE__ */ jsx("div", { className: sectionStyle, children: /* @__PURE__ */ jsx(MarkdownRenderer, { content: channel.description }) }),
|
|
435
|
-
channel.parameters && Object.keys(channel.parameters).length > 0 && /* @__PURE__ */ jsxs("div", { className: sectionStyle, children: [
|
|
436
|
-
/* @__PURE__ */ jsx("h4", { className: sectionTitleStyle, children: "Parameters" }),
|
|
437
|
-
/* @__PURE__ */ jsx("div", { className: paramListStyle, children: Object.entries(channel.parameters).map(([name, param]) => {
|
|
438
|
-
const paramType = param.schema?.type;
|
|
439
|
-
return /* @__PURE__ */ jsxs("div", { className: paramRowStyle, children: [
|
|
440
|
-
/* @__PURE__ */ jsxs("div", { className: paramHeaderStyle, children: [
|
|
441
|
-
/* @__PURE__ */ jsx("span", { className: paramNameStyle, children: name }),
|
|
442
|
-
paramType && /* @__PURE__ */ jsx("pre", { className: typeBadgeStyle, children: paramType })
|
|
443
|
-
] }),
|
|
444
|
-
param.description && /* @__PURE__ */ jsx("p", { className: paramDescStyle, children: param.description })
|
|
445
|
-
] }, name);
|
|
446
|
-
}) })
|
|
447
|
-
] }),
|
|
448
|
-
channel.operations.map((op, idx) => /* @__PURE__ */ jsxs("div", { className: operationStyle, children: [
|
|
449
|
-
/* @__PURE__ */ jsxs("div", { className: opHeaderStyle, children: [
|
|
450
|
-
/* @__PURE__ */ jsx(
|
|
451
|
-
"span",
|
|
452
|
-
{
|
|
453
|
-
className: cx(actionBadgeBase, css({
|
|
454
|
-
backgroundColor: actionColors[op.action] ?? "var(--omnispec-fg-muted)"
|
|
455
|
-
})),
|
|
456
|
-
children: actionLabels[op.action] ?? op.action.toUpperCase()
|
|
457
|
-
}
|
|
458
|
-
),
|
|
459
|
-
op.operationId && /* @__PURE__ */ jsx("span", { className: opIdStyle, children: op.operationId }),
|
|
460
|
-
op.summary && /* @__PURE__ */ jsx("span", { className: opSummaryStyle, children: op.summary })
|
|
461
|
-
] }),
|
|
462
|
-
op.description && /* @__PURE__ */ jsx("div", { className: sectionStyle, children: /* @__PURE__ */ jsx(MarkdownRenderer, { content: op.description }) }),
|
|
463
|
-
op.message && /* @__PURE__ */ jsxs("div", { className: sectionStyle, children: [
|
|
464
|
-
/* @__PURE__ */ jsxs("h4", { className: sectionTitleStyle, children: [
|
|
465
|
-
"Message",
|
|
466
|
-
op.message.title && /* @__PURE__ */ jsxs("span", { className: messageTitleStyle, children: [
|
|
467
|
-
" \u2014 ",
|
|
468
|
-
op.message.title
|
|
469
|
-
] })
|
|
470
|
-
] }),
|
|
471
|
-
op.message.summary && /* @__PURE__ */ jsx("p", { className: messageSummaryStyle, children: op.message.summary }),
|
|
472
|
-
op.message.contentType && /* @__PURE__ */ jsx("code", { className: contentTypeStyle, children: op.message.contentType }),
|
|
473
|
-
op.message.payload && /* @__PURE__ */ jsx(
|
|
474
|
-
Tabs,
|
|
475
|
-
{
|
|
476
|
-
tabs: [
|
|
477
|
-
{
|
|
478
|
-
id: `schema-${idx}`,
|
|
479
|
-
label: "Payload Schema",
|
|
480
|
-
content: /* @__PURE__ */ jsx(SchemaTree, { nodes: schemaToNodes(op.message.payload) })
|
|
481
|
-
},
|
|
482
|
-
{
|
|
483
|
-
id: `example-${idx}`,
|
|
484
|
-
label: "Example",
|
|
485
|
-
content: /* @__PURE__ */ jsx(
|
|
486
|
-
CodeBlock,
|
|
487
|
-
{
|
|
488
|
-
code: JSON.stringify(generateExample(op.message.payload), null, 2),
|
|
489
|
-
language: "json"
|
|
490
|
-
}
|
|
491
|
-
)
|
|
492
|
-
}
|
|
493
|
-
]
|
|
494
|
-
}
|
|
495
|
-
),
|
|
496
|
-
op.message.headers && /* @__PURE__ */ jsxs("div", { className: headersWrapStyle, children: [
|
|
497
|
-
/* @__PURE__ */ jsx("h4", { className: sectionTitleStyle, children: "Headers" }),
|
|
498
|
-
/* @__PURE__ */ jsx(SchemaTree, { nodes: schemaToNodes(op.message.headers) })
|
|
499
|
-
] })
|
|
500
|
-
] })
|
|
501
|
-
] }, idx))
|
|
502
|
-
] })
|
|
503
|
-
]
|
|
504
|
-
}
|
|
505
|
-
);
|
|
506
|
-
}
|
|
507
|
-
const bodyStyle = css({
|
|
508
|
-
padding: "0.75rem 1rem",
|
|
509
|
-
[mq.desktop]: {
|
|
510
|
-
padding: "1rem 1.25rem"
|
|
511
|
-
}
|
|
512
|
-
});
|
|
513
|
-
const sectionStyle = css({
|
|
514
|
-
marginBottom: "24px"
|
|
515
|
-
});
|
|
516
|
-
const sectionTitleStyle = css({
|
|
517
|
-
margin: "0 0 12px",
|
|
518
|
-
fontSize: "var(--omnispec-font-size-md)",
|
|
519
|
-
fontWeight: 700,
|
|
520
|
-
color: "var(--omnispec-fg-primary)",
|
|
521
|
-
letterSpacing: "0.02em"
|
|
522
|
-
});
|
|
523
|
-
const paramListStyle = css({
|
|
524
|
-
display: "flex",
|
|
525
|
-
flexDirection: "column"
|
|
526
|
-
});
|
|
527
|
-
const paramRowStyle = css({
|
|
528
|
-
padding: "12px 0"
|
|
529
|
-
});
|
|
530
|
-
const paramHeaderStyle = css({
|
|
531
|
-
display: "flex",
|
|
532
|
-
alignItems: "center",
|
|
533
|
-
gap: "8px",
|
|
534
|
-
flexWrap: "wrap"
|
|
535
|
-
});
|
|
536
|
-
const paramNameStyle = css({
|
|
537
|
-
fontSize: "var(--omnispec-font-size-sm)",
|
|
538
|
-
fontWeight: 700,
|
|
539
|
-
backgroundColor: "transparent",
|
|
540
|
-
padding: 0
|
|
541
|
-
});
|
|
542
|
-
const typeBadgeStyle = css({
|
|
543
|
-
fontSize: "var(--omnispec-font-size-xs)",
|
|
544
|
-
fontWeight: 400
|
|
545
|
-
});
|
|
546
|
-
const paramDescStyle = css({
|
|
547
|
-
margin: "4px 0 0",
|
|
548
|
-
fontSize: "var(--omnispec-font-size-base)",
|
|
549
|
-
color: "var(--omnispec-fg-secondary)",
|
|
550
|
-
lineHeight: 1.5
|
|
551
|
-
});
|
|
552
|
-
const operationStyle = css({
|
|
553
|
-
padding: "12px 0",
|
|
554
|
-
borderTop: "1px solid var(--omnispec-border-color)"
|
|
555
|
-
});
|
|
556
|
-
const opHeaderStyle = css({
|
|
557
|
-
display: "flex",
|
|
558
|
-
alignItems: "center",
|
|
559
|
-
gap: "8px",
|
|
560
|
-
marginBottom: "8px"
|
|
561
|
-
});
|
|
562
|
-
const actionBadgeBase = css({
|
|
563
|
-
display: "inline-block",
|
|
564
|
-
padding: "2px 6px",
|
|
565
|
-
borderRadius: "3px",
|
|
566
|
-
fontSize: "9px",
|
|
567
|
-
fontWeight: 700,
|
|
568
|
-
fontFamily: "var(--omnispec-font-mono)",
|
|
569
|
-
color: "#ffffff",
|
|
570
|
-
letterSpacing: "0.5px"
|
|
571
|
-
});
|
|
572
|
-
const opIdStyle = css({
|
|
573
|
-
fontSize: "var(--omnispec-font-size-sm)",
|
|
574
|
-
fontWeight: 700,
|
|
575
|
-
backgroundColor: "transparent",
|
|
576
|
-
padding: 0
|
|
577
|
-
});
|
|
578
|
-
const opSummaryStyle = css({
|
|
579
|
-
fontSize: "var(--omnispec-font-size-sm)",
|
|
580
|
-
color: "var(--omnispec-fg-secondary)"
|
|
581
|
-
});
|
|
582
|
-
const messageTitleStyle = css({
|
|
583
|
-
fontWeight: 400,
|
|
584
|
-
color: "var(--omnispec-fg-primary)"
|
|
585
|
-
});
|
|
586
|
-
const messageSummaryStyle = css({
|
|
587
|
-
margin: "0 0 8px",
|
|
588
|
-
fontSize: "var(--omnispec-font-size-base)",
|
|
589
|
-
color: "var(--omnispec-fg-secondary)"
|
|
590
|
-
});
|
|
591
|
-
const contentTypeStyle = css({
|
|
592
|
-
fontFamily: "var(--omnispec-font-mono)",
|
|
593
|
-
fontSize: "var(--omnispec-font-size-xs)",
|
|
594
|
-
color: "var(--omnispec-fg-muted)",
|
|
595
|
-
display: "block",
|
|
596
|
-
marginBottom: "8px",
|
|
597
|
-
backgroundColor: "transparent",
|
|
598
|
-
padding: 0
|
|
599
|
-
});
|
|
600
|
-
const headersWrapStyle = css({
|
|
601
|
-
marginTop: "16px"
|
|
602
|
-
});
|
|
603
|
-
|
|
604
|
-
function ComponentsSection({ components }) {
|
|
605
|
-
const schemas = Object.entries(components.schemas);
|
|
606
|
-
if (schemas.length === 0) return null;
|
|
607
|
-
return /* @__PURE__ */ jsxs("div", { className: `omnispec-async-components ${containerStyle}`, id: "schemas", children: [
|
|
608
|
-
/* @__PURE__ */ jsx("h2", { className: titleStyle, children: "Schemas" }),
|
|
609
|
-
/* @__PURE__ */ jsx("div", { className: schemaWrapperStyle, children: schemas.map(([name, schema]) => /* @__PURE__ */ jsx("div", { className: schemaStyle, id: `schema-${name}`, children: /* @__PURE__ */ jsx(
|
|
610
|
-
Collapsible,
|
|
611
|
-
{
|
|
612
|
-
title: /* @__PURE__ */ jsx("code", { className: schemaNameStyle, children: name }),
|
|
613
|
-
defaultOpen: false,
|
|
614
|
-
children: /* @__PURE__ */ jsx(SchemaTree, { nodes: schemaToNodes(schema) })
|
|
615
|
-
}
|
|
616
|
-
) }, name)) })
|
|
617
|
-
] });
|
|
618
|
-
}
|
|
619
|
-
const containerStyle = css({
|
|
620
|
-
marginTop: "2rem",
|
|
621
|
-
paddingTop: "1.5rem",
|
|
622
|
-
borderTop: "1px solid var(--omnispec-border-color)",
|
|
623
|
-
[mq.mobile]: {
|
|
624
|
-
borderTop: "none",
|
|
625
|
-
marginTop: "1.5rem",
|
|
626
|
-
paddingTop: "1rem"
|
|
627
|
-
}
|
|
628
|
-
});
|
|
629
|
-
const titleStyle = css({
|
|
630
|
-
margin: "0 0 16px",
|
|
631
|
-
fontSize: "var(--omnispec-h2-font-size)",
|
|
632
|
-
color: "var(--omnispec-h2-color)",
|
|
633
|
-
fontWeight: 700
|
|
634
|
-
});
|
|
635
|
-
const schemaWrapperStyle = css({
|
|
636
|
-
border: "1px solid var(--omnispec-border-color)",
|
|
637
|
-
borderRadius: "8px",
|
|
638
|
-
padding: "1.5rem 1rem"
|
|
639
|
-
});
|
|
640
|
-
const schemaStyle = css({
|
|
641
|
-
marginBottom: "8px"
|
|
642
|
-
});
|
|
643
|
-
const schemaNameStyle = css({
|
|
644
|
-
fontFamily: "var(--omnispec-font-mono)",
|
|
645
|
-
fontSize: "var(--omnispec-font-size-base)",
|
|
646
|
-
fontWeight: 600,
|
|
647
|
-
color: "var(--omnispec-color-primary)",
|
|
648
|
-
backgroundColor: "transparent",
|
|
649
|
-
padding: 0,
|
|
650
|
-
"&:hover": {
|
|
651
|
-
textDecoration: "underline"
|
|
652
|
-
}
|
|
653
|
-
});
|
|
654
|
-
|
|
655
|
-
function AsyncApiSpec({
|
|
656
|
-
spec,
|
|
657
|
-
theme,
|
|
658
|
-
layout = "sidebar",
|
|
659
|
-
sidebarPosition = "left",
|
|
660
|
-
defaultExpandOperations = false,
|
|
661
|
-
downloadLink,
|
|
662
|
-
sidebarNav,
|
|
663
|
-
slots = {},
|
|
664
|
-
schemaStyle,
|
|
665
|
-
pro,
|
|
666
|
-
onSpecLoaded,
|
|
667
|
-
className
|
|
668
|
-
}) {
|
|
669
|
-
const resolvedSchemaStyle = resolveSchemaStyle(schemaStyle, pro?.advancedSchemaStyles ?? false);
|
|
670
|
-
const { data: parsedSpec, state } = useAsyncApiSpec(spec);
|
|
671
|
-
const [searchQuery, setSearchQuery] = useState("");
|
|
672
|
-
const [allExpanded, setAllExpanded] = useState(defaultExpandOperations);
|
|
673
|
-
const [expandGeneration, setExpandGeneration] = useState(0);
|
|
674
|
-
const handleToggleExpand = useCallback(() => {
|
|
675
|
-
setAllExpanded((prev) => !prev);
|
|
676
|
-
setExpandGeneration((prev) => prev + 1);
|
|
677
|
-
}, []);
|
|
678
|
-
useMemo(() => {
|
|
679
|
-
if (parsedSpec && onSpecLoaded) {
|
|
680
|
-
const major = parseInt(parsedSpec.specVersion.split(".")[0], 10);
|
|
681
|
-
onSpecLoaded({
|
|
682
|
-
title: parsedSpec.title,
|
|
683
|
-
version: parsedSpec.version,
|
|
684
|
-
type: major >= 3 ? SpecType.ASYNCAPI_3 : SpecType.ASYNCAPI_2
|
|
685
|
-
});
|
|
686
|
-
}
|
|
687
|
-
}, [parsedSpec, onSpecLoaded]);
|
|
688
|
-
const navItems = useMemo(() => {
|
|
689
|
-
if (!parsedSpec) return [];
|
|
690
|
-
const channelItems = parsedSpec.channels.map((ch) => {
|
|
691
|
-
const actionLabels = ch.operations.map(
|
|
692
|
-
(op) => op.action.toUpperCase()
|
|
693
|
-
).join("/");
|
|
694
|
-
return {
|
|
695
|
-
id: `channel-${ch.name}`,
|
|
696
|
-
label: ch.address,
|
|
697
|
-
badge: actionLabels || void 0,
|
|
698
|
-
badgeColor: ch.operations[0]?.action === "subscribe" || ch.operations[0]?.action === "receive" ? "var(--omnispec-color-subscribe)" : "var(--omnispec-color-publish)"
|
|
699
|
-
};
|
|
700
|
-
});
|
|
701
|
-
const items = [];
|
|
702
|
-
if (parsedSpec.servers.length > 0) {
|
|
703
|
-
items.push({ id: "servers", label: "Servers" });
|
|
704
|
-
}
|
|
705
|
-
items.push({
|
|
706
|
-
id: "channels",
|
|
707
|
-
label: "Channels",
|
|
708
|
-
children: channelItems
|
|
709
|
-
});
|
|
710
|
-
if (Object.keys(parsedSpec.components.schemas).length > 0) {
|
|
711
|
-
items.push({
|
|
712
|
-
id: "schemas",
|
|
713
|
-
label: "Schemas",
|
|
714
|
-
children: Object.keys(parsedSpec.components.schemas).map((name) => ({
|
|
715
|
-
id: `schema-${name}`,
|
|
716
|
-
label: name
|
|
717
|
-
}))
|
|
718
|
-
});
|
|
719
|
-
}
|
|
720
|
-
return items;
|
|
721
|
-
}, [parsedSpec]);
|
|
722
|
-
const filteredChannels = useMemo(() => {
|
|
723
|
-
if (!parsedSpec || !searchQuery.trim()) return parsedSpec?.channels ?? [];
|
|
724
|
-
const q = searchQuery.toLowerCase();
|
|
725
|
-
return parsedSpec.channels.filter(
|
|
726
|
-
(ch) => ch.address.toLowerCase().includes(q) || ch.description?.toLowerCase().includes(q) || ch.operations.some(
|
|
727
|
-
(op) => op.operationId?.toLowerCase().includes(q) || op.summary?.toLowerCase().includes(q)
|
|
728
|
-
)
|
|
729
|
-
);
|
|
730
|
-
}, [parsedSpec, searchQuery]);
|
|
731
|
-
const handleNavSelect = useCallback((id) => {
|
|
732
|
-
const el = document.getElementById(id);
|
|
733
|
-
el?.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
734
|
-
}, []);
|
|
735
|
-
const navSectionIds = useMemo(() => flattenNavItemIds(navItems), [navItems]);
|
|
736
|
-
const activeSection = useScrollSpy(navSectionIds);
|
|
737
|
-
if (state.status === "loading") {
|
|
738
|
-
return /* @__PURE__ */ jsx(ThemeProvider, { theme, children: /* @__PURE__ */ jsx("div", { className: `omnispec-asyncapi ${className ?? ""}`, children: /* @__PURE__ */ jsx(LoadingScreen, {}) }) });
|
|
739
|
-
}
|
|
740
|
-
if (state.status === "error") {
|
|
741
|
-
return /* @__PURE__ */ jsx(
|
|
742
|
-
SpecStatusScreen,
|
|
743
|
-
{
|
|
744
|
-
theme,
|
|
745
|
-
layout,
|
|
746
|
-
sidebarPosition,
|
|
747
|
-
slots,
|
|
748
|
-
sidebarNav,
|
|
749
|
-
premiumThemingEnabled: pro?.premiumThemingEnabled ?? false,
|
|
750
|
-
className: `omnispec-asyncapi ${className ?? ""}`,
|
|
751
|
-
children: /* @__PURE__ */ jsx(ErrorMessage, { title: "Failed to load specification", message: state.error })
|
|
752
|
-
}
|
|
753
|
-
);
|
|
754
|
-
}
|
|
755
|
-
if (!parsedSpec) return null;
|
|
756
|
-
const specNav = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
757
|
-
/* @__PURE__ */ jsx(
|
|
758
|
-
SearchBar,
|
|
759
|
-
{
|
|
760
|
-
placeholder: "Filter channels...",
|
|
761
|
-
onSearch: setSearchQuery
|
|
762
|
-
}
|
|
763
|
-
),
|
|
764
|
-
/* @__PURE__ */ jsx(
|
|
765
|
-
NavTree,
|
|
766
|
-
{
|
|
767
|
-
items: navItems,
|
|
768
|
-
activeId: activeSection,
|
|
769
|
-
onSelect: handleNavSelect
|
|
770
|
-
}
|
|
771
|
-
)
|
|
772
|
-
] });
|
|
773
|
-
const sidebar = buildSidebar(sidebarNav, specNav);
|
|
774
|
-
const resolvedDownloadLink = resolveDownloadLink(downloadLink, spec);
|
|
775
|
-
return /* @__PURE__ */ jsx(ConfigProvider, { config: { allowTryIt: false, layout, sidebarPosition, defaultExpandOperations, schemaStyle: resolvedSchemaStyle, slots, proRenderers: pro?.renderers ?? /* @__PURE__ */ new Map(), premiumThemingEnabled: pro?.premiumThemingEnabled ?? false }, children: /* @__PURE__ */ jsx(ExpandProvider, { expandAll: allExpanded, expandGeneration, children: /* @__PURE__ */ jsx(ThemeProvider, { theme, children: /* @__PURE__ */ jsx("div", { className: `omnispec-asyncapi ${className ?? ""}`, children: /* @__PURE__ */ jsx(ErrorBoundary, { title: "Failed to render this API reference", children: /* @__PURE__ */ jsxs(
|
|
776
|
-
DocLayout,
|
|
777
|
-
{
|
|
778
|
-
layout,
|
|
779
|
-
sidebarPosition,
|
|
780
|
-
sidebar,
|
|
781
|
-
sidebarHeader: slots.sidebarHeader,
|
|
782
|
-
sidebarFooter: slots.sidebarFooter,
|
|
783
|
-
header: slots.header,
|
|
784
|
-
footer: slots.footer,
|
|
785
|
-
children: [
|
|
786
|
-
/* @__PURE__ */ jsx(
|
|
787
|
-
SpecToolbar,
|
|
788
|
-
{
|
|
789
|
-
overview: /* @__PURE__ */ jsx(AsyncOverview, { spec: parsedSpec }),
|
|
790
|
-
expandLabel: "channels",
|
|
791
|
-
allExpanded,
|
|
792
|
-
onToggleExpand: handleToggleExpand,
|
|
793
|
-
downloadLink: resolvedDownloadLink
|
|
794
|
-
}
|
|
795
|
-
),
|
|
796
|
-
/* @__PURE__ */ jsx("div", { id: "servers", children: /* @__PURE__ */ jsx(ServerList, { servers: parsedSpec.servers }) }),
|
|
797
|
-
/* @__PURE__ */ jsxs("div", { id: "channels", children: [
|
|
798
|
-
/* @__PURE__ */ jsx("h2", { className: css({ margin: "0 0 16px", fontSize: "var(--omnispec-h2-font-size)", fontWeight: "var(--omnispec-h2-font-weight)", color: "var(--omnispec-h2-color)" }), children: "Channels" }),
|
|
799
|
-
filteredChannels.map((channel) => /* @__PURE__ */ jsx(
|
|
800
|
-
ChannelDetail,
|
|
801
|
-
{
|
|
802
|
-
id: `channel-${channel.name}`,
|
|
803
|
-
channel,
|
|
804
|
-
expandAll: allExpanded,
|
|
805
|
-
expandGeneration
|
|
806
|
-
},
|
|
807
|
-
channel.name
|
|
808
|
-
))
|
|
809
|
-
] }),
|
|
810
|
-
/* @__PURE__ */ jsx(ComponentsSection, { components: parsedSpec.components })
|
|
811
|
-
]
|
|
812
|
-
}
|
|
813
|
-
) }) }) }) }) });
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
export { AsyncApiSpec };
|
|
817
|
-
//# sourceMappingURL=AsyncApiSpec-C3lsUpZk.js.map
|