schema-components 1.21.0 → 1.23.0
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 +3 -1
- package/dist/core/adapter.d.mts +115 -4
- package/dist/core/adapter.mjs +405 -75
- package/dist/core/constraints.d.mts +2 -2
- package/dist/core/constraints.mjs +0 -7
- package/dist/core/cssClasses.d.mts +52 -0
- package/dist/core/cssClasses.mjs +51 -0
- package/dist/core/diagnostics.d.mts +1 -1
- package/dist/core/errors.d.mts +1 -1
- package/dist/core/errors.mjs +5 -13
- package/dist/core/fieldOrder.d.mts +1 -1
- package/dist/core/formats.d.mts +30 -2
- package/dist/core/formats.mjs +33 -1
- package/dist/core/idPath.d.mts +54 -0
- package/dist/core/idPath.mjs +66 -0
- package/dist/core/limits.d.mts +2 -0
- package/dist/core/limits.mjs +23 -0
- package/dist/core/merge.d.mts +10 -1
- package/dist/core/merge.mjs +49 -10
- package/dist/core/normalise.d.mts +40 -3
- package/dist/core/normalise.mjs +2 -2
- package/dist/core/openapi30.d.mts +15 -1
- package/dist/core/openapi30.mjs +2 -2
- package/dist/core/openapiConstants.d.mts +67 -0
- package/dist/core/openapiConstants.mjs +90 -0
- package/dist/core/ref.d.mts +2 -2
- package/dist/core/ref.mjs +85 -6
- package/dist/core/refChain.d.mts +70 -0
- package/dist/core/refChain.mjs +44 -0
- package/dist/core/renderer.d.mts +1 -1
- package/dist/core/renderer.mjs +0 -2
- package/dist/core/swagger2.d.mts +1 -1
- package/dist/core/swagger2.mjs +1 -1
- package/dist/core/typeInference.d.mts +982 -2
- package/dist/core/types.d.mts +2 -2
- package/dist/core/types.mjs +1 -4
- package/dist/core/unionMatch.d.mts +36 -0
- package/dist/core/unionMatch.mjs +53 -0
- package/dist/core/version.d.mts +1 -1
- package/dist/core/version.mjs +29 -17
- package/dist/core/walkBuilders.d.mts +23 -4
- package/dist/core/walkBuilders.mjs +27 -7
- package/dist/core/walker.d.mts +1 -1
- package/dist/core/walker.mjs +123 -47
- package/dist/{diagnostics-CbBPsxSt.d.mts → diagnostics-BS2kaUyE.d.mts} +1 -1
- package/dist/{errors-QEwOtQAA.d.mts → errors-g_MCTQel.d.mts} +10 -16
- package/dist/html/a11y.d.mts +9 -4
- package/dist/html/a11y.mjs +10 -12
- package/dist/html/renderToHtml.d.mts +10 -3
- package/dist/html/renderToHtml.mjs +13 -3
- package/dist/html/renderToHtmlStream.d.mts +2 -2
- package/dist/html/renderToHtmlStream.mjs +12 -1
- package/dist/html/renderers.d.mts +43 -8
- package/dist/html/renderers.mjs +136 -116
- package/dist/html/streamRenderers.d.mts +6 -6
- package/dist/html/streamRenderers.mjs +129 -89
- package/dist/limits-Cw5QZND8.d.mts +29 -0
- package/dist/{normalise-DaSrnr8g.mjs → normalise-DCYp06Sr.mjs} +770 -227
- package/dist/openapi/ApiCallbacks.d.mts +1 -1
- package/dist/openapi/ApiLinks.d.mts +1 -1
- package/dist/openapi/ApiResponseHeaders.d.mts +1 -1
- package/dist/openapi/ApiSecurity.d.mts +1 -1
- package/dist/openapi/ApiSecurity.mjs +16 -2
- package/dist/openapi/components.d.mts +234 -23
- package/dist/openapi/components.mjs +183 -52
- package/dist/openapi/parser.d.mts +9 -8
- package/dist/openapi/parser.mjs +252 -70
- package/dist/openapi/resolve.d.mts +31 -15
- package/dist/openapi/resolve.mjs +260 -40
- package/dist/react/SchemaComponent.d.mts +126 -36
- package/dist/react/SchemaComponent.mjs +95 -57
- package/dist/react/SchemaView.d.mts +30 -10
- package/dist/react/SchemaView.mjs +2 -2
- package/dist/react/a11y.d.mts +21 -0
- package/dist/react/a11y.mjs +24 -0
- package/dist/react/fieldPath.d.mts +1 -1
- package/dist/react/headless.d.mts +1 -1
- package/dist/react/headless.mjs +1 -2
- package/dist/react/headlessRenderers.d.mts +9 -11
- package/dist/react/headlessRenderers.mjs +51 -102
- package/dist/{ref-si8ViYun.d.mts → ref-DjLEKa_E.d.mts} +38 -3
- package/dist/{renderer-DI6ZYf7a.d.mts → renderer-CXJ8y0qw.d.mts} +2 -2
- package/dist/themes/mantine.d.mts +1 -1
- package/dist/themes/mui.d.mts +1 -1
- package/dist/themes/radix.d.mts +1 -1
- package/dist/themes/shadcn.d.mts +1 -1
- package/dist/themes/shadcn.mjs +2 -1
- package/dist/{types-BnxPEElk.d.mts → types-BTB73MB8.d.mts} +35 -14
- package/dist/{version-D-u7aMfy.d.mts → version-BFTVLsdb.d.mts} +7 -1
- package/package.json +1 -3
- package/dist/typeInference-Bxw3NOG1.d.mts +0 -647
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { isObject, toRecordOrUndefined } from "../core/guards.mjs";
|
|
2
|
+
import { emitDiagnostic } from "../core/diagnostics.mjs";
|
|
3
|
+
import { extractRootMetaFromJson } from "../core/adapter.mjs";
|
|
2
4
|
import { walk } from "../core/walker.mjs";
|
|
3
5
|
import { ApiCallbacks } from "./ApiCallbacks.mjs";
|
|
4
6
|
import { ApiLinks } from "./ApiLinks.mjs";
|
|
5
7
|
import { ApiResponseHeaders } from "./ApiResponseHeaders.mjs";
|
|
6
8
|
import { ApiSecurity } from "./ApiSecurity.mjs";
|
|
7
|
-
import { getLinks, getSecurityRequirements, getSecuritySchemes, listCallbacks } from "./parser.mjs";
|
|
9
|
+
import { getExternalDocs, getLinks, getSecurityRequirements, getSecuritySchemes, getXmlInfo, listCallbacks, listWebhooks } from "./parser.mjs";
|
|
8
10
|
import { joinPath, renderField, sanitisePrefix } from "../react/SchemaComponent.mjs";
|
|
9
11
|
import { getParsed, resolveOperationFromParsed, resolveParametersFromParsed, resolveRequestBodyFromParsed, resolveResponseFromParsed, toDoc } from "./resolve.mjs";
|
|
10
12
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -30,10 +32,29 @@ function buildDiagnostics(onDiagnostic, strict) {
|
|
|
30
32
|
if (strict === true) opts.strict = true;
|
|
31
33
|
return opts;
|
|
32
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Coerce an `unknown` `schema` prop to a document record. Returns
|
|
37
|
+
* `undefined` when the prop is not a plain object, surfacing a
|
|
38
|
+
* `doc-not-object` diagnostic so silent "empty document" misbehaviour
|
|
39
|
+
* (the historic `toDoc` `{}` fallback) is impossible.
|
|
40
|
+
*
|
|
41
|
+
* Components MUST short-circuit when this returns `undefined` rather
|
|
42
|
+
* than rendering empty operation lists.
|
|
43
|
+
*/
|
|
44
|
+
function resolveRootDoc(doc, diagnostics) {
|
|
45
|
+
const resolved = toDoc(doc);
|
|
46
|
+
if (resolved === void 0) emitDiagnostic(diagnostics, {
|
|
47
|
+
code: "doc-not-object",
|
|
48
|
+
message: "OpenAPI document prop is not a plain object; nothing to render",
|
|
49
|
+
pointer: "",
|
|
50
|
+
detail: { received: typeof doc }
|
|
51
|
+
});
|
|
52
|
+
return resolved;
|
|
53
|
+
}
|
|
33
54
|
function noop() {}
|
|
34
55
|
function renderSchema(schema, rootDocument, options) {
|
|
35
56
|
if (!isObject(schema)) throw new Error("renderSchema received a non-object schema from the resolver.");
|
|
36
|
-
const rootMeta =
|
|
57
|
+
const rootMeta = extractRootMetaFromJson(schema);
|
|
37
58
|
const componentMeta = {};
|
|
38
59
|
if (options.readOnly === true) componentMeta.readOnly = true;
|
|
39
60
|
if (options.meta !== void 0) for (const [k, v] of Object.entries(options.meta)) componentMeta[k] = v;
|
|
@@ -49,14 +70,55 @@ function renderSchema(schema, rootDocument, options) {
|
|
|
49
70
|
};
|
|
50
71
|
return renderField(tree, options.value, options.onChange ?? noop, void 0, makeRenderChild(options.rootPath), options.rootPath, options.widgets);
|
|
51
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Render a Schema Object or Operation Object's `externalDocs` as a
|
|
75
|
+
* simple anchor with optional descriptive text. Returns `null` when no
|
|
76
|
+
* externalDocs are attached so callers can drop it into JSX without an
|
|
77
|
+
* extra guard.
|
|
78
|
+
*/
|
|
79
|
+
function ExternalDocsLink({ externalDocs }) {
|
|
80
|
+
if (externalDocs === void 0) return null;
|
|
81
|
+
return /* @__PURE__ */ jsx("p", {
|
|
82
|
+
"data-external-docs": true,
|
|
83
|
+
children: /* @__PURE__ */ jsx("a", {
|
|
84
|
+
href: externalDocs.url,
|
|
85
|
+
children: externalDocs.description ?? externalDocs.url
|
|
86
|
+
})
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Render a Schema Object's `xml` metadata as a footnote. The library
|
|
91
|
+
* does not render XML payloads natively, but the metadata still
|
|
92
|
+
* carries author intent (namespaces, element names, wrapping rules).
|
|
93
|
+
* Surface it so consumers can audit the dropped feature without
|
|
94
|
+
* losing the underlying information.
|
|
95
|
+
*/
|
|
96
|
+
function SchemaXmlFootnote({ xml }) {
|
|
97
|
+
if (xml === void 0) return null;
|
|
98
|
+
return /* @__PURE__ */ jsx("aside", {
|
|
99
|
+
"data-schema-xml": true,
|
|
100
|
+
children: /* @__PURE__ */ jsxs("small", { children: [
|
|
101
|
+
"XML representation",
|
|
102
|
+
xml.name !== void 0 && ` — name: ${xml.name}`,
|
|
103
|
+
xml.namespace !== void 0 && ` — namespace: ${xml.namespace}`,
|
|
104
|
+
xml.prefix !== void 0 && ` — prefix: ${xml.prefix}`,
|
|
105
|
+
xml.attribute && " — attribute",
|
|
106
|
+
xml.wrapped && " — wrapped"
|
|
107
|
+
] })
|
|
108
|
+
});
|
|
109
|
+
}
|
|
52
110
|
function ApiOperation({ schema: doc, path, method, requestBodyValue, onRequestBodyChange, responseValue, meta, requestBodyFields, widgets, onDiagnostic, strict }) {
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
111
|
+
const diagnostics = buildDiagnostics(onDiagnostic, strict);
|
|
112
|
+
const instancePrefix = sanitisePrefix(useId());
|
|
113
|
+
const rootDoc = resolveRootDoc(doc, diagnostics);
|
|
114
|
+
if (rootDoc === void 0) return null;
|
|
115
|
+
const parsed = getParsed(rootDoc, diagnostics);
|
|
116
|
+
const resolved = resolveOperationFromParsed(parsed, path, method, diagnostics);
|
|
56
117
|
const securityReqs = getSecurityRequirements(parsed, path, method);
|
|
57
118
|
const securitySchemes = getSecuritySchemes(parsed);
|
|
58
119
|
const callbacks = listCallbacks(parsed, path, method);
|
|
59
|
-
const
|
|
120
|
+
const operationExternalDocs = getExternalDocs(resolved.operation.operation);
|
|
121
|
+
const requestBodyXml = resolved.requestBody?.schema !== void 0 ? getXmlInfo(resolved.requestBody.schema) : void 0;
|
|
60
122
|
return /* @__PURE__ */ jsxs("section", {
|
|
61
123
|
"data-operation": `${method.toUpperCase()} ${path}`,
|
|
62
124
|
children: [
|
|
@@ -64,6 +126,7 @@ function ApiOperation({ schema: doc, path, method, requestBodyValue, onRequestBo
|
|
|
64
126
|
operation: resolved.operation,
|
|
65
127
|
pathItem: resolved.pathItem
|
|
66
128
|
}),
|
|
129
|
+
/* @__PURE__ */ jsx(ExternalDocsLink, { externalDocs: operationExternalDocs }),
|
|
67
130
|
/* @__PURE__ */ jsx(ApiSecurity, {
|
|
68
131
|
requirements: securityReqs,
|
|
69
132
|
schemes: securitySchemes
|
|
@@ -76,7 +139,9 @@ function ApiOperation({ schema: doc, path, method, requestBodyValue, onRequestBo
|
|
|
76
139
|
rootDoc,
|
|
77
140
|
meta,
|
|
78
141
|
widgets,
|
|
79
|
-
idPrefix: joinPath(instancePrefix, "params")
|
|
142
|
+
idPrefix: joinPath(instancePrefix, "params"),
|
|
143
|
+
diagnostics,
|
|
144
|
+
pointerPrefix: operationPointer(path, method)
|
|
80
145
|
})]
|
|
81
146
|
}),
|
|
82
147
|
resolved.requestBody?.schema !== void 0 && /* @__PURE__ */ jsxs("section", {
|
|
@@ -98,7 +163,8 @@ function ApiOperation({ schema: doc, path, method, requestBodyValue, onRequestBo
|
|
|
98
163
|
meta,
|
|
99
164
|
widgets,
|
|
100
165
|
rootPath: joinPath(instancePrefix, "requestBody")
|
|
101
|
-
})
|
|
166
|
+
}),
|
|
167
|
+
/* @__PURE__ */ jsx(SchemaXmlFootnote, { xml: requestBodyXml })
|
|
102
168
|
]
|
|
103
169
|
}),
|
|
104
170
|
resolved.responses.length > 0 && /* @__PURE__ */ jsxs("section", {
|
|
@@ -119,9 +185,11 @@ function ApiOperation({ schema: doc, path, method, requestBodyValue, onRequestBo
|
|
|
119
185
|
});
|
|
120
186
|
}
|
|
121
187
|
function ApiParameters({ schema: doc, path, method, meta, overrides, widgets, onDiagnostic, strict }) {
|
|
122
|
-
const
|
|
123
|
-
const params = resolveParametersFromParsed(getParsed(rootDoc, buildDiagnostics(onDiagnostic, strict)), path, method);
|
|
188
|
+
const diagnostics = buildDiagnostics(onDiagnostic, strict);
|
|
124
189
|
const instancePrefix = sanitisePrefix(useId());
|
|
190
|
+
const rootDoc = resolveRootDoc(doc, diagnostics);
|
|
191
|
+
if (rootDoc === void 0) return null;
|
|
192
|
+
const params = resolveParametersFromParsed(getParsed(rootDoc, diagnostics), path, method);
|
|
125
193
|
if (params.length === 0) return null;
|
|
126
194
|
return /* @__PURE__ */ jsxs("section", {
|
|
127
195
|
"data-parameters": true,
|
|
@@ -131,15 +199,20 @@ function ApiParameters({ schema: doc, path, method, meta, overrides, widgets, on
|
|
|
131
199
|
overrides,
|
|
132
200
|
meta,
|
|
133
201
|
widgets,
|
|
134
|
-
idPrefix: instancePrefix
|
|
202
|
+
idPrefix: instancePrefix,
|
|
203
|
+
diagnostics,
|
|
204
|
+
pointerPrefix: operationPointer(path, method)
|
|
135
205
|
})]
|
|
136
206
|
});
|
|
137
207
|
}
|
|
138
208
|
function ApiRequestBody({ schema: doc, path, method, value, onChange, meta, fields, widgets, onDiagnostic, strict }) {
|
|
139
|
-
const
|
|
140
|
-
const requestBody = resolveRequestBodyFromParsed(getParsed(rootDoc, buildDiagnostics(onDiagnostic, strict)), path, method);
|
|
209
|
+
const diagnostics = buildDiagnostics(onDiagnostic, strict);
|
|
141
210
|
const instancePrefix = sanitisePrefix(useId());
|
|
211
|
+
const rootDoc = resolveRootDoc(doc, diagnostics);
|
|
212
|
+
if (rootDoc === void 0) return null;
|
|
213
|
+
const requestBody = resolveRequestBodyFromParsed(getParsed(rootDoc, diagnostics), path, method);
|
|
142
214
|
if (requestBody?.schema === void 0) return null;
|
|
215
|
+
const requestBodyXml = getXmlInfo(requestBody.schema);
|
|
143
216
|
return /* @__PURE__ */ jsxs("section", {
|
|
144
217
|
"data-request-body": true,
|
|
145
218
|
children: [
|
|
@@ -159,15 +232,18 @@ function ApiRequestBody({ schema: doc, path, method, value, onChange, meta, fiel
|
|
|
159
232
|
meta,
|
|
160
233
|
widgets,
|
|
161
234
|
rootPath: instancePrefix
|
|
162
|
-
})
|
|
235
|
+
}),
|
|
236
|
+
/* @__PURE__ */ jsx(SchemaXmlFootnote, { xml: requestBodyXml })
|
|
163
237
|
]
|
|
164
238
|
});
|
|
165
239
|
}
|
|
166
240
|
function ApiResponse({ schema: doc, path, method, status, value, meta, fields, widgets, onDiagnostic, strict }) {
|
|
167
|
-
const
|
|
168
|
-
const parsed = getParsed(rootDoc, buildDiagnostics(onDiagnostic, strict));
|
|
169
|
-
const response = resolveResponseFromParsed(parsed, path, method, status);
|
|
241
|
+
const diagnostics = buildDiagnostics(onDiagnostic, strict);
|
|
170
242
|
const instancePrefix = sanitisePrefix(useId());
|
|
243
|
+
const rootDoc = resolveRootDoc(doc, diagnostics);
|
|
244
|
+
if (rootDoc === void 0) return null;
|
|
245
|
+
const parsed = getParsed(rootDoc, diagnostics);
|
|
246
|
+
const response = resolveResponseFromParsed(parsed, path, method, status);
|
|
171
247
|
if (response.schema === void 0) return /* @__PURE__ */ jsxs("div", {
|
|
172
248
|
"data-status": status,
|
|
173
249
|
children: [
|
|
@@ -189,6 +265,49 @@ function ApiResponse({ schema: doc, path, method, status, value, meta, fields, w
|
|
|
189
265
|
idPrefix: instancePrefix
|
|
190
266
|
});
|
|
191
267
|
}
|
|
268
|
+
function ApiWebhook({ schema: doc, name, widgets, meta, onDiagnostic, strict }) {
|
|
269
|
+
const diagnostics = buildDiagnostics(onDiagnostic, strict);
|
|
270
|
+
const instancePrefix = sanitisePrefix(useId());
|
|
271
|
+
const rootDoc = resolveRootDoc(doc, diagnostics);
|
|
272
|
+
if (rootDoc === void 0) return null;
|
|
273
|
+
const webhook = listWebhooks(getParsed(rootDoc, diagnostics)).find((w) => w.name === name);
|
|
274
|
+
if (webhook === void 0) return null;
|
|
275
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
276
|
+
"data-webhook": name,
|
|
277
|
+
"data-instance": instancePrefix,
|
|
278
|
+
children: [/* @__PURE__ */ jsxs("h3", { children: ["Webhook: ", name] }), webhook.operations.map((op) => {
|
|
279
|
+
const opProps = {
|
|
280
|
+
schema: rootDoc,
|
|
281
|
+
path: name,
|
|
282
|
+
method: op.method
|
|
283
|
+
};
|
|
284
|
+
if (widgets !== void 0) opProps.widgets = widgets;
|
|
285
|
+
if (meta !== void 0) opProps.meta = meta;
|
|
286
|
+
return /* @__PURE__ */ jsx(ApiOperation, { ...opProps }, `${name}-${op.method}`);
|
|
287
|
+
})]
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
function ApiWebhooks({ schema: doc, widgets, meta, onDiagnostic, strict }) {
|
|
291
|
+
const diagnostics = buildDiagnostics(onDiagnostic, strict);
|
|
292
|
+
const instancePrefix = sanitisePrefix(useId());
|
|
293
|
+
const rootDoc = resolveRootDoc(doc, diagnostics);
|
|
294
|
+
if (rootDoc === void 0) return null;
|
|
295
|
+
const webhooks = listWebhooks(getParsed(rootDoc, diagnostics));
|
|
296
|
+
if (webhooks.length === 0) return null;
|
|
297
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
298
|
+
"data-webhooks": true,
|
|
299
|
+
"data-instance": instancePrefix,
|
|
300
|
+
children: [/* @__PURE__ */ jsx("h2", { children: "Webhooks" }), webhooks.map((webhook) => {
|
|
301
|
+
const props = {
|
|
302
|
+
schema: rootDoc,
|
|
303
|
+
name: webhook.name
|
|
304
|
+
};
|
|
305
|
+
if (widgets !== void 0) props.widgets = widgets;
|
|
306
|
+
if (meta !== void 0) props.meta = meta;
|
|
307
|
+
return /* @__PURE__ */ jsx(ApiWebhook, { ...props }, webhook.name);
|
|
308
|
+
})]
|
|
309
|
+
});
|
|
310
|
+
}
|
|
192
311
|
function OperationHeader({ operation, pathItem }) {
|
|
193
312
|
return /* @__PURE__ */ jsxs("header", { children: [
|
|
194
313
|
(pathItem.summary !== void 0 || pathItem.description !== void 0) && /* @__PURE__ */ jsxs("div", {
|
|
@@ -217,25 +336,39 @@ function OperationHeader({ operation, pathItem }) {
|
|
|
217
336
|
})
|
|
218
337
|
] });
|
|
219
338
|
}
|
|
220
|
-
function ParameterList({ parameters, rootDoc, overrides, meta, widgets, idPrefix }) {
|
|
221
|
-
return /* @__PURE__ */ jsx(Fragment, { children: parameters.map((param) =>
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
"
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
})
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
339
|
+
function ParameterList({ parameters, rootDoc, overrides, meta, widgets, idPrefix, diagnostics, pointerPrefix }) {
|
|
340
|
+
return /* @__PURE__ */ jsx(Fragment, { children: parameters.map((param) => {
|
|
341
|
+
if (param.schema === void 0) {
|
|
342
|
+
emitDiagnostic(diagnostics, {
|
|
343
|
+
code: "parameter-missing-schema",
|
|
344
|
+
message: `Parameter "${param.name}" has no schema; rendering skipped`,
|
|
345
|
+
pointer: `${pointerPrefix}/parameters/${param.name}`,
|
|
346
|
+
detail: {
|
|
347
|
+
name: param.name,
|
|
348
|
+
location: param.location
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
return null;
|
|
352
|
+
}
|
|
353
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
354
|
+
"data-parameter": param.name,
|
|
355
|
+
children: [
|
|
356
|
+
/* @__PURE__ */ jsxs("label", { children: [param.name, param.required && /* @__PURE__ */ jsx("span", {
|
|
357
|
+
"data-required": true,
|
|
358
|
+
children: "*"
|
|
359
|
+
})] }),
|
|
360
|
+
param.description && /* @__PURE__ */ jsx("span", {
|
|
361
|
+
"data-description": true,
|
|
362
|
+
children: param.description
|
|
363
|
+
}),
|
|
364
|
+
renderSchema(param.schema, rootDoc, {
|
|
365
|
+
meta: buildParamMeta(param, overrides, meta),
|
|
366
|
+
widgets,
|
|
367
|
+
rootPath: joinPath(idPrefix, param.name)
|
|
368
|
+
})
|
|
369
|
+
]
|
|
370
|
+
}, param.name);
|
|
371
|
+
}) });
|
|
239
372
|
}
|
|
240
373
|
function ResponseCard({ response, rootDoc, parsed, value, fields, meta, widgets, path, method, idPrefix }) {
|
|
241
374
|
if (response.schema === void 0) return /* @__PURE__ */ jsxs("div", {
|
|
@@ -268,6 +401,19 @@ function ResponseCard({ response, rootDoc, parsed, value, fields, meta, widgets,
|
|
|
268
401
|
]
|
|
269
402
|
});
|
|
270
403
|
}
|
|
404
|
+
/**
|
|
405
|
+
* Compose the JSON Pointer prefix for an operation's Parameter Object
|
|
406
|
+
* map. Paths conventionally begin with `/` so they live under
|
|
407
|
+
* `#/paths/<escaped path>/<method>`; OpenAPI 3.1 webhook names (which
|
|
408
|
+
* have no leading slash) live under `#/webhooks/<name>/<method>`.
|
|
409
|
+
*
|
|
410
|
+
* JSON Pointer (RFC 6901) requires `~` → `~0` and `/` → `~1`. The
|
|
411
|
+
* escape order matters: `~` first to avoid double-escaping the `~1`
|
|
412
|
+
* produced for `/`.
|
|
413
|
+
*/
|
|
414
|
+
function operationPointer(path, method) {
|
|
415
|
+
return `/${path.startsWith("/") ? "paths" : "webhooks"}/${path.replace(/~/g, "~0").replace(/\//g, "~1")}/${method}`;
|
|
416
|
+
}
|
|
271
417
|
function buildParamMeta(param, overrides, meta) {
|
|
272
418
|
const result = {};
|
|
273
419
|
if (param.description !== void 0) result.description = param.description;
|
|
@@ -277,20 +423,5 @@ function buildParamMeta(param, overrides, meta) {
|
|
|
277
423
|
if (meta !== void 0) for (const [k, v] of Object.entries(meta)) result[k] = v;
|
|
278
424
|
return Object.keys(result).length > 0 ? result : void 0;
|
|
279
425
|
}
|
|
280
|
-
/**
|
|
281
|
-
* Extract root-level meta (title, description, readOnly, etc.) from a
|
|
282
|
-
* JSON Schema node. Mirrors `extractRootMetaFromJson` in the adapter so
|
|
283
|
-
* pre-normalised schemas (extracted from `getParsed`) still surface root
|
|
284
|
-
* meta to the walker without an extra adapter round-trip.
|
|
285
|
-
*/
|
|
286
|
-
function extractRootMetaFromSchema(jsonSchema) {
|
|
287
|
-
const meta = {};
|
|
288
|
-
if (jsonSchema.readOnly === true) meta.readOnly = true;
|
|
289
|
-
if (jsonSchema.writeOnly === true) meta.writeOnly = true;
|
|
290
|
-
if (typeof jsonSchema.description === "string") meta.description = jsonSchema.description;
|
|
291
|
-
if (typeof jsonSchema.title === "string") meta.title = jsonSchema.title;
|
|
292
|
-
if (typeof jsonSchema.deprecated === "boolean") meta.deprecated = jsonSchema.deprecated;
|
|
293
|
-
return Object.keys(meta).length > 0 ? meta : void 0;
|
|
294
|
-
}
|
|
295
426
|
//#endregion
|
|
296
|
-
export { ApiOperation, ApiParameters, ApiRequestBody, ApiResponse };
|
|
427
|
+
export { ApiOperation, ApiParameters, ApiRequestBody, ApiResponse, ApiWebhook, ApiWebhooks };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { m as JsonObject } from "../types-
|
|
1
|
+
import { m as JsonObject } from "../types-BTB73MB8.mjs";
|
|
2
|
+
import { i as DiagnosticsOptions } from "../diagnostics-BS2kaUyE.mjs";
|
|
2
3
|
|
|
3
4
|
//#region src/openapi/parser.d.ts
|
|
4
5
|
interface OpenApiDocument {
|
|
@@ -86,17 +87,17 @@ interface LinkInfo {
|
|
|
86
87
|
}
|
|
87
88
|
declare function parseOpenApiDocument(doc: JsonObject): OpenApiDocument;
|
|
88
89
|
declare function getSchema(parsed: OpenApiDocument, ref: string): JsonObject | undefined;
|
|
89
|
-
declare function listOperations(parsed: OpenApiDocument): OperationInfo[];
|
|
90
|
-
declare function getParameters(parsed: OpenApiDocument, path: string, method: string): ParameterInfo[];
|
|
90
|
+
declare function listOperations(parsed: OpenApiDocument, diagnostics?: DiagnosticsOptions): OperationInfo[];
|
|
91
|
+
declare function getParameters(parsed: OpenApiDocument, path: string, method: string, diagnostics?: DiagnosticsOptions): ParameterInfo[];
|
|
91
92
|
declare function getRequestBody(parsed: OpenApiDocument, path: string, method: string): RequestBodyInfo | undefined;
|
|
92
|
-
declare function getResponses(parsed: OpenApiDocument, path: string, method: string): ResponseInfo[];
|
|
93
|
+
declare function getResponses(parsed: OpenApiDocument, path: string, method: string, diagnostics?: DiagnosticsOptions): ResponseInfo[];
|
|
93
94
|
declare function getSecurityRequirements(parsed: OpenApiDocument, path: string, method: string): SecurityRequirement[];
|
|
94
95
|
declare function getSecuritySchemes(parsed: OpenApiDocument): Map<string, SecurityScheme>;
|
|
95
|
-
declare function getResponseHeaders(response: JsonObject, doc?: JsonObject): Map<string, HeaderInfo>;
|
|
96
|
-
declare function listWebhooks(parsed: OpenApiDocument): WebhookInfo[];
|
|
96
|
+
declare function getResponseHeaders(response: JsonObject, doc?: JsonObject, diagnostics?: DiagnosticsOptions): Map<string, HeaderInfo>;
|
|
97
|
+
declare function listWebhooks(parsed: OpenApiDocument, diagnostics?: DiagnosticsOptions): WebhookInfo[];
|
|
97
98
|
declare function getExternalDocs(obj: JsonObject): ExternalDocs | undefined;
|
|
98
99
|
declare function getXmlInfo(schema: JsonObject): XmlInfo | undefined;
|
|
99
|
-
declare function listCallbacks(parsed: OpenApiDocument, path: string, method: string): CallbackInfo[];
|
|
100
|
-
declare function getLinks(parsed: OpenApiDocument, path: string, method: string, statusCode: string): LinkInfo[];
|
|
100
|
+
declare function listCallbacks(parsed: OpenApiDocument, path: string, method: string, diagnostics?: DiagnosticsOptions): CallbackInfo[];
|
|
101
|
+
declare function getLinks(parsed: OpenApiDocument, path: string, method: string, statusCode: string, diagnostics?: DiagnosticsOptions): LinkInfo[];
|
|
101
102
|
//#endregion
|
|
102
103
|
export { CallbackInfo, ExternalDocs, HeaderInfo, LinkInfo, OpenApiDocument, OperationInfo, ParameterInfo, ParameterLocation, RequestBodyInfo, ResponseInfo, SecurityRequirement, SecurityScheme, WebhookInfo, XmlInfo, getExternalDocs, getLinks, getParameters, getRequestBody, getResponseHeaders, getResponses, getSchema, getSecurityRequirements, getSecuritySchemes, getXmlInfo, listCallbacks, listOperations, listWebhooks, parseOpenApiDocument };
|