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.
Files changed (91) hide show
  1. package/README.md +3 -1
  2. package/dist/core/adapter.d.mts +115 -4
  3. package/dist/core/adapter.mjs +405 -75
  4. package/dist/core/constraints.d.mts +2 -2
  5. package/dist/core/constraints.mjs +0 -7
  6. package/dist/core/cssClasses.d.mts +52 -0
  7. package/dist/core/cssClasses.mjs +51 -0
  8. package/dist/core/diagnostics.d.mts +1 -1
  9. package/dist/core/errors.d.mts +1 -1
  10. package/dist/core/errors.mjs +5 -13
  11. package/dist/core/fieldOrder.d.mts +1 -1
  12. package/dist/core/formats.d.mts +30 -2
  13. package/dist/core/formats.mjs +33 -1
  14. package/dist/core/idPath.d.mts +54 -0
  15. package/dist/core/idPath.mjs +66 -0
  16. package/dist/core/limits.d.mts +2 -0
  17. package/dist/core/limits.mjs +23 -0
  18. package/dist/core/merge.d.mts +10 -1
  19. package/dist/core/merge.mjs +49 -10
  20. package/dist/core/normalise.d.mts +40 -3
  21. package/dist/core/normalise.mjs +2 -2
  22. package/dist/core/openapi30.d.mts +15 -1
  23. package/dist/core/openapi30.mjs +2 -2
  24. package/dist/core/openapiConstants.d.mts +67 -0
  25. package/dist/core/openapiConstants.mjs +90 -0
  26. package/dist/core/ref.d.mts +2 -2
  27. package/dist/core/ref.mjs +85 -6
  28. package/dist/core/refChain.d.mts +70 -0
  29. package/dist/core/refChain.mjs +44 -0
  30. package/dist/core/renderer.d.mts +1 -1
  31. package/dist/core/renderer.mjs +0 -2
  32. package/dist/core/swagger2.d.mts +1 -1
  33. package/dist/core/swagger2.mjs +1 -1
  34. package/dist/core/typeInference.d.mts +982 -2
  35. package/dist/core/types.d.mts +2 -2
  36. package/dist/core/types.mjs +1 -4
  37. package/dist/core/unionMatch.d.mts +36 -0
  38. package/dist/core/unionMatch.mjs +53 -0
  39. package/dist/core/version.d.mts +1 -1
  40. package/dist/core/version.mjs +29 -17
  41. package/dist/core/walkBuilders.d.mts +23 -4
  42. package/dist/core/walkBuilders.mjs +27 -7
  43. package/dist/core/walker.d.mts +1 -1
  44. package/dist/core/walker.mjs +123 -47
  45. package/dist/{diagnostics-CbBPsxSt.d.mts → diagnostics-BS2kaUyE.d.mts} +1 -1
  46. package/dist/{errors-QEwOtQAA.d.mts → errors-g_MCTQel.d.mts} +10 -16
  47. package/dist/html/a11y.d.mts +9 -4
  48. package/dist/html/a11y.mjs +10 -12
  49. package/dist/html/renderToHtml.d.mts +10 -3
  50. package/dist/html/renderToHtml.mjs +13 -3
  51. package/dist/html/renderToHtmlStream.d.mts +2 -2
  52. package/dist/html/renderToHtmlStream.mjs +12 -1
  53. package/dist/html/renderers.d.mts +43 -8
  54. package/dist/html/renderers.mjs +136 -116
  55. package/dist/html/streamRenderers.d.mts +6 -6
  56. package/dist/html/streamRenderers.mjs +129 -89
  57. package/dist/limits-Cw5QZND8.d.mts +29 -0
  58. package/dist/{normalise-DaSrnr8g.mjs → normalise-DCYp06Sr.mjs} +770 -227
  59. package/dist/openapi/ApiCallbacks.d.mts +1 -1
  60. package/dist/openapi/ApiLinks.d.mts +1 -1
  61. package/dist/openapi/ApiResponseHeaders.d.mts +1 -1
  62. package/dist/openapi/ApiSecurity.d.mts +1 -1
  63. package/dist/openapi/ApiSecurity.mjs +16 -2
  64. package/dist/openapi/components.d.mts +234 -23
  65. package/dist/openapi/components.mjs +183 -52
  66. package/dist/openapi/parser.d.mts +9 -8
  67. package/dist/openapi/parser.mjs +252 -70
  68. package/dist/openapi/resolve.d.mts +31 -15
  69. package/dist/openapi/resolve.mjs +260 -40
  70. package/dist/react/SchemaComponent.d.mts +126 -36
  71. package/dist/react/SchemaComponent.mjs +95 -57
  72. package/dist/react/SchemaView.d.mts +30 -10
  73. package/dist/react/SchemaView.mjs +2 -2
  74. package/dist/react/a11y.d.mts +21 -0
  75. package/dist/react/a11y.mjs +24 -0
  76. package/dist/react/fieldPath.d.mts +1 -1
  77. package/dist/react/headless.d.mts +1 -1
  78. package/dist/react/headless.mjs +1 -2
  79. package/dist/react/headlessRenderers.d.mts +9 -11
  80. package/dist/react/headlessRenderers.mjs +51 -102
  81. package/dist/{ref-si8ViYun.d.mts → ref-DjLEKa_E.d.mts} +38 -3
  82. package/dist/{renderer-DI6ZYf7a.d.mts → renderer-CXJ8y0qw.d.mts} +2 -2
  83. package/dist/themes/mantine.d.mts +1 -1
  84. package/dist/themes/mui.d.mts +1 -1
  85. package/dist/themes/radix.d.mts +1 -1
  86. package/dist/themes/shadcn.d.mts +1 -1
  87. package/dist/themes/shadcn.mjs +2 -1
  88. package/dist/{types-BnxPEElk.d.mts → types-BTB73MB8.d.mts} +35 -14
  89. package/dist/{version-D-u7aMfy.d.mts → version-BFTVLsdb.d.mts} +7 -1
  90. package/package.json +1 -3
  91. package/dist/typeInference-Bxw3NOG1.d.mts +0 -647
@@ -1,4 +1,4 @@
1
- import { T as SchemaMeta } from "../types-BnxPEElk.mjs";
1
+ import { w as SchemaMeta } from "../types-BTB73MB8.mjs";
2
2
  import { CallbackInfo } from "./parser.mjs";
3
3
  import { ReactNode } from "react";
4
4
 
@@ -1,4 +1,4 @@
1
- import { T as SchemaMeta } from "../types-BnxPEElk.mjs";
1
+ import { w as SchemaMeta } from "../types-BTB73MB8.mjs";
2
2
  import { LinkInfo } from "./parser.mjs";
3
3
  import { ReactNode } from "react";
4
4
 
@@ -1,4 +1,4 @@
1
- import { T as SchemaMeta } from "../types-BnxPEElk.mjs";
1
+ import { w as SchemaMeta } from "../types-BTB73MB8.mjs";
2
2
  import { HeaderInfo } from "./parser.mjs";
3
3
  import { ReactNode } from "react";
4
4
 
@@ -1,4 +1,4 @@
1
- import { T as SchemaMeta } from "../types-BnxPEElk.mjs";
1
+ import { w as SchemaMeta } from "../types-BTB73MB8.mjs";
2
2
  import { SecurityRequirement, SecurityScheme } from "./parser.mjs";
3
3
  import { ReactNode } from "react";
4
4
 
@@ -11,6 +11,18 @@ const OAUTH_FLOW_KEYS = [
11
11
  "clientCredentials",
12
12
  "authorizationCode"
13
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
+ ]);
14
26
  function readString(source, key) {
15
27
  const value = source[key];
16
28
  return typeof value === "string" ? value : void 0;
@@ -66,10 +78,12 @@ function ApiSecurity({ requirements, schemes }) {
66
78
  }
67
79
  function SchemeDetails({ scheme }) {
68
80
  const flows = extractFlows(scheme.flows);
81
+ const isKnownType = scheme.type !== void 0 && KNOWN_SECURITY_SCHEME_TYPES.has(scheme.type);
69
82
  return /* @__PURE__ */ jsxs(Fragment, { children: [
70
- scheme.type !== void 0 && /* @__PURE__ */ jsx("span", {
83
+ scheme.type !== void 0 && /* @__PURE__ */ jsxs("span", {
71
84
  "data-security-type": true,
72
- children: scheme.type
85
+ "data-security-type-unknown": isKnownType ? void 0 : "true",
86
+ children: [scheme.type, !isKnownType && " (unknown type)"]
73
87
  }),
74
88
  scheme.description !== void 0 && /* @__PURE__ */ jsx("span", {
75
89
  "data-security-description": true,
@@ -1,10 +1,160 @@
1
- import { T as SchemaMeta, u as FieldOverride } from "../types-BnxPEElk.mjs";
2
- import { r as DiagnosticSink } from "../diagnostics-CbBPsxSt.mjs";
3
- import { a as InferResponseFields, i as InferRequestBodyFields, m as UnsafeFields, r as InferParameterOverrides } from "../typeInference-Bxw3NOG1.mjs";
1
+ import { u as FieldOverride, w as SchemaMeta } from "../types-BTB73MB8.mjs";
2
+ import { r as DiagnosticSink } from "../diagnostics-BS2kaUyE.mjs";
3
+ import { InferParameterOverrides, InferRequestBodyFields, InferResponseFields } from "../core/typeInference.mjs";
4
4
  import { WidgetMap } from "../react/SchemaComponent.mjs";
5
5
  import { ReactNode } from "react";
6
6
 
7
7
  //#region src/openapi/components.d.ts
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
+ * For OpenAPI 3.1 documents the union includes keys from `webhooks`
20
+ * alongside `paths`, because `<ApiOperation>` / `<ApiRequestBody>` /
21
+ * `<ApiResponse>` resolve webhook names through the same code path as
22
+ * paths (see `lookupPathItem` in `openapi/resolve.ts`). Without the
23
+ * webhook keys, a typed `as const` 3.1 document that declares only
24
+ * webhooks would reject every `path` prop value at compile time
25
+ * ("Type 'string' is not assignable to type 'never'") despite working
26
+ * at runtime.
27
+ *
28
+ * When the document declares neither a `paths` nor a `webhooks` map
29
+ * the union falls back to `string` so untyped/foreign inputs keep
30
+ * working — the constraint is informational, not gating.
31
+ *
32
+ * The `string extends keyof P` guard distinguishes a typed `as const`
33
+ * document (whose `paths` map has literal keys) from a runtime
34
+ * `Record<string, unknown>` document (whose `keyof` collapses to
35
+ * `string`). For the runtime case we surface `string` so callers pass
36
+ * arbitrary path values without losing the existing freedom.
37
+ */
38
+ type PathKeysOf<D> = HasPathsOrWebhooks<D> extends true ? PathsKey<D> | WebhooksKey<D> : string;
39
+ /**
40
+ * `true` when `D` declares either a `paths` or a `webhooks` object,
41
+ * so the `PathKeysOf` union can be derived from real document keys
42
+ * instead of falling back to `string`.
43
+ */
44
+ type HasPathsOrWebhooks<D> = D extends {
45
+ paths: Record<string, unknown>;
46
+ } ? true : D extends {
47
+ webhooks: Record<string, unknown>;
48
+ } ? true : false;
49
+ /**
50
+ * Literal `paths` keys, or `never` when the document does not declare
51
+ * a `paths` object. Runtime documents (whose `keyof` collapses to
52
+ * `string`) widen to `string` so callers retain prior freedom.
53
+ */
54
+ type PathsKey<D> = D extends {
55
+ paths: infer P;
56
+ } ? P extends Record<string, unknown> ? string extends keyof P ? string : Extract<keyof P, string> : never : never;
57
+ /**
58
+ * Literal `webhooks` keys, or `never` when the document does not
59
+ * declare a `webhooks` object (OpenAPI 3.1 only). Runtime documents
60
+ * widen to `string`.
61
+ */
62
+ type WebhooksKey<D> = D extends {
63
+ webhooks: infer W;
64
+ } ? W extends Record<string, unknown> ? string extends keyof W ? string : Extract<keyof W, string> : never : never;
65
+ /**
66
+ * Extract the methods declared on a specific path or webhook item,
67
+ * restricted to the OpenAPI-recognised method set so non-method
68
+ * extension keys (e.g. `summary`, `description`, `parameters`) do not
69
+ * pollute the autocomplete.
70
+ *
71
+ * Runtime documents (typed `Record<string, unknown>`) widen back to
72
+ * `string` so callers retain the freedom to pass arbitrary method
73
+ * strings without surfacing an `HttpMethod` constraint at runtime
74
+ * call sites. Untyped documents (`unknown`) also widen to `string` so
75
+ * consumers with no static doc info can supply extension methods —
76
+ * the canonical `HttpMethod` set is informational, not gating, when
77
+ * the document carries no structural information at all.
78
+ *
79
+ * When the document declares `paths` or `webhooks` but not the
80
+ * specific entry `P`, the union falls back to `HttpMethod` so callers
81
+ * can still target an authored operation that compile-time inference
82
+ * happens to miss (e.g. behind a deferred conditional type).
83
+ */
84
+ type MethodKeysOf<D, P extends string> = IsRuntimeDoc<D> extends true ? string : unknown extends D ? string : HasPathsOrWebhooks<D> extends true ? MethodKeysWithFallback<D, P> : HttpMethod;
85
+ /**
86
+ * Union of literal methods extracted from `paths[P]` and `webhooks[P]`,
87
+ * falling back to the canonical `HttpMethod` set when neither map
88
+ * declares the requested entry.
89
+ */
90
+ type MethodKeysWithFallback<D, P extends string> = [MethodKeysFromPaths<D, P> | MethodKeysFromWebhooks<D, P>] extends [never] ? HttpMethod : MethodKeysFromPaths<D, P> | MethodKeysFromWebhooks<D, P>;
91
+ /**
92
+ * Methods declared on `paths[P]`, restricted to `HttpMethod`.
93
+ * Returns `never` when the document has no matching path entry.
94
+ */
95
+ type MethodKeysFromPaths<D, P extends string> = D extends {
96
+ paths: infer Paths;
97
+ } ? Paths extends Record<string, unknown> ? P extends keyof Paths ? Extract<keyof Paths[P], HttpMethod> : never : never : never;
98
+ /**
99
+ * Methods declared on `webhooks[P]`, restricted to `HttpMethod`.
100
+ * Returns `never` when the document has no matching webhook entry.
101
+ */
102
+ type MethodKeysFromWebhooks<D, P extends string> = D extends {
103
+ webhooks: infer Webhooks;
104
+ } ? Webhooks extends Record<string, unknown> ? P extends keyof Webhooks ? Extract<keyof Webhooks[P], HttpMethod> : never : never : never;
105
+ /**
106
+ * True for the runtime-document sentinel — a `Record<string, unknown>`
107
+ * (or wider) where `keyof` collapses to `string`. Used to drop
108
+ * narrow-constraint defaults so runtime callers retain the prior
109
+ * freedom to pass arbitrary path/method/status values.
110
+ */
111
+ type IsRuntimeDoc<D> = D extends Record<string, unknown> ? string extends keyof D ? true : false : false;
112
+ /**
113
+ * Generic "operation under a given map" extractor used by every
114
+ * downstream `xxKeysOf` helper. Returns the Operation Object for the
115
+ * given path-or-webhook name and method, or `never` when no such
116
+ * entry exists.
117
+ */
118
+ type OperationAt<Map_, P extends string, M extends string> = Map_ extends Record<string, unknown> ? P extends keyof Map_ ? Map_[P] extends Record<string, unknown> ? M extends keyof Map_[P] ? Map_[P][M] : never : never : never : never;
119
+ /**
120
+ * Locate the Operation Object for `path`/`method` across both `paths`
121
+ * and `webhooks`. The OpenAPI 3.1 spec assigns webhooks the same
122
+ * Path Item shape as `paths` entries, so structural inference is
123
+ * identical once the operation is resolved.
124
+ */
125
+ type ResolveOperation<D, P extends string, M extends string> = (D extends {
126
+ paths: infer Paths;
127
+ } ? OperationAt<Paths, P, M> : never) | (D extends {
128
+ webhooks: infer Webhooks;
129
+ } ? OperationAt<Webhooks, P, M> : never);
130
+ /**
131
+ * Extract the status-code keys declared by an operation's `responses`
132
+ * map. Includes class wildcards (`2XX`, etc.) and the `default`
133
+ * sentinel; runtime documents widen to `string`.
134
+ */
135
+ type StatusKeysOf<D, P extends string, M extends string> = ResolveOperation<D, P, M> extends {
136
+ responses: infer R;
137
+ } ? R extends Record<string, unknown> ? string extends keyof R ? string : Extract<keyof R, string> : string : string;
138
+ /**
139
+ * Extract the content-type keys declared on a request body's
140
+ * `content` map for the given path and method. Runtime documents
141
+ * widen to `string`.
142
+ */
143
+ type RequestContentTypesOf<D, P extends string, M extends string> = ResolveOperation<D, P, M> extends {
144
+ requestBody: {
145
+ content: infer C;
146
+ };
147
+ } ? C extends Record<string, unknown> ? string extends keyof C ? string : Extract<keyof C, string> : string : string;
148
+ /**
149
+ * Extract the content-type keys declared on a response entry's
150
+ * `content` map for the given path, method, and status. Runtime
151
+ * documents widen to `string`.
152
+ */
153
+ type ResponseContentTypesOf<D, P extends string, M extends string, S extends string> = ResolveOperation<D, P, M> extends {
154
+ responses: infer R;
155
+ } ? R extends Record<string, unknown> ? S extends keyof R ? R[S] extends {
156
+ content: infer C;
157
+ } ? C extends Record<string, unknown> ? string extends keyof C ? string : Extract<keyof C, string> : string : string : string : string : string;
8
158
  /**
9
159
  * Diagnostics props accepted by every top-level OpenAPI component.
10
160
  *
@@ -18,7 +168,7 @@ interface ApiDiagnosticsProps {
18
168
  onDiagnostic?: DiagnosticSink;
19
169
  strict?: boolean;
20
170
  }
21
- interface ApiOperationProps<Doc = unknown, Path extends string = string, Method extends string = string> extends ApiDiagnosticsProps {
171
+ 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 {
22
172
  schema: Doc;
23
173
  path: Path;
24
174
  method: Method;
@@ -26,16 +176,20 @@ interface ApiOperationProps<Doc = unknown, Path extends string = string, Method
26
176
  onRequestBodyChange?: (value: unknown) => void;
27
177
  responseValue?: unknown;
28
178
  meta?: SchemaMeta;
29
- requestBodyFields?: Doc extends Record<string, unknown> ? InferRequestBodyFields<Doc, Path, Method> : Record<string, FieldOverride>;
30
- /** Escape hatch for recursive schemas where type-level inference fails.
31
- * Typed as Record<string, FieldOverride> use when the schema contains
32
- * deeply nested $ref chains.
179
+ /**
180
+ * Media type whose request body schema drives `requestBodyFields`
181
+ * inference. Defaults to the union of declared content types so
182
+ * callers can omit it; supply explicitly to narrow inference to a
183
+ * specific media type. Mirrors {@link ApiRequestBodyProps.contentType}
184
+ * so `<ApiOperation>` can target non-JSON request bodies with the
185
+ * same precision as `<ApiRequestBody>`.
33
186
  */
34
- unsafeFields?: UnsafeFields;
187
+ requestBodyContentType?: ContentType;
188
+ requestBodyFields?: Doc extends Record<string, unknown> ? InferRequestBodyFields<Doc, Path & string, Method & string, ContentType & string> : Record<string, FieldOverride>;
35
189
  /** Instance-scoped widgets. */
36
190
  widgets?: WidgetMap;
37
191
  }
38
- declare function ApiOperation<Doc = unknown, Path extends string = string, Method extends string = string>({
192
+ 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>>({
39
193
  schema: doc,
40
194
  path,
41
195
  method,
@@ -47,17 +201,17 @@ declare function ApiOperation<Doc = unknown, Path extends string = string, Metho
47
201
  widgets,
48
202
  onDiagnostic,
49
203
  strict
50
- }: ApiOperationProps<Doc, Path, Method>): ReactNode;
51
- interface ApiParametersProps<Doc = unknown, Path extends string = string, Method extends string = string> extends ApiDiagnosticsProps {
204
+ }: ApiOperationProps<Doc, Path, Method, ContentType>): ReactNode;
205
+ interface ApiParametersProps<Doc = unknown, Path extends PathKeysOf<Doc> = PathKeysOf<Doc>, Method extends MethodKeysOf<Doc, Path> = MethodKeysOf<Doc, Path>> extends ApiDiagnosticsProps {
52
206
  schema: Doc;
53
207
  path: Path;
54
208
  method: Method;
55
209
  meta?: SchemaMeta;
56
- overrides?: Doc extends Record<string, unknown> ? InferParameterOverrides<Doc, Path, Method> : Record<string, FieldOverride>;
210
+ overrides?: Doc extends Record<string, unknown> ? InferParameterOverrides<Doc, Path & string, Method & string> : Record<string, FieldOverride>;
57
211
  /** Instance-scoped widgets. */
58
212
  widgets?: WidgetMap;
59
213
  }
60
- declare function ApiParameters<Doc = unknown, Path extends string = string, Method extends string = string>({
214
+ declare function ApiParameters<Doc = unknown, Path extends PathKeysOf<Doc> = PathKeysOf<Doc>, Method extends MethodKeysOf<Doc, Path> = MethodKeysOf<Doc, Path>>({
61
215
  schema: doc,
62
216
  path,
63
217
  method,
@@ -67,18 +221,25 @@ declare function ApiParameters<Doc = unknown, Path extends string = string, Meth
67
221
  onDiagnostic,
68
222
  strict
69
223
  }: ApiParametersProps<Doc, Path, Method>): ReactNode;
70
- interface ApiRequestBodyProps<Doc = unknown, Path extends string = string, Method extends string = string> extends ApiDiagnosticsProps {
224
+ 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 {
71
225
  schema: Doc;
72
226
  path: Path;
73
227
  method: Method;
228
+ /**
229
+ * Media type whose schema should be rendered for the request body.
230
+ * Defaults to the union of declared content types so callers can
231
+ * omit it; supply explicitly to narrow `fields` inference to a
232
+ * specific media type via {@link InferRequestBodyFields}.
233
+ */
234
+ contentType?: ContentType;
74
235
  value?: unknown;
75
236
  onChange?: (value: unknown) => void;
76
237
  meta?: SchemaMeta;
77
- fields?: Doc extends Record<string, unknown> ? InferRequestBodyFields<Doc, Path, Method> : Record<string, FieldOverride>;
238
+ fields?: Doc extends Record<string, unknown> ? InferRequestBodyFields<Doc, Path & string, Method & string, ContentType & string> : Record<string, FieldOverride>;
78
239
  /** Instance-scoped widgets. */
79
240
  widgets?: WidgetMap;
80
241
  }
81
- declare function ApiRequestBody<Doc = unknown, Path extends string = string, Method extends string = string>({
242
+ 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>>({
82
243
  schema: doc,
83
244
  path,
84
245
  method,
@@ -89,19 +250,26 @@ declare function ApiRequestBody<Doc = unknown, Path extends string = string, Met
89
250
  widgets,
90
251
  onDiagnostic,
91
252
  strict
92
- }: ApiRequestBodyProps<Doc, Path, Method>): ReactNode;
93
- interface ApiResponseProps<Doc = unknown, Path extends string = string, Method extends string = string, Status extends string = string> extends ApiDiagnosticsProps {
253
+ }: ApiRequestBodyProps<Doc, Path, Method, ContentType>): ReactNode;
254
+ 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 {
94
255
  schema: Doc;
95
256
  path: Path;
96
257
  method: Method;
97
258
  status: Status;
259
+ /**
260
+ * Media type whose schema should be rendered. Defaults to the
261
+ * union of declared content types so callers can omit it;
262
+ * supply explicitly to narrow `fields` inference via
263
+ * {@link InferResponseFields}.
264
+ */
265
+ contentType?: ContentType;
98
266
  value?: unknown;
99
267
  meta?: SchemaMeta;
100
- fields?: Doc extends Record<string, unknown> ? InferResponseFields<Doc, Path, Method, Status> : Record<string, FieldOverride>;
268
+ fields?: Doc extends Record<string, unknown> ? InferResponseFields<Doc, Path & string, Method & string, Status & string, ContentType & string> : Record<string, FieldOverride>;
101
269
  /** Instance-scoped widgets. */
102
270
  widgets?: WidgetMap;
103
271
  }
104
- declare function ApiResponse<Doc = unknown, Path extends string = string, Method extends string = string, Status extends string = string>({
272
+ 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>>({
105
273
  schema: doc,
106
274
  path,
107
275
  method,
@@ -112,6 +280,49 @@ declare function ApiResponse<Doc = unknown, Path extends string = string, Method
112
280
  widgets,
113
281
  onDiagnostic,
114
282
  strict
115
- }: ApiResponseProps<Doc, Path, Method, Status>): ReactNode;
283
+ }: ApiResponseProps<Doc, Path, Method, Status, ContentType>): ReactNode;
284
+ /**
285
+ * Render a single OpenAPI 3.1 webhook by name. A webhook is a Path Item
286
+ * Object under the document's top-level `webhooks` map; once resolved,
287
+ * its operations are structurally identical to operations under `paths`.
288
+ *
289
+ * Internally, this delegates to `ApiOperation` for each method present
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.
293
+ */
294
+ interface ApiWebhookProps extends ApiDiagnosticsProps {
295
+ schema: unknown;
296
+ /** Webhook name (key under the document's `webhooks` map). */
297
+ name: string;
298
+ /** Instance-scoped widgets, forwarded to each rendered operation. */
299
+ widgets?: WidgetMap;
300
+ meta?: SchemaMeta;
301
+ }
302
+ declare function ApiWebhook({
303
+ schema: doc,
304
+ name,
305
+ widgets,
306
+ meta,
307
+ onDiagnostic,
308
+ strict
309
+ }: ApiWebhookProps): ReactNode;
310
+ /**
311
+ * Render every OpenAPI 3.1 webhook declared on the document, one
312
+ * `<ApiWebhook>` per entry. Returns `null` when the document has no
313
+ * `webhooks` map or it is empty.
314
+ */
315
+ interface ApiWebhooksProps extends ApiDiagnosticsProps {
316
+ schema: unknown;
317
+ widgets?: WidgetMap;
318
+ meta?: SchemaMeta;
319
+ }
320
+ declare function ApiWebhooks({
321
+ schema: doc,
322
+ widgets,
323
+ meta,
324
+ onDiagnostic,
325
+ strict
326
+ }: ApiWebhooksProps): ReactNode;
116
327
  //#endregion
117
- export { ApiOperation, ApiOperationProps, ApiParameters, ApiParametersProps, ApiRequestBody, ApiRequestBodyProps, ApiResponse, ApiResponseProps };
328
+ export { ApiOperation, ApiOperationProps, ApiParameters, ApiParametersProps, ApiRequestBody, ApiRequestBodyProps, ApiResponse, ApiResponseProps, ApiWebhook, ApiWebhookProps, ApiWebhooks, ApiWebhooksProps };