schema-components 1.20.0 → 1.22.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 +1 -1
- package/dist/core/adapter.d.mts +28 -4
- package/dist/core/adapter.mjs +408 -71
- package/dist/core/constraints.d.mts +2 -2
- package/dist/core/constraints.mjs +0 -2
- package/dist/core/diagnostics.d.mts +1 -1
- package/dist/core/errors.d.mts +1 -1
- package/dist/core/errors.mjs +9 -15
- package/dist/core/fieldOrder.d.mts +1 -1
- package/dist/core/formats.d.mts +22 -1
- package/dist/core/formats.mjs +21 -0
- package/dist/core/limits.d.mts +2 -0
- package/dist/core/limits.mjs +23 -0
- package/dist/core/merge.d.mts +11 -2
- package/dist/core/merge.mjs +11 -0
- package/dist/core/normalise.d.mts +36 -4
- package/dist/core/normalise.mjs +2 -2
- package/dist/core/openapi30.d.mts +24 -1
- package/dist/core/openapi30.mjs +2 -2
- package/dist/core/ref.d.mts +1 -1
- package/dist/core/ref.mjs +35 -9
- 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 +2 -2
- package/dist/core/types.d.mts +2 -2
- package/dist/core/types.mjs +1 -4
- package/dist/core/version.d.mts +1 -1
- package/dist/core/walkBuilders.d.mts +13 -5
- package/dist/core/walkBuilders.mjs +11 -3
- package/dist/core/walker.d.mts +1 -1
- package/dist/core/walker.mjs +110 -26
- package/dist/{diagnostics-CbBPsxSt.d.mts → diagnostics-D0QCYGv0.d.mts} +1 -1
- package/dist/{errors-C2iABcn9.d.mts → errors-DpFwqs5C.d.mts} +7 -11
- package/dist/html/a11y.d.mts +2 -2
- package/dist/html/a11y.mjs +10 -3
- 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/renderers.d.mts +2 -2
- package/dist/html/renderers.mjs +1 -6
- package/dist/html/streamRenderers.d.mts +5 -4
- package/dist/html/streamRenderers.mjs +91 -30
- package/dist/limits-Cw5QZND8.d.mts +29 -0
- package/dist/{normalise-CMMEl4cd.mjs → normalise-DVEJQmF7.mjs} +791 -141
- 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 +127 -7
- package/dist/openapi/components.d.mts +175 -21
- package/dist/openapi/components.mjs +145 -21
- package/dist/openapi/parser.d.mts +1 -1
- package/dist/openapi/parser.mjs +74 -7
- package/dist/openapi/resolve.d.mts +70 -12
- package/dist/openapi/resolve.mjs +265 -42
- package/dist/react/SchemaComponent.d.mts +100 -35
- package/dist/react/SchemaComponent.mjs +66 -24
- package/dist/react/SchemaView.d.mts +3 -3
- package/dist/react/SchemaView.mjs +2 -2
- 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 +3 -4
- package/dist/react/headlessRenderers.mjs +11 -31
- package/dist/{ref-C8JbwfiS.d.mts → ref-D-_JBZkF.d.mts} +7 -2
- package/dist/{renderer-SOIbJBtk.d.mts → renderer-BaRlQIuN.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/typeInference-DkcUHfaM.d.mts +982 -0
- package/dist/{types-C9zw9wbX.d.mts → types-BrRMV0en.d.mts} +15 -12
- package/package.json +1 -3
- package/dist/typeInference-CDoD_LZ_.d.mts +0 -533
- /package/dist/{version-D-u7aMfy.d.mts → version-D2jfdX6E.d.mts} +0 -0
|
@@ -1,5 +1,58 @@
|
|
|
1
|
+
import { isObject } from "../core/guards.mjs";
|
|
1
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
3
|
//#region src/openapi/ApiSecurity.tsx
|
|
4
|
+
/**
|
|
5
|
+
* The four OAuth 2 flow keys defined by OpenAPI 3.x. Listed in the
|
|
6
|
+
* canonical specification order so renders are deterministic.
|
|
7
|
+
*/
|
|
8
|
+
const OAUTH_FLOW_KEYS = [
|
|
9
|
+
"implicit",
|
|
10
|
+
"password",
|
|
11
|
+
"clientCredentials",
|
|
12
|
+
"authorizationCode"
|
|
13
|
+
];
|
|
14
|
+
/**
|
|
15
|
+
* Known Security Scheme `type` values per the OpenAPI 3.0/3.1 spec.
|
|
16
|
+
* Used to flag unknown values in the rendered output so authors can
|
|
17
|
+
* spot typos like `mutalTLS` without consulting the diagnostic sink.
|
|
18
|
+
*/
|
|
19
|
+
const KNOWN_SECURITY_SCHEME_TYPES = new Set([
|
|
20
|
+
"apiKey",
|
|
21
|
+
"http",
|
|
22
|
+
"oauth2",
|
|
23
|
+
"openIdConnect",
|
|
24
|
+
"mutualTLS"
|
|
25
|
+
]);
|
|
26
|
+
function readString(source, key) {
|
|
27
|
+
const value = source[key];
|
|
28
|
+
return typeof value === "string" ? value : void 0;
|
|
29
|
+
}
|
|
30
|
+
function readScopes(source) {
|
|
31
|
+
const scopes = source.scopes;
|
|
32
|
+
const result = /* @__PURE__ */ new Map();
|
|
33
|
+
if (!isObject(scopes)) return result;
|
|
34
|
+
for (const [name, description] of Object.entries(scopes)) {
|
|
35
|
+
if (typeof description !== "string") continue;
|
|
36
|
+
result.set(name, description);
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
function extractFlows(flows) {
|
|
41
|
+
if (flows === void 0) return [];
|
|
42
|
+
const result = [];
|
|
43
|
+
for (const name of OAUTH_FLOW_KEYS) {
|
|
44
|
+
const flow = flows[name];
|
|
45
|
+
if (!isObject(flow)) continue;
|
|
46
|
+
result.push({
|
|
47
|
+
name,
|
|
48
|
+
authorizationUrl: readString(flow, "authorizationUrl"),
|
|
49
|
+
tokenUrl: readString(flow, "tokenUrl"),
|
|
50
|
+
refreshUrl: readString(flow, "refreshUrl"),
|
|
51
|
+
scopes: readScopes(flow)
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
3
56
|
function ApiSecurity({ requirements, schemes }) {
|
|
4
57
|
if (requirements.length === 0) return null;
|
|
5
58
|
return /* @__PURE__ */ jsxs("section", {
|
|
@@ -13,13 +66,7 @@ function ApiSecurity({ requirements, schemes }) {
|
|
|
13
66
|
"data-security-name": true,
|
|
14
67
|
children: req.name
|
|
15
68
|
}),
|
|
16
|
-
scheme !== void 0 && /* @__PURE__ */
|
|
17
|
-
"data-security-type": true,
|
|
18
|
-
children: scheme.type
|
|
19
|
-
}), scheme.description && /* @__PURE__ */ jsx("span", {
|
|
20
|
-
"data-security-description": true,
|
|
21
|
-
children: scheme.description
|
|
22
|
-
})] }),
|
|
69
|
+
scheme !== void 0 && /* @__PURE__ */ jsx(SchemeDetails, { scheme }),
|
|
23
70
|
req.scopes.length > 0 && /* @__PURE__ */ jsx("span", {
|
|
24
71
|
"data-security-scopes": true,
|
|
25
72
|
children: req.scopes.join(", ")
|
|
@@ -29,5 +76,78 @@ function ApiSecurity({ requirements, schemes }) {
|
|
|
29
76
|
})]
|
|
30
77
|
});
|
|
31
78
|
}
|
|
79
|
+
function SchemeDetails({ scheme }) {
|
|
80
|
+
const flows = extractFlows(scheme.flows);
|
|
81
|
+
const isKnownType = scheme.type !== void 0 && KNOWN_SECURITY_SCHEME_TYPES.has(scheme.type);
|
|
82
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
83
|
+
scheme.type !== void 0 && /* @__PURE__ */ jsxs("span", {
|
|
84
|
+
"data-security-type": true,
|
|
85
|
+
"data-security-type-unknown": isKnownType ? void 0 : "true",
|
|
86
|
+
children: [scheme.type, !isKnownType && " (unknown type)"]
|
|
87
|
+
}),
|
|
88
|
+
scheme.description !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
89
|
+
"data-security-description": true,
|
|
90
|
+
children: scheme.description
|
|
91
|
+
}),
|
|
92
|
+
scheme.scheme !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
93
|
+
"data-security-http-scheme": true,
|
|
94
|
+
children: scheme.scheme
|
|
95
|
+
}),
|
|
96
|
+
scheme.bearerFormat !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
97
|
+
"data-security-bearer-format": true,
|
|
98
|
+
children: scheme.bearerFormat
|
|
99
|
+
}),
|
|
100
|
+
scheme.name !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
101
|
+
"data-security-apikey-name": true,
|
|
102
|
+
children: scheme.name
|
|
103
|
+
}),
|
|
104
|
+
scheme.location !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
105
|
+
"data-security-apikey-in": true,
|
|
106
|
+
children: scheme.location
|
|
107
|
+
}),
|
|
108
|
+
scheme.openIdConnectUrl !== void 0 && /* @__PURE__ */ jsx("a", {
|
|
109
|
+
"data-security-openid-url": true,
|
|
110
|
+
href: scheme.openIdConnectUrl,
|
|
111
|
+
children: scheme.openIdConnectUrl
|
|
112
|
+
}),
|
|
113
|
+
flows.length > 0 && /* @__PURE__ */ jsx("section", {
|
|
114
|
+
"data-security-flows": true,
|
|
115
|
+
children: flows.map((flow) => /* @__PURE__ */ jsx(FlowDetails, { flow }, flow.name))
|
|
116
|
+
})
|
|
117
|
+
] });
|
|
118
|
+
}
|
|
119
|
+
function FlowDetails({ flow }) {
|
|
120
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
121
|
+
"data-security-flow": flow.name,
|
|
122
|
+
children: [
|
|
123
|
+
/* @__PURE__ */ jsx("span", {
|
|
124
|
+
"data-security-flow-name": true,
|
|
125
|
+
children: flow.name
|
|
126
|
+
}),
|
|
127
|
+
flow.authorizationUrl !== void 0 && /* @__PURE__ */ jsx("a", {
|
|
128
|
+
"data-security-flow-authorization-url": true,
|
|
129
|
+
href: flow.authorizationUrl,
|
|
130
|
+
children: flow.authorizationUrl
|
|
131
|
+
}),
|
|
132
|
+
flow.tokenUrl !== void 0 && /* @__PURE__ */ jsx("a", {
|
|
133
|
+
"data-security-flow-token-url": true,
|
|
134
|
+
href: flow.tokenUrl,
|
|
135
|
+
children: flow.tokenUrl
|
|
136
|
+
}),
|
|
137
|
+
flow.refreshUrl !== void 0 && /* @__PURE__ */ jsx("a", {
|
|
138
|
+
"data-security-flow-refresh-url": true,
|
|
139
|
+
href: flow.refreshUrl,
|
|
140
|
+
children: flow.refreshUrl
|
|
141
|
+
}),
|
|
142
|
+
flow.scopes.size > 0 && /* @__PURE__ */ jsx("dl", {
|
|
143
|
+
"data-security-flow-scopes": true,
|
|
144
|
+
children: [...flow.scopes.entries()].map(([name, description]) => /* @__PURE__ */ jsxs("div", {
|
|
145
|
+
"data-security-flow-scope": name,
|
|
146
|
+
children: [/* @__PURE__ */ jsx("dt", { children: name }), /* @__PURE__ */ jsx("dd", { children: description })]
|
|
147
|
+
}, name))
|
|
148
|
+
})
|
|
149
|
+
]
|
|
150
|
+
});
|
|
151
|
+
}
|
|
32
152
|
//#endregion
|
|
33
153
|
export { ApiSecurity };
|
|
@@ -1,10 +1,99 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { u as FieldOverride, w as SchemaMeta } from "../types-BrRMV0en.mjs";
|
|
2
|
+
import { r as DiagnosticSink } from "../diagnostics-D0QCYGv0.mjs";
|
|
3
|
+
import { a as InferParameterOverrides, g as UnsafeFields, o as InferRequestBodyFields, s as InferResponseFields } from "../typeInference-DkcUHfaM.mjs";
|
|
3
4
|
import { WidgetMap } from "../react/SchemaComponent.mjs";
|
|
4
5
|
import { ReactNode } from "react";
|
|
5
6
|
|
|
6
7
|
//#region src/openapi/components.d.ts
|
|
7
|
-
|
|
8
|
+
/**
|
|
9
|
+
* The canonical set of HTTP method strings recognised by OpenAPI 3.x.
|
|
10
|
+
* Used to constrain `Method` generics so autocomplete on typed
|
|
11
|
+
* documents only suggests methods the path item actually declares,
|
|
12
|
+
* not arbitrary string keys.
|
|
13
|
+
*/
|
|
14
|
+
type HttpMethod = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace";
|
|
15
|
+
/**
|
|
16
|
+
* Extract the literal path keys from a document type, or the broad
|
|
17
|
+
* `string` fallback when the document is untyped at compile time.
|
|
18
|
+
*
|
|
19
|
+
* The `string extends keyof D["paths"]` guard distinguishes a typed
|
|
20
|
+
* `as const` document (whose `paths` map has literal keys) from a
|
|
21
|
+
* runtime `Record<string, unknown>` document (whose `keyof` collapses
|
|
22
|
+
* to `string`). For the runtime case we surface `string` so callers
|
|
23
|
+
* pass arbitrary path values without losing the existing freedom.
|
|
24
|
+
*/
|
|
25
|
+
type PathKeysOf<D> = D extends {
|
|
26
|
+
paths: infer P;
|
|
27
|
+
} ? P extends Record<string, unknown> ? string extends keyof P ? string : Extract<keyof P, string> : string : string;
|
|
28
|
+
/**
|
|
29
|
+
* Extract the methods declared on a specific path item, restricted to
|
|
30
|
+
* the OpenAPI-recognised method set so non-method extension keys
|
|
31
|
+
* (e.g. `summary`, `description`, `parameters`) do not pollute the
|
|
32
|
+
* autocomplete.
|
|
33
|
+
*
|
|
34
|
+
* Runtime documents (typed `Record<string, unknown>`) widen back to
|
|
35
|
+
* `string` so callers retain the freedom to pass arbitrary method
|
|
36
|
+
* strings without surfacing an `HttpMethod` constraint at runtime
|
|
37
|
+
* call sites.
|
|
38
|
+
*/
|
|
39
|
+
type MethodKeysOf<D, P extends string> = IsRuntimeDoc<D> extends true ? string : D extends {
|
|
40
|
+
paths: infer Paths;
|
|
41
|
+
} ? Paths extends Record<string, unknown> ? P extends keyof Paths ? Extract<keyof Paths[P], HttpMethod> : HttpMethod : HttpMethod : HttpMethod;
|
|
42
|
+
/**
|
|
43
|
+
* True for the runtime-document sentinel — a `Record<string, unknown>`
|
|
44
|
+
* (or wider) where `keyof` collapses to `string`. Used to drop
|
|
45
|
+
* narrow-constraint defaults so runtime callers retain the prior
|
|
46
|
+
* freedom to pass arbitrary path/method/status values.
|
|
47
|
+
*/
|
|
48
|
+
type IsRuntimeDoc<D> = D extends Record<string, unknown> ? string extends keyof D ? true : false : false;
|
|
49
|
+
/**
|
|
50
|
+
* Extract the status-code keys declared by an operation's `responses`
|
|
51
|
+
* map. Includes class wildcards (`2XX`, etc.) and the `default`
|
|
52
|
+
* sentinel; runtime documents widen to `string`.
|
|
53
|
+
*/
|
|
54
|
+
type StatusKeysOf<D, P extends string, M extends string> = D extends {
|
|
55
|
+
paths: infer Paths;
|
|
56
|
+
} ? Paths extends Record<string, unknown> ? P extends keyof Paths ? Paths[P] extends Record<string, unknown> ? M extends keyof Paths[P] ? Paths[P][M] extends {
|
|
57
|
+
responses: infer R;
|
|
58
|
+
} ? R extends Record<string, unknown> ? string extends keyof R ? string : Extract<keyof R, string> : string : string : string : string : string : string : string;
|
|
59
|
+
/**
|
|
60
|
+
* Extract the content-type keys declared on a request body's
|
|
61
|
+
* `content` map for the given path and method. Runtime documents
|
|
62
|
+
* widen to `string`.
|
|
63
|
+
*/
|
|
64
|
+
type RequestContentTypesOf<D, P extends string, M extends string> = D extends {
|
|
65
|
+
paths: infer Paths;
|
|
66
|
+
} ? Paths extends Record<string, unknown> ? P extends keyof Paths ? Paths[P] extends Record<string, unknown> ? M extends keyof Paths[P] ? Paths[P][M] extends {
|
|
67
|
+
requestBody: {
|
|
68
|
+
content: infer C;
|
|
69
|
+
};
|
|
70
|
+
} ? C extends Record<string, unknown> ? string extends keyof C ? string : Extract<keyof C, string> : string : string : string : string : string : string : string;
|
|
71
|
+
/**
|
|
72
|
+
* Extract the content-type keys declared on a response entry's
|
|
73
|
+
* `content` map for the given path, method, and status. Runtime
|
|
74
|
+
* documents widen to `string`.
|
|
75
|
+
*/
|
|
76
|
+
type ResponseContentTypesOf<D, P extends string, M extends string, S extends string> = D extends {
|
|
77
|
+
paths: infer Paths;
|
|
78
|
+
} ? Paths extends Record<string, unknown> ? P extends keyof Paths ? Paths[P] extends Record<string, unknown> ? M extends keyof Paths[P] ? Paths[P][M] extends {
|
|
79
|
+
responses: infer R;
|
|
80
|
+
} ? R extends Record<string, unknown> ? S extends keyof R ? R[S] extends {
|
|
81
|
+
content: infer C;
|
|
82
|
+
} ? C extends Record<string, unknown> ? string extends keyof C ? string : Extract<keyof C, string> : string : string : string : string : string : string : string : string : string : string;
|
|
83
|
+
/**
|
|
84
|
+
* Diagnostics props accepted by every top-level OpenAPI component.
|
|
85
|
+
*
|
|
86
|
+
* `onDiagnostic` is the sink invoked for each event surfaced by the
|
|
87
|
+
* normalisation pipeline (duplicate body parameter, dropped Swagger
|
|
88
|
+
* feature, divisible-by conflict, unknown JSON Schema dialect,
|
|
89
|
+
* relative-ref resolved, etc.). `strict` converts every emitted
|
|
90
|
+
* diagnostic into a thrown `SchemaNormalisationError`.
|
|
91
|
+
*/
|
|
92
|
+
interface ApiDiagnosticsProps {
|
|
93
|
+
onDiagnostic?: DiagnosticSink;
|
|
94
|
+
strict?: boolean;
|
|
95
|
+
}
|
|
96
|
+
interface ApiOperationProps<Doc = unknown, Path extends PathKeysOf<Doc> = PathKeysOf<Doc>, Method extends MethodKeysOf<Doc, Path> = MethodKeysOf<Doc, Path>> extends ApiDiagnosticsProps {
|
|
8
97
|
schema: Doc;
|
|
9
98
|
path: Path;
|
|
10
99
|
method: Method;
|
|
@@ -12,7 +101,7 @@ interface ApiOperationProps<Doc = unknown, Path extends string = string, Method
|
|
|
12
101
|
onRequestBodyChange?: (value: unknown) => void;
|
|
13
102
|
responseValue?: unknown;
|
|
14
103
|
meta?: SchemaMeta;
|
|
15
|
-
requestBodyFields?: Doc extends Record<string, unknown> ? InferRequestBodyFields<Doc, Path, Method> : Record<string, FieldOverride>;
|
|
104
|
+
requestBodyFields?: Doc extends Record<string, unknown> ? InferRequestBodyFields<Doc, Path & string, Method & string> : Record<string, FieldOverride>;
|
|
16
105
|
/** Escape hatch for recursive schemas where type-level inference fails.
|
|
17
106
|
* Typed as Record<string, FieldOverride> — use when the schema contains
|
|
18
107
|
* deeply nested $ref chains.
|
|
@@ -21,7 +110,7 @@ interface ApiOperationProps<Doc = unknown, Path extends string = string, Method
|
|
|
21
110
|
/** Instance-scoped widgets. */
|
|
22
111
|
widgets?: WidgetMap;
|
|
23
112
|
}
|
|
24
|
-
declare function ApiOperation<Doc = unknown, Path extends
|
|
113
|
+
declare function ApiOperation<Doc = unknown, Path extends PathKeysOf<Doc> = PathKeysOf<Doc>, Method extends MethodKeysOf<Doc, Path> = MethodKeysOf<Doc, Path>>({
|
|
25
114
|
schema: doc,
|
|
26
115
|
path,
|
|
27
116
|
method,
|
|
@@ -30,37 +119,48 @@ declare function ApiOperation<Doc = unknown, Path extends string = string, Metho
|
|
|
30
119
|
responseValue,
|
|
31
120
|
meta,
|
|
32
121
|
requestBodyFields,
|
|
33
|
-
widgets
|
|
122
|
+
widgets,
|
|
123
|
+
onDiagnostic,
|
|
124
|
+
strict
|
|
34
125
|
}: ApiOperationProps<Doc, Path, Method>): ReactNode;
|
|
35
|
-
interface ApiParametersProps<Doc = unknown, Path extends
|
|
126
|
+
interface ApiParametersProps<Doc = unknown, Path extends PathKeysOf<Doc> = PathKeysOf<Doc>, Method extends MethodKeysOf<Doc, Path> = MethodKeysOf<Doc, Path>> extends ApiDiagnosticsProps {
|
|
36
127
|
schema: Doc;
|
|
37
128
|
path: Path;
|
|
38
129
|
method: Method;
|
|
39
130
|
meta?: SchemaMeta;
|
|
40
|
-
overrides?: Doc extends Record<string, unknown> ? InferParameterOverrides<Doc, Path, Method> : Record<string, FieldOverride>;
|
|
131
|
+
overrides?: Doc extends Record<string, unknown> ? InferParameterOverrides<Doc, Path & string, Method & string> : Record<string, FieldOverride>;
|
|
41
132
|
/** Instance-scoped widgets. */
|
|
42
133
|
widgets?: WidgetMap;
|
|
43
134
|
}
|
|
44
|
-
declare function ApiParameters<Doc = unknown, Path extends
|
|
135
|
+
declare function ApiParameters<Doc = unknown, Path extends PathKeysOf<Doc> = PathKeysOf<Doc>, Method extends MethodKeysOf<Doc, Path> = MethodKeysOf<Doc, Path>>({
|
|
45
136
|
schema: doc,
|
|
46
137
|
path,
|
|
47
138
|
method,
|
|
48
139
|
meta,
|
|
49
140
|
overrides,
|
|
50
|
-
widgets
|
|
141
|
+
widgets,
|
|
142
|
+
onDiagnostic,
|
|
143
|
+
strict
|
|
51
144
|
}: ApiParametersProps<Doc, Path, Method>): ReactNode;
|
|
52
|
-
interface ApiRequestBodyProps<Doc = unknown, Path extends
|
|
145
|
+
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 {
|
|
53
146
|
schema: Doc;
|
|
54
147
|
path: Path;
|
|
55
148
|
method: Method;
|
|
149
|
+
/**
|
|
150
|
+
* Media type whose schema should be rendered for the request body.
|
|
151
|
+
* Defaults to the union of declared content types so callers can
|
|
152
|
+
* omit it; supply explicitly to narrow `fields` inference to a
|
|
153
|
+
* specific media type via {@link InferRequestBodyFields}.
|
|
154
|
+
*/
|
|
155
|
+
contentType?: ContentType;
|
|
56
156
|
value?: unknown;
|
|
57
157
|
onChange?: (value: unknown) => void;
|
|
58
158
|
meta?: SchemaMeta;
|
|
59
|
-
fields?: Doc extends Record<string, unknown> ? InferRequestBodyFields<Doc, Path, Method> : Record<string, FieldOverride>;
|
|
159
|
+
fields?: Doc extends Record<string, unknown> ? InferRequestBodyFields<Doc, Path & string, Method & string, ContentType & string> : Record<string, FieldOverride>;
|
|
60
160
|
/** Instance-scoped widgets. */
|
|
61
161
|
widgets?: WidgetMap;
|
|
62
162
|
}
|
|
63
|
-
declare function ApiRequestBody<Doc = unknown, Path extends
|
|
163
|
+
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>>({
|
|
64
164
|
schema: doc,
|
|
65
165
|
path,
|
|
66
166
|
method,
|
|
@@ -68,20 +168,29 @@ declare function ApiRequestBody<Doc = unknown, Path extends string = string, Met
|
|
|
68
168
|
onChange,
|
|
69
169
|
meta,
|
|
70
170
|
fields,
|
|
71
|
-
widgets
|
|
72
|
-
|
|
73
|
-
|
|
171
|
+
widgets,
|
|
172
|
+
onDiagnostic,
|
|
173
|
+
strict
|
|
174
|
+
}: ApiRequestBodyProps<Doc, Path, Method, ContentType>): ReactNode;
|
|
175
|
+
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 {
|
|
74
176
|
schema: Doc;
|
|
75
177
|
path: Path;
|
|
76
178
|
method: Method;
|
|
77
179
|
status: Status;
|
|
180
|
+
/**
|
|
181
|
+
* Media type whose schema should be rendered. Defaults to the
|
|
182
|
+
* union of declared content types so callers can omit it;
|
|
183
|
+
* supply explicitly to narrow `fields` inference via
|
|
184
|
+
* {@link InferResponseFields}.
|
|
185
|
+
*/
|
|
186
|
+
contentType?: ContentType;
|
|
78
187
|
value?: unknown;
|
|
79
188
|
meta?: SchemaMeta;
|
|
80
|
-
fields?: Doc extends Record<string, unknown> ? InferResponseFields<Doc, Path, Method, Status> : Record<string, FieldOverride>;
|
|
189
|
+
fields?: Doc extends Record<string, unknown> ? InferResponseFields<Doc, Path & string, Method & string, Status & string, ContentType & string> : Record<string, FieldOverride>;
|
|
81
190
|
/** Instance-scoped widgets. */
|
|
82
191
|
widgets?: WidgetMap;
|
|
83
192
|
}
|
|
84
|
-
declare function ApiResponse<Doc = unknown, Path extends
|
|
193
|
+
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>>({
|
|
85
194
|
schema: doc,
|
|
86
195
|
path,
|
|
87
196
|
method,
|
|
@@ -89,7 +198,52 @@ declare function ApiResponse<Doc = unknown, Path extends string = string, Method
|
|
|
89
198
|
value,
|
|
90
199
|
meta,
|
|
91
200
|
fields,
|
|
92
|
-
widgets
|
|
93
|
-
|
|
201
|
+
widgets,
|
|
202
|
+
onDiagnostic,
|
|
203
|
+
strict
|
|
204
|
+
}: ApiResponseProps<Doc, Path, Method, Status, ContentType>): ReactNode;
|
|
205
|
+
/**
|
|
206
|
+
* Render a single OpenAPI 3.1 webhook by name. A webhook is a Path Item
|
|
207
|
+
* Object under the document's top-level `webhooks` map; once resolved,
|
|
208
|
+
* its operations are structurally identical to operations under `paths`.
|
|
209
|
+
*
|
|
210
|
+
* Internally, this delegates to `ApiOperation` for each method present
|
|
211
|
+
* on the webhook's Path Item Object. The parser's `lookupPathItem`
|
|
212
|
+
* resolves webhook names through the same code path as paths, so
|
|
213
|
+
* `ApiOperation` works for both with no special-casing in the renderer.
|
|
214
|
+
*/
|
|
215
|
+
interface ApiWebhookProps extends ApiDiagnosticsProps {
|
|
216
|
+
schema: unknown;
|
|
217
|
+
/** Webhook name (key under the document's `webhooks` map). */
|
|
218
|
+
name: string;
|
|
219
|
+
/** Instance-scoped widgets, forwarded to each rendered operation. */
|
|
220
|
+
widgets?: WidgetMap;
|
|
221
|
+
meta?: SchemaMeta;
|
|
222
|
+
}
|
|
223
|
+
declare function ApiWebhook({
|
|
224
|
+
schema: doc,
|
|
225
|
+
name,
|
|
226
|
+
widgets,
|
|
227
|
+
meta,
|
|
228
|
+
onDiagnostic,
|
|
229
|
+
strict
|
|
230
|
+
}: ApiWebhookProps): ReactNode;
|
|
231
|
+
/**
|
|
232
|
+
* Render every OpenAPI 3.1 webhook declared on the document, one
|
|
233
|
+
* `<ApiWebhook>` per entry. Returns `null` when the document has no
|
|
234
|
+
* `webhooks` map or it is empty.
|
|
235
|
+
*/
|
|
236
|
+
interface ApiWebhooksProps extends ApiDiagnosticsProps {
|
|
237
|
+
schema: unknown;
|
|
238
|
+
widgets?: WidgetMap;
|
|
239
|
+
meta?: SchemaMeta;
|
|
240
|
+
}
|
|
241
|
+
declare function ApiWebhooks({
|
|
242
|
+
schema: doc,
|
|
243
|
+
widgets,
|
|
244
|
+
meta,
|
|
245
|
+
onDiagnostic,
|
|
246
|
+
strict
|
|
247
|
+
}: ApiWebhooksProps): ReactNode;
|
|
94
248
|
//#endregion
|
|
95
|
-
export { ApiOperation, ApiOperationProps, ApiParameters, ApiParametersProps, ApiRequestBody, ApiRequestBodyProps, ApiResponse, ApiResponseProps };
|
|
249
|
+
export { ApiOperation, ApiOperationProps, ApiParameters, ApiParametersProps, ApiRequestBody, ApiRequestBodyProps, ApiResponse, ApiResponseProps, ApiWebhook, ApiWebhookProps, ApiWebhooks, ApiWebhooksProps };
|