schema-components 1.28.1 → 1.29.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/dist/{adapter-DqlAnZ_w.d.mts → adapter-DcWi4XXn.d.mts} +60 -9
- package/dist/core/adapter.d.mts +2 -2
- package/dist/core/adapter.mjs +20 -1
- package/dist/core/constraints.d.mts +34 -2
- package/dist/core/constraints.mjs +32 -0
- package/dist/core/cssClasses.d.mts +1 -0
- package/dist/core/diagnostics.d.mts +1 -1
- package/dist/core/errors.d.mts +1 -1
- package/dist/core/errors.mjs +22 -12
- package/dist/core/fieldOrder.d.mts +1 -1
- package/dist/core/formats.d.mts +7 -1
- package/dist/core/formats.mjs +6 -0
- package/dist/core/limits.d.mts +1 -1
- package/dist/core/limits.mjs +1 -0
- package/dist/core/merge.d.mts +11 -1
- package/dist/core/normalise.d.mts +17 -2
- package/dist/core/openapiConstants.d.mts +1 -0
- package/dist/core/ref.d.mts +1 -1
- package/dist/core/renderer.d.mts +1 -1
- package/dist/core/renderer.mjs +5 -0
- package/dist/core/swagger2.d.mts +1 -1
- package/dist/core/typeInference.d.mts +2 -2
- package/dist/core/types.d.mts +1 -1
- package/dist/core/types.mjs +17 -0
- package/dist/core/unionMatch.d.mts +1 -1
- package/dist/core/version.d.mts +1 -1
- package/dist/core/walkBuilders.d.mts +48 -3
- package/dist/core/walkBuilders.mjs +30 -0
- package/dist/core/walker.d.mts +14 -1
- package/dist/core/walker.mjs +13 -0
- package/dist/{diagnostics-Cbwak-ZX.d.mts → diagnostics-ByEzkjrA.d.mts} +8 -0
- package/dist/{errors-DQSIK4n1.d.mts → errors-D8JndRwI.d.mts} +23 -13
- package/dist/html/a11y.d.mts +2 -2
- package/dist/html/html.d.mts +11 -0
- package/dist/html/html.mjs +11 -0
- package/dist/html/renderToHtml.d.mts +25 -5
- package/dist/html/renderToHtml.mjs +18 -3
- package/dist/html/renderToHtmlStream.d.mts +41 -9
- package/dist/html/renderToHtmlStream.mjs +32 -7
- package/dist/html/renderers.d.mts +7 -1
- package/dist/html/renderers.mjs +6 -0
- package/dist/html/streamRenderers.d.mts +31 -3
- package/dist/html/streamRenderers.mjs +28 -0
- package/dist/{limits-DJhgx5Ay.d.mts → limits-DswmqWuy.d.mts} +1 -0
- package/dist/openapi/ApiCallbacks.d.mts +13 -1
- package/dist/openapi/ApiCallbacks.mjs +7 -0
- package/dist/openapi/ApiLinks.d.mts +13 -1
- package/dist/openapi/ApiLinks.mjs +7 -0
- package/dist/openapi/ApiResponseHeaders.d.mts +13 -1
- package/dist/openapi/ApiResponseHeaders.mjs +7 -0
- package/dist/openapi/ApiSecurity.d.mts +14 -1
- package/dist/openapi/ApiSecurity.mjs +8 -0
- package/dist/openapi/components.d.mts +96 -12
- package/dist/openapi/components.mjs +69 -0
- package/dist/openapi/parser.d.mts +129 -2
- package/dist/openapi/parser.mjs +72 -0
- package/dist/openapi/resolve.d.mts +7 -1
- package/dist/react/SchemaComponent.d.mts +83 -5
- package/dist/react/SchemaComponent.mjs +61 -0
- package/dist/react/SchemaErrorBoundary.d.mts +18 -1
- package/dist/react/SchemaErrorBoundary.mjs +13 -1
- package/dist/react/SchemaView.d.mts +32 -8
- package/dist/react/SchemaView.mjs +19 -4
- package/dist/react/a11y.d.mts +1 -1
- package/dist/react/fieldPath.d.mts +1 -1
- package/dist/react/headless.d.mts +1 -1
- package/dist/react/headlessRenderers.d.mts +13 -2
- package/dist/react/headlessRenderers.mjs +11 -0
- package/dist/{ref-TdeMfaV_.d.mts → ref-CPh8rKQ3.d.mts} +1 -1
- package/dist/{renderer-Ul9taFYp.d.mts → renderer-OaOz-n6-.d.mts} +17 -1
- package/dist/themes/mantine.d.mts +29 -3
- package/dist/themes/mantine.mjs +28 -2
- package/dist/themes/mui.d.mts +29 -2
- package/dist/themes/mui.mjs +28 -1
- package/dist/themes/radix.d.mts +40 -3
- package/dist/themes/radix.mjs +39 -2
- package/dist/themes/shadcn.d.mts +22 -1
- package/dist/themes/shadcn.mjs +21 -0
- package/dist/{types-BTB73MB8.d.mts → types-C2Ay1FEh.d.mts} +23 -0
- package/dist/{version-ZzL5R6cS.d.mts → version-DL8U5RuA.d.mts} +6 -0
- package/package.json +5 -1
|
@@ -1,13 +1,41 @@
|
|
|
1
|
-
import { j as WalkedField } from "../types-
|
|
2
|
-
import { i as DiagnosticsOptions } from "../diagnostics-
|
|
3
|
-
import { o as HtmlResolver } from "../renderer-
|
|
1
|
+
import { j as WalkedField } from "../types-C2Ay1FEh.mjs";
|
|
2
|
+
import { i as DiagnosticsOptions } from "../diagnostics-ByEzkjrA.mjs";
|
|
3
|
+
import { o as HtmlResolver } from "../renderer-OaOz-n6-.mjs";
|
|
4
4
|
import { HtmlElement } from "./html.mjs";
|
|
5
5
|
|
|
6
6
|
//#region src/html/streamRenderers.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Serialise the opening tag of an element so a generator can yield it
|
|
9
|
+
* without the matching closing tag. Void elements (e.g. `input`) are
|
|
10
|
+
* emitted self-closed so the chunk is structurally valid on its own.
|
|
11
|
+
*/
|
|
7
12
|
declare function yieldOpen(el: HtmlElement): string;
|
|
13
|
+
/**
|
|
14
|
+
* Serialise the closing tag of an element so a generator can yield it
|
|
15
|
+
* after its children. Returns an empty string for void elements (their
|
|
16
|
+
* opening tag was emitted self-closed by {@link yieldOpen}).
|
|
17
|
+
*/
|
|
8
18
|
declare function yieldClose(el: HtmlElement): string;
|
|
19
|
+
/**
|
|
20
|
+
* Render a leaf {@link WalkedField} entirely as a single HTML chunk.
|
|
21
|
+
* Used inside the streaming generators when descent into containers is
|
|
22
|
+
* complete. Falls back to a `<span>`-wrapped value when no renderer is
|
|
23
|
+
* registered for the field type.
|
|
24
|
+
*/
|
|
9
25
|
declare function renderLeaf(tree: WalkedField, value: unknown, mergedResolver: HtmlResolver, path: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Drain {@link streamField} into a single string. Used when a streamed
|
|
28
|
+
* sub-tree needs to be embedded inside a non-streaming chunk (e.g. as
|
|
29
|
+
* children of a parent element).
|
|
30
|
+
*/
|
|
10
31
|
declare function renderFieldSync(tree: WalkedField, value: unknown, mergedResolver: HtmlResolver, path: string, rawResolver: HtmlResolver, currentDepth: number, diagnostics: DiagnosticsOptions | undefined): string;
|
|
32
|
+
/**
|
|
33
|
+
* Render a {@link WalkedField} as a generator that yields HTML chunks
|
|
34
|
+
* at natural boundaries (opening tag, one chunk per child, closing
|
|
35
|
+
* tag). Threads `currentDepth` so cyclic walked-field graphs terminate
|
|
36
|
+
* at `MAX_RENDER_DEPTH` with a recursion sentinel rather than
|
|
37
|
+
* overflowing the stack.
|
|
38
|
+
*/
|
|
11
39
|
declare function streamField(tree: WalkedField, value: unknown, mergedResolver: HtmlResolver, path: string, rawResolver: HtmlResolver, currentDepth?: number, diagnostics?: DiagnosticsOptions): Iterable<string, void, undefined>;
|
|
12
40
|
//#endregion
|
|
13
41
|
export { renderFieldSync, renderLeaf, streamField, yieldClose, yieldOpen };
|
|
@@ -9,15 +9,31 @@ import { ariaLabelAttrs, buildHintElement, buildInputId, joinPath, requiredIndic
|
|
|
9
9
|
import { panelId, tabId } from "./renderers.mjs";
|
|
10
10
|
import { recursionSentinelHtml } from "./renderToHtml.mjs";
|
|
11
11
|
//#region src/html/streamRenderers.ts
|
|
12
|
+
/**
|
|
13
|
+
* Serialise the opening tag of an element so a generator can yield it
|
|
14
|
+
* without the matching closing tag. Void elements (e.g. `input`) are
|
|
15
|
+
* emitted self-closed so the chunk is structurally valid on its own.
|
|
16
|
+
*/
|
|
12
17
|
function yieldOpen(el) {
|
|
13
18
|
const attrStr = serializeAttributes(el.attributes);
|
|
14
19
|
if (VOID_ELEMENTS.has(el.tag)) return `<${el.tag}${attrStr} />`;
|
|
15
20
|
return `<${el.tag}${attrStr}>`;
|
|
16
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Serialise the closing tag of an element so a generator can yield it
|
|
24
|
+
* after its children. Returns an empty string for void elements (their
|
|
25
|
+
* opening tag was emitted self-closed by {@link yieldOpen}).
|
|
26
|
+
*/
|
|
17
27
|
function yieldClose(el) {
|
|
18
28
|
if (VOID_ELEMENTS.has(el.tag)) return "";
|
|
19
29
|
return `</${el.tag}>`;
|
|
20
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Render a leaf {@link WalkedField} entirely as a single HTML chunk.
|
|
33
|
+
* Used inside the streaming generators when descent into containers is
|
|
34
|
+
* complete. Falls back to a `<span>`-wrapped value when no renderer is
|
|
35
|
+
* registered for the field type.
|
|
36
|
+
*/
|
|
21
37
|
function renderLeaf(tree, value, mergedResolver, path) {
|
|
22
38
|
const renderFn = getHtmlRenderFn(tree.type, mergedResolver);
|
|
23
39
|
if (renderFn !== void 0) return renderFn({
|
|
@@ -33,6 +49,11 @@ function renderLeaf(tree, value, mergedResolver, path) {
|
|
|
33
49
|
if (value === void 0 || value === null) return serialize(h("span", { class: SC_CLASSES.valueEmpty }, "—"));
|
|
34
50
|
return serialize(h("span", { class: SC_CLASSES.value }, typeof value === "string" ? value : JSON.stringify(value)));
|
|
35
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Drain {@link streamField} into a single string. Used when a streamed
|
|
54
|
+
* sub-tree needs to be embedded inside a non-streaming chunk (e.g. as
|
|
55
|
+
* children of a parent element).
|
|
56
|
+
*/
|
|
36
57
|
function renderFieldSync(tree, value, mergedResolver, path, rawResolver, currentDepth, diagnostics) {
|
|
37
58
|
return [...streamField(tree, value, mergedResolver, path, rawResolver, currentDepth, diagnostics)].join("");
|
|
38
59
|
}
|
|
@@ -51,6 +72,13 @@ function typeMismatchPlaceholder(expectedShape) {
|
|
|
51
72
|
role: "alert"
|
|
52
73
|
}, `invalid value (expected ${expectedShape})`));
|
|
53
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Render a {@link WalkedField} as a generator that yields HTML chunks
|
|
77
|
+
* at natural boundaries (opening tag, one chunk per child, closing
|
|
78
|
+
* tag). Threads `currentDepth` so cyclic walked-field graphs terminate
|
|
79
|
+
* at `MAX_RENDER_DEPTH` with a recursion sentinel rather than
|
|
80
|
+
* overflowing the stack.
|
|
81
|
+
*/
|
|
54
82
|
function* streamField(tree, value, mergedResolver, path, rawResolver, currentDepth = 0, diagnostics) {
|
|
55
83
|
if (currentDepth >= 10) {
|
|
56
84
|
yield recursionSentinelHtml(typeof tree.meta.description === "string" ? tree.meta.description : "schema");
|
|
@@ -18,6 +18,7 @@ declare const MAX_RENDER_DEPTH = 10;
|
|
|
18
18
|
* and compile-time bounds agree.
|
|
19
19
|
*/
|
|
20
20
|
type MaxRefDepth = 64;
|
|
21
|
+
/** Runtime constant matching the type-level {@link MaxRefDepth} bound. */
|
|
21
22
|
declare const MAX_REF_DEPTH: MaxRefDepth;
|
|
22
23
|
/**
|
|
23
24
|
* Maximum number of `$ref` hops permitted when walking a chain of
|
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
import { w as SchemaMeta } from "../types-
|
|
1
|
+
import { w as SchemaMeta } from "../types-C2Ay1FEh.mjs";
|
|
2
2
|
import { CallbackInfo } from "./parser.mjs";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/openapi/ApiCallbacks.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Props accepted by {@link ApiCallbacks}.
|
|
8
|
+
*
|
|
9
|
+
* @group OpenAPI
|
|
10
|
+
*/
|
|
6
11
|
interface ApiCallbacksProps {
|
|
7
12
|
/** Callback definitions for this operation. */
|
|
8
13
|
callbacks: CallbackInfo[];
|
|
9
14
|
/** Optional meta overrides. */
|
|
10
15
|
meta?: SchemaMeta;
|
|
11
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Render OpenAPI callback definitions declared on an operation. Each
|
|
19
|
+
* callback name is displayed alongside its operations. Read-only —
|
|
20
|
+
* intended for documentation rather than interactive editing.
|
|
21
|
+
*
|
|
22
|
+
* @group OpenAPI
|
|
23
|
+
*/
|
|
12
24
|
declare function ApiCallbacks({
|
|
13
25
|
callbacks
|
|
14
26
|
}: ApiCallbacksProps): ReactNode;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
//#region src/openapi/ApiCallbacks.tsx
|
|
3
|
+
/**
|
|
4
|
+
* Render OpenAPI callback definitions declared on an operation. Each
|
|
5
|
+
* callback name is displayed alongside its operations. Read-only —
|
|
6
|
+
* intended for documentation rather than interactive editing.
|
|
7
|
+
*
|
|
8
|
+
* @group OpenAPI
|
|
9
|
+
*/
|
|
3
10
|
function ApiCallbacks({ callbacks }) {
|
|
4
11
|
if (callbacks.length === 0) return null;
|
|
5
12
|
return /* @__PURE__ */ jsxs("section", {
|
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
import { w as SchemaMeta } from "../types-
|
|
1
|
+
import { w as SchemaMeta } from "../types-C2Ay1FEh.mjs";
|
|
2
2
|
import { LinkInfo } from "./parser.mjs";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/openapi/ApiLinks.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Props accepted by {@link ApiLinks}.
|
|
8
|
+
*
|
|
9
|
+
* @group OpenAPI
|
|
10
|
+
*/
|
|
6
11
|
interface ApiLinksProps {
|
|
7
12
|
/** Link definitions for a response. */
|
|
8
13
|
links: LinkInfo[];
|
|
9
14
|
/** Optional meta overrides. */
|
|
10
15
|
meta?: SchemaMeta;
|
|
11
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Render OpenAPI link definitions attached to a response. Displays each
|
|
19
|
+
* link's name, target operation (`operationId` or `operationRef`),
|
|
20
|
+
* description, and parameter mappings. Read-only.
|
|
21
|
+
*
|
|
22
|
+
* @group OpenAPI
|
|
23
|
+
*/
|
|
12
24
|
declare function ApiLinks({
|
|
13
25
|
links
|
|
14
26
|
}: ApiLinksProps): ReactNode;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
//#region src/openapi/ApiLinks.tsx
|
|
3
|
+
/**
|
|
4
|
+
* Render OpenAPI link definitions attached to a response. Displays each
|
|
5
|
+
* link's name, target operation (`operationId` or `operationRef`),
|
|
6
|
+
* description, and parameter mappings. Read-only.
|
|
7
|
+
*
|
|
8
|
+
* @group OpenAPI
|
|
9
|
+
*/
|
|
3
10
|
function ApiLinks({ links }) {
|
|
4
11
|
if (links.length === 0) return null;
|
|
5
12
|
return /* @__PURE__ */ jsxs("section", {
|
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
import { w as SchemaMeta } from "../types-
|
|
1
|
+
import { w as SchemaMeta } from "../types-C2Ay1FEh.mjs";
|
|
2
2
|
import { HeaderInfo } from "./parser.mjs";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/openapi/ApiResponseHeaders.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Props accepted by {@link ApiResponseHeaders}.
|
|
8
|
+
*
|
|
9
|
+
* @group OpenAPI
|
|
10
|
+
*/
|
|
6
11
|
interface ApiResponseHeadersProps {
|
|
7
12
|
/** Header definitions for a response. */
|
|
8
13
|
headers: Map<string, HeaderInfo>;
|
|
9
14
|
/** Optional meta overrides. */
|
|
10
15
|
meta?: SchemaMeta;
|
|
11
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Render the header definitions declared on an OpenAPI response. Shows
|
|
19
|
+
* each header's name, description, type, required flag, and deprecation
|
|
20
|
+
* marker. Read-only.
|
|
21
|
+
*
|
|
22
|
+
* @group OpenAPI
|
|
23
|
+
*/
|
|
12
24
|
declare function ApiResponseHeaders({
|
|
13
25
|
headers
|
|
14
26
|
}: ApiResponseHeadersProps): ReactNode;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
//#region src/openapi/ApiResponseHeaders.tsx
|
|
3
|
+
/**
|
|
4
|
+
* Render the header definitions declared on an OpenAPI response. Shows
|
|
5
|
+
* each header's name, description, type, required flag, and deprecation
|
|
6
|
+
* marker. Read-only.
|
|
7
|
+
*
|
|
8
|
+
* @group OpenAPI
|
|
9
|
+
*/
|
|
3
10
|
function ApiResponseHeaders({ headers }) {
|
|
4
11
|
if (headers.size === 0) return null;
|
|
5
12
|
return /* @__PURE__ */ jsxs("section", {
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { w as SchemaMeta } from "../types-
|
|
1
|
+
import { w as SchemaMeta } from "../types-C2Ay1FEh.mjs";
|
|
2
2
|
import { SecurityRequirement, SecurityScheme } from "./parser.mjs";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/openapi/ApiSecurity.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Props accepted by {@link ApiSecurity}.
|
|
8
|
+
*
|
|
9
|
+
* @group OpenAPI
|
|
10
|
+
*/
|
|
6
11
|
interface ApiSecurityProps {
|
|
7
12
|
/** Security requirements for this operation. */
|
|
8
13
|
requirements: SecurityRequirement[];
|
|
@@ -11,6 +16,14 @@ interface ApiSecurityProps {
|
|
|
11
16
|
/** Optional meta overrides. */
|
|
12
17
|
meta?: SchemaMeta;
|
|
13
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Render the security requirements that apply to an OpenAPI operation,
|
|
21
|
+
* resolved against the document's component security schemes. Displays
|
|
22
|
+
* each scheme's type, description, location, scopes, and the full set
|
|
23
|
+
* of OAuth 2 flows when applicable. Read-only.
|
|
24
|
+
*
|
|
25
|
+
* @group OpenAPI
|
|
26
|
+
*/
|
|
14
27
|
declare function ApiSecurity({
|
|
15
28
|
requirements,
|
|
16
29
|
schemes
|
|
@@ -53,6 +53,14 @@ function extractFlows(flows) {
|
|
|
53
53
|
}
|
|
54
54
|
return result;
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Render the security requirements that apply to an OpenAPI operation,
|
|
58
|
+
* resolved against the document's component security schemes. Displays
|
|
59
|
+
* each scheme's type, description, location, scopes, and the full set
|
|
60
|
+
* of OAuth 2 flows when applicable. Read-only.
|
|
61
|
+
*
|
|
62
|
+
* @group OpenAPI
|
|
63
|
+
*/
|
|
56
64
|
function ApiSecurity({ requirements, schemes }) {
|
|
57
65
|
if (requirements.length === 0) return null;
|
|
58
66
|
return /* @__PURE__ */ jsxs("section", {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { u as FieldOverride, w as SchemaMeta } from "../types-
|
|
2
|
-
import { r as DiagnosticSink } from "../diagnostics-
|
|
1
|
+
import { u as FieldOverride, w as SchemaMeta } from "../types-C2Ay1FEh.mjs";
|
|
2
|
+
import { r as DiagnosticSink } from "../diagnostics-ByEzkjrA.mjs";
|
|
3
3
|
import { InferParameterOverrides, InferRequestBodyFields, InferResponseFields } from "../core/typeInference.mjs";
|
|
4
4
|
import { WidgetMap } from "../react/SchemaComponent.mjs";
|
|
5
5
|
import { ReactNode } from "react";
|
|
@@ -168,6 +168,11 @@ interface ApiDiagnosticsProps {
|
|
|
168
168
|
onDiagnostic?: DiagnosticSink;
|
|
169
169
|
strict?: boolean;
|
|
170
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Props accepted by {@link ApiOperation}.
|
|
173
|
+
*
|
|
174
|
+
* @group OpenAPI
|
|
175
|
+
*/
|
|
171
176
|
interface ApiOperationProps<Doc = unknown, Path extends PathKeysOf<Doc> = PathKeysOf<Doc>, Method extends MethodKeysOf<Doc, Path> = MethodKeysOf<Doc, Path>, ContentType extends RequestContentTypesOf<Doc, Path, Method> = RequestContentTypesOf<Doc, Path, Method>> extends ApiDiagnosticsProps {
|
|
172
177
|
schema: Doc;
|
|
173
178
|
path: Path;
|
|
@@ -189,6 +194,25 @@ interface ApiOperationProps<Doc = unknown, Path extends PathKeysOf<Doc> = PathKe
|
|
|
189
194
|
/** Instance-scoped widgets. */
|
|
190
195
|
widgets?: WidgetMap;
|
|
191
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Render a single OpenAPI operation — header, parameters, request body,
|
|
199
|
+
* responses, callbacks, security, and external docs — picked out of a
|
|
200
|
+
* supplied document by `path` and `method`.
|
|
201
|
+
*
|
|
202
|
+
* When `schema` is typed `as const`, `requestBodyFields` autocomplete
|
|
203
|
+
* resolves from the operation's request body schema. The component
|
|
204
|
+
* works with OpenAPI 2.0, 3.0, and 3.1 inputs (Swagger 2.0 documents
|
|
205
|
+
* are normalised to 3.1 internally) and also resolves OpenAPI 3.1
|
|
206
|
+
* webhooks under the same code path.
|
|
207
|
+
*
|
|
208
|
+
* @group OpenAPI
|
|
209
|
+
* @example
|
|
210
|
+
* ```tsx
|
|
211
|
+
* import { ApiOperation } from "schema-components/openapi/components";
|
|
212
|
+
*
|
|
213
|
+
* <ApiOperation schema={petStore} path="/pets" method="post" />
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
192
216
|
declare function ApiOperation<Doc = unknown, Path extends PathKeysOf<Doc> = PathKeysOf<Doc>, Method extends MethodKeysOf<Doc, Path> = MethodKeysOf<Doc, Path>, ContentType extends RequestContentTypesOf<Doc, Path, Method> = RequestContentTypesOf<Doc, Path, Method>>({
|
|
193
217
|
schema: doc,
|
|
194
218
|
path,
|
|
@@ -202,6 +226,11 @@ declare function ApiOperation<Doc = unknown, Path extends PathKeysOf<Doc> = Path
|
|
|
202
226
|
onDiagnostic,
|
|
203
227
|
strict
|
|
204
228
|
}: ApiOperationProps<Doc, Path, Method, ContentType>): ReactNode;
|
|
229
|
+
/**
|
|
230
|
+
* Props accepted by {@link ApiParameters}.
|
|
231
|
+
*
|
|
232
|
+
* @group OpenAPI
|
|
233
|
+
*/
|
|
205
234
|
interface ApiParametersProps<Doc = unknown, Path extends PathKeysOf<Doc> = PathKeysOf<Doc>, Method extends MethodKeysOf<Doc, Path> = MethodKeysOf<Doc, Path>> extends ApiDiagnosticsProps {
|
|
206
235
|
schema: Doc;
|
|
207
236
|
path: Path;
|
|
@@ -211,6 +240,14 @@ interface ApiParametersProps<Doc = unknown, Path extends PathKeysOf<Doc> = PathK
|
|
|
211
240
|
/** Instance-scoped widgets. */
|
|
212
241
|
widgets?: WidgetMap;
|
|
213
242
|
}
|
|
243
|
+
/**
|
|
244
|
+
* Render the `parameters` of a single OpenAPI operation — path, query,
|
|
245
|
+
* header, and cookie parameters — picked out of `schema` by `path` and
|
|
246
|
+
* `method`. When the document is typed `as const`, the `overrides` prop
|
|
247
|
+
* autocompletes on each parameter name.
|
|
248
|
+
*
|
|
249
|
+
* @group OpenAPI
|
|
250
|
+
*/
|
|
214
251
|
declare function ApiParameters<Doc = unknown, Path extends PathKeysOf<Doc> = PathKeysOf<Doc>, Method extends MethodKeysOf<Doc, Path> = MethodKeysOf<Doc, Path>>({
|
|
215
252
|
schema: doc,
|
|
216
253
|
path,
|
|
@@ -221,6 +258,11 @@ declare function ApiParameters<Doc = unknown, Path extends PathKeysOf<Doc> = Pat
|
|
|
221
258
|
onDiagnostic,
|
|
222
259
|
strict
|
|
223
260
|
}: ApiParametersProps<Doc, Path, Method>): ReactNode;
|
|
261
|
+
/**
|
|
262
|
+
* Props accepted by {@link ApiRequestBody}.
|
|
263
|
+
*
|
|
264
|
+
* @group OpenAPI
|
|
265
|
+
*/
|
|
224
266
|
interface ApiRequestBodyProps<Doc = unknown, Path extends PathKeysOf<Doc> = PathKeysOf<Doc>, Method extends MethodKeysOf<Doc, Path> = MethodKeysOf<Doc, Path>, ContentType extends RequestContentTypesOf<Doc, Path, Method> = RequestContentTypesOf<Doc, Path, Method>> extends ApiDiagnosticsProps {
|
|
225
267
|
schema: Doc;
|
|
226
268
|
path: Path;
|
|
@@ -239,6 +281,17 @@ interface ApiRequestBodyProps<Doc = unknown, Path extends PathKeysOf<Doc> = Path
|
|
|
239
281
|
/** Instance-scoped widgets. */
|
|
240
282
|
widgets?: WidgetMap;
|
|
241
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* Render the request body of a single OpenAPI operation, picked out of
|
|
286
|
+
* `schema` by `path` and `method`. Returns `null` when the operation
|
|
287
|
+
* declares no request body or no resolvable schema.
|
|
288
|
+
*
|
|
289
|
+
* When `schema` is typed `as const`, `fields` autocomplete resolves
|
|
290
|
+
* from the request body schema; pass `contentType` to narrow inference
|
|
291
|
+
* to a specific media type.
|
|
292
|
+
*
|
|
293
|
+
* @group OpenAPI
|
|
294
|
+
*/
|
|
242
295
|
declare function ApiRequestBody<Doc = unknown, Path extends PathKeysOf<Doc> = PathKeysOf<Doc>, Method extends MethodKeysOf<Doc, Path> = MethodKeysOf<Doc, Path>, ContentType extends RequestContentTypesOf<Doc, Path, Method> = RequestContentTypesOf<Doc, Path, Method>>({
|
|
243
296
|
schema: doc,
|
|
244
297
|
path,
|
|
@@ -251,6 +304,11 @@ declare function ApiRequestBody<Doc = unknown, Path extends PathKeysOf<Doc> = Pa
|
|
|
251
304
|
onDiagnostic,
|
|
252
305
|
strict
|
|
253
306
|
}: ApiRequestBodyProps<Doc, Path, Method, ContentType>): ReactNode;
|
|
307
|
+
/**
|
|
308
|
+
* Props accepted by {@link ApiResponse}.
|
|
309
|
+
*
|
|
310
|
+
* @group OpenAPI
|
|
311
|
+
*/
|
|
254
312
|
interface ApiResponseProps<Doc = unknown, Path extends PathKeysOf<Doc> = PathKeysOf<Doc>, Method extends MethodKeysOf<Doc, Path> = MethodKeysOf<Doc, Path>, Status extends StatusKeysOf<Doc, Path, Method> = StatusKeysOf<Doc, Path, Method>, ContentType extends ResponseContentTypesOf<Doc, Path, Method, Status> = ResponseContentTypesOf<Doc, Path, Method, Status>> extends ApiDiagnosticsProps {
|
|
255
313
|
schema: Doc;
|
|
256
314
|
path: Path;
|
|
@@ -269,6 +327,18 @@ interface ApiResponseProps<Doc = unknown, Path extends PathKeysOf<Doc> = PathKey
|
|
|
269
327
|
/** Instance-scoped widgets. */
|
|
270
328
|
widgets?: WidgetMap;
|
|
271
329
|
}
|
|
330
|
+
/**
|
|
331
|
+
* Render the response schema for a single OpenAPI operation status —
|
|
332
|
+
* picked out of `schema` by `path`, `method`, and `status`.
|
|
333
|
+
*
|
|
334
|
+
* Status resolution follows the OpenAPI priority order: concrete code
|
|
335
|
+
* (e.g. `"200"`) > class wildcard (e.g. `"2XX"`) > `"default"`. When
|
|
336
|
+
* `schema` is typed `as const`, `fields` autocomplete resolves from
|
|
337
|
+
* the response schema; pass `contentType` to narrow inference to a
|
|
338
|
+
* specific media type.
|
|
339
|
+
*
|
|
340
|
+
* @group OpenAPI
|
|
341
|
+
*/
|
|
272
342
|
declare function ApiResponse<Doc = unknown, Path extends PathKeysOf<Doc> = PathKeysOf<Doc>, Method extends MethodKeysOf<Doc, Path> = MethodKeysOf<Doc, Path>, Status extends StatusKeysOf<Doc, Path, Method> = StatusKeysOf<Doc, Path, Method>, ContentType extends ResponseContentTypesOf<Doc, Path, Method, Status> = ResponseContentTypesOf<Doc, Path, Method, Status>>({
|
|
273
343
|
schema: doc,
|
|
274
344
|
path,
|
|
@@ -282,14 +352,9 @@ declare function ApiResponse<Doc = unknown, Path extends PathKeysOf<Doc> = PathK
|
|
|
282
352
|
strict
|
|
283
353
|
}: ApiResponseProps<Doc, Path, Method, Status, ContentType>): ReactNode;
|
|
284
354
|
/**
|
|
285
|
-
*
|
|
286
|
-
* Object under the document's top-level `webhooks` map; once resolved,
|
|
287
|
-
* its operations are structurally identical to operations under `paths`.
|
|
355
|
+
* Props accepted by {@link ApiWebhook}.
|
|
288
356
|
*
|
|
289
|
-
*
|
|
290
|
-
* on the webhook's Path Item Object. The parser's `lookupPathItem`
|
|
291
|
-
* resolves webhook names through the same code path as paths, so
|
|
292
|
-
* `ApiOperation` works for both with no special-casing in the renderer.
|
|
357
|
+
* @group OpenAPI
|
|
293
358
|
*/
|
|
294
359
|
interface ApiWebhookProps extends ApiDiagnosticsProps {
|
|
295
360
|
schema: unknown;
|
|
@@ -299,6 +364,18 @@ interface ApiWebhookProps extends ApiDiagnosticsProps {
|
|
|
299
364
|
widgets?: WidgetMap;
|
|
300
365
|
meta?: SchemaMeta;
|
|
301
366
|
}
|
|
367
|
+
/**
|
|
368
|
+
* Render a single OpenAPI 3.1 webhook by name. A webhook is a Path Item
|
|
369
|
+
* Object under the document's top-level `webhooks` map; once resolved,
|
|
370
|
+
* its operations are structurally identical to operations under `paths`.
|
|
371
|
+
*
|
|
372
|
+
* Delegates to {@link ApiOperation} for each method present on the
|
|
373
|
+
* webhook's Path Item Object — the parser's `lookupPathItem` resolves
|
|
374
|
+
* webhook names through the same code path as paths, so `ApiOperation`
|
|
375
|
+
* works for both with no special-casing in the renderer.
|
|
376
|
+
*
|
|
377
|
+
* @group OpenAPI
|
|
378
|
+
*/
|
|
302
379
|
declare function ApiWebhook({
|
|
303
380
|
schema: doc,
|
|
304
381
|
name,
|
|
@@ -308,15 +385,22 @@ declare function ApiWebhook({
|
|
|
308
385
|
strict
|
|
309
386
|
}: ApiWebhookProps): ReactNode;
|
|
310
387
|
/**
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
388
|
+
* Props accepted by {@link ApiWebhooks}.
|
|
389
|
+
*
|
|
390
|
+
* @group OpenAPI
|
|
314
391
|
*/
|
|
315
392
|
interface ApiWebhooksProps extends ApiDiagnosticsProps {
|
|
316
393
|
schema: unknown;
|
|
317
394
|
widgets?: WidgetMap;
|
|
318
395
|
meta?: SchemaMeta;
|
|
319
396
|
}
|
|
397
|
+
/**
|
|
398
|
+
* Render every OpenAPI 3.1 webhook declared on the document, one
|
|
399
|
+
* `<ApiWebhook>` per entry. Returns `null` when the document has no
|
|
400
|
+
* `webhooks` map or the map is empty.
|
|
401
|
+
*
|
|
402
|
+
* @group OpenAPI
|
|
403
|
+
*/
|
|
320
404
|
declare function ApiWebhooks({
|
|
321
405
|
schema: doc,
|
|
322
406
|
widgets,
|
|
@@ -107,6 +107,25 @@ function SchemaXmlFootnote({ xml }) {
|
|
|
107
107
|
] })
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Render a single OpenAPI operation — header, parameters, request body,
|
|
112
|
+
* responses, callbacks, security, and external docs — picked out of a
|
|
113
|
+
* supplied document by `path` and `method`.
|
|
114
|
+
*
|
|
115
|
+
* When `schema` is typed `as const`, `requestBodyFields` autocomplete
|
|
116
|
+
* resolves from the operation's request body schema. The component
|
|
117
|
+
* works with OpenAPI 2.0, 3.0, and 3.1 inputs (Swagger 2.0 documents
|
|
118
|
+
* are normalised to 3.1 internally) and also resolves OpenAPI 3.1
|
|
119
|
+
* webhooks under the same code path.
|
|
120
|
+
*
|
|
121
|
+
* @group OpenAPI
|
|
122
|
+
* @example
|
|
123
|
+
* ```tsx
|
|
124
|
+
* import { ApiOperation } from "schema-components/openapi/components";
|
|
125
|
+
*
|
|
126
|
+
* <ApiOperation schema={petStore} path="/pets" method="post" />
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
110
129
|
function ApiOperation({ schema: doc, path, method, requestBodyValue, onRequestBodyChange, responseValue, meta, requestBodyFields, widgets, onDiagnostic, strict }) {
|
|
111
130
|
const diagnostics = buildDiagnostics(onDiagnostic, strict);
|
|
112
131
|
const instancePrefix = sanitisePrefix(useId());
|
|
@@ -184,6 +203,14 @@ function ApiOperation({ schema: doc, path, method, requestBodyValue, onRequestBo
|
|
|
184
203
|
]
|
|
185
204
|
});
|
|
186
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* Render the `parameters` of a single OpenAPI operation — path, query,
|
|
208
|
+
* header, and cookie parameters — picked out of `schema` by `path` and
|
|
209
|
+
* `method`. When the document is typed `as const`, the `overrides` prop
|
|
210
|
+
* autocompletes on each parameter name.
|
|
211
|
+
*
|
|
212
|
+
* @group OpenAPI
|
|
213
|
+
*/
|
|
187
214
|
function ApiParameters({ schema: doc, path, method, meta, overrides, widgets, onDiagnostic, strict }) {
|
|
188
215
|
const diagnostics = buildDiagnostics(onDiagnostic, strict);
|
|
189
216
|
const instancePrefix = sanitisePrefix(useId());
|
|
@@ -205,6 +232,17 @@ function ApiParameters({ schema: doc, path, method, meta, overrides, widgets, on
|
|
|
205
232
|
})]
|
|
206
233
|
});
|
|
207
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* Render the request body of a single OpenAPI operation, picked out of
|
|
237
|
+
* `schema` by `path` and `method`. Returns `null` when the operation
|
|
238
|
+
* declares no request body or no resolvable schema.
|
|
239
|
+
*
|
|
240
|
+
* When `schema` is typed `as const`, `fields` autocomplete resolves
|
|
241
|
+
* from the request body schema; pass `contentType` to narrow inference
|
|
242
|
+
* to a specific media type.
|
|
243
|
+
*
|
|
244
|
+
* @group OpenAPI
|
|
245
|
+
*/
|
|
208
246
|
function ApiRequestBody({ schema: doc, path, method, value, onChange, meta, fields, widgets, onDiagnostic, strict }) {
|
|
209
247
|
const diagnostics = buildDiagnostics(onDiagnostic, strict);
|
|
210
248
|
const instancePrefix = sanitisePrefix(useId());
|
|
@@ -237,6 +275,18 @@ function ApiRequestBody({ schema: doc, path, method, value, onChange, meta, fiel
|
|
|
237
275
|
]
|
|
238
276
|
});
|
|
239
277
|
}
|
|
278
|
+
/**
|
|
279
|
+
* Render the response schema for a single OpenAPI operation status —
|
|
280
|
+
* picked out of `schema` by `path`, `method`, and `status`.
|
|
281
|
+
*
|
|
282
|
+
* Status resolution follows the OpenAPI priority order: concrete code
|
|
283
|
+
* (e.g. `"200"`) > class wildcard (e.g. `"2XX"`) > `"default"`. When
|
|
284
|
+
* `schema` is typed `as const`, `fields` autocomplete resolves from
|
|
285
|
+
* the response schema; pass `contentType` to narrow inference to a
|
|
286
|
+
* specific media type.
|
|
287
|
+
*
|
|
288
|
+
* @group OpenAPI
|
|
289
|
+
*/
|
|
240
290
|
function ApiResponse({ schema: doc, path, method, status, value, meta, fields, widgets, onDiagnostic, strict }) {
|
|
241
291
|
const diagnostics = buildDiagnostics(onDiagnostic, strict);
|
|
242
292
|
const instancePrefix = sanitisePrefix(useId());
|
|
@@ -265,6 +315,18 @@ function ApiResponse({ schema: doc, path, method, status, value, meta, fields, w
|
|
|
265
315
|
idPrefix: instancePrefix
|
|
266
316
|
});
|
|
267
317
|
}
|
|
318
|
+
/**
|
|
319
|
+
* Render a single OpenAPI 3.1 webhook by name. A webhook is a Path Item
|
|
320
|
+
* Object under the document's top-level `webhooks` map; once resolved,
|
|
321
|
+
* its operations are structurally identical to operations under `paths`.
|
|
322
|
+
*
|
|
323
|
+
* Delegates to {@link ApiOperation} for each method present on the
|
|
324
|
+
* webhook's Path Item Object — the parser's `lookupPathItem` resolves
|
|
325
|
+
* webhook names through the same code path as paths, so `ApiOperation`
|
|
326
|
+
* works for both with no special-casing in the renderer.
|
|
327
|
+
*
|
|
328
|
+
* @group OpenAPI
|
|
329
|
+
*/
|
|
268
330
|
function ApiWebhook({ schema: doc, name, widgets, meta, onDiagnostic, strict }) {
|
|
269
331
|
const diagnostics = buildDiagnostics(onDiagnostic, strict);
|
|
270
332
|
const instancePrefix = sanitisePrefix(useId());
|
|
@@ -287,6 +349,13 @@ function ApiWebhook({ schema: doc, name, widgets, meta, onDiagnostic, strict })
|
|
|
287
349
|
})]
|
|
288
350
|
});
|
|
289
351
|
}
|
|
352
|
+
/**
|
|
353
|
+
* Render every OpenAPI 3.1 webhook declared on the document, one
|
|
354
|
+
* `<ApiWebhook>` per entry. Returns `null` when the document has no
|
|
355
|
+
* `webhooks` map or the map is empty.
|
|
356
|
+
*
|
|
357
|
+
* @group OpenAPI
|
|
358
|
+
*/
|
|
290
359
|
function ApiWebhooks({ schema: doc, widgets, meta, onDiagnostic, strict }) {
|
|
291
360
|
const diagnostics = buildDiagnostics(onDiagnostic, strict);
|
|
292
361
|
const instancePrefix = sanitisePrefix(useId());
|