schema-components 1.22.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 (82) hide show
  1. package/README.md +3 -1
  2. package/dist/core/adapter.d.mts +97 -3
  3. package/dist/core/adapter.mjs +260 -111
  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 +9 -2
  13. package/dist/core/formats.mjs +12 -1
  14. package/dist/core/idPath.d.mts +54 -0
  15. package/dist/core/idPath.mjs +66 -0
  16. package/dist/core/merge.d.mts +10 -1
  17. package/dist/core/merge.mjs +49 -10
  18. package/dist/core/normalise.d.mts +14 -3
  19. package/dist/core/normalise.mjs +2 -2
  20. package/dist/core/openapi30.d.mts +15 -1
  21. package/dist/core/openapi30.mjs +2 -2
  22. package/dist/core/openapiConstants.d.mts +67 -0
  23. package/dist/core/openapiConstants.mjs +90 -0
  24. package/dist/core/ref.d.mts +2 -2
  25. package/dist/core/ref.mjs +84 -6
  26. package/dist/core/refChain.d.mts +70 -0
  27. package/dist/core/refChain.mjs +44 -0
  28. package/dist/core/renderer.d.mts +1 -1
  29. package/dist/core/swagger2.d.mts +1 -1
  30. package/dist/core/swagger2.mjs +1 -1
  31. package/dist/core/typeInference.d.mts +982 -2
  32. package/dist/core/types.d.mts +1 -1
  33. package/dist/core/unionMatch.d.mts +36 -0
  34. package/dist/core/unionMatch.mjs +53 -0
  35. package/dist/core/version.d.mts +1 -1
  36. package/dist/core/version.mjs +29 -17
  37. package/dist/core/walkBuilders.d.mts +23 -4
  38. package/dist/core/walkBuilders.mjs +27 -7
  39. package/dist/core/walker.d.mts +1 -1
  40. package/dist/core/walker.mjs +44 -45
  41. package/dist/{diagnostics-D0QCYGv0.d.mts → diagnostics-BS2kaUyE.d.mts} +1 -1
  42. package/dist/{errors-DpFwqs5C.d.mts → errors-g_MCTQel.d.mts} +9 -15
  43. package/dist/html/a11y.d.mts +9 -4
  44. package/dist/html/a11y.mjs +10 -19
  45. package/dist/html/renderToHtml.d.mts +2 -2
  46. package/dist/html/renderToHtmlStream.d.mts +2 -2
  47. package/dist/html/renderToHtmlStream.mjs +12 -1
  48. package/dist/html/renderers.d.mts +43 -8
  49. package/dist/html/renderers.mjs +136 -111
  50. package/dist/html/streamRenderers.d.mts +4 -5
  51. package/dist/html/streamRenderers.mjs +40 -61
  52. package/dist/{normalise-DVEJQmF7.mjs → normalise-DCYp06Sr.mjs} +352 -162
  53. package/dist/openapi/ApiCallbacks.d.mts +1 -1
  54. package/dist/openapi/ApiLinks.d.mts +1 -1
  55. package/dist/openapi/ApiResponseHeaders.d.mts +1 -1
  56. package/dist/openapi/ApiSecurity.d.mts +1 -1
  57. package/dist/openapi/components.d.mts +116 -37
  58. package/dist/openapi/components.mjs +54 -37
  59. package/dist/openapi/parser.d.mts +9 -8
  60. package/dist/openapi/parser.mjs +234 -84
  61. package/dist/openapi/resolve.d.mts +20 -11
  62. package/dist/openapi/resolve.mjs +133 -73
  63. package/dist/react/SchemaComponent.d.mts +32 -7
  64. package/dist/react/SchemaComponent.mjs +45 -21
  65. package/dist/react/SchemaView.d.mts +30 -10
  66. package/dist/react/a11y.d.mts +21 -0
  67. package/dist/react/a11y.mjs +24 -0
  68. package/dist/react/fieldPath.d.mts +1 -1
  69. package/dist/react/headless.d.mts +1 -1
  70. package/dist/react/headlessRenderers.d.mts +8 -9
  71. package/dist/react/headlessRenderers.mjs +41 -72
  72. package/dist/{ref-D-_JBZkF.d.mts → ref-DjLEKa_E.d.mts} +38 -3
  73. package/dist/{renderer-BaRlQIuN.d.mts → renderer-CXJ8y0qw.d.mts} +1 -1
  74. package/dist/themes/mantine.d.mts +1 -1
  75. package/dist/themes/mui.d.mts +1 -1
  76. package/dist/themes/radix.d.mts +1 -1
  77. package/dist/themes/shadcn.d.mts +1 -1
  78. package/dist/themes/shadcn.mjs +2 -1
  79. package/dist/{types-BrRMV0en.d.mts → types-BTB73MB8.d.mts} +32 -4
  80. package/dist/{version-D2jfdX6E.d.mts → version-BFTVLsdb.d.mts} +7 -1
  81. package/package.json +1 -1
  82. package/dist/typeInference-DkcUHfaM.d.mts +0 -982
@@ -1,4 +1,4 @@
1
- import { w as SchemaMeta } from "../types-BrRMV0en.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 { w as SchemaMeta } from "../types-BrRMV0en.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 { w as SchemaMeta } from "../types-BrRMV0en.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 { w as SchemaMeta } from "../types-BrRMV0en.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
 
@@ -1,6 +1,6 @@
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";
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
 
@@ -16,29 +16,92 @@ type HttpMethod = "get" | "put" | "post" | "delete" | "options" | "head" | "patc
16
16
  * Extract the literal path keys from a document type, or the broad
17
17
  * `string` fallback when the document is untyped at compile time.
18
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.
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`.
24
43
  */
25
- type PathKeysOf<D> = D extends {
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 {
26
55
  paths: infer P;
27
- } ? P extends Record<string, unknown> ? string extends keyof P ? string : Extract<keyof P, string> : string : string;
56
+ } ? P extends Record<string, unknown> ? string extends keyof P ? string : Extract<keyof P, string> : never : never;
28
57
  /**
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.
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.
33
70
  *
34
71
  * Runtime documents (typed `Record<string, unknown>`) widen back to
35
72
  * `string` so callers retain the freedom to pass arbitrary method
36
73
  * strings without surfacing an `HttpMethod` constraint at runtime
37
- * call sites.
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).
38
83
  */
39
- type MethodKeysOf<D, P extends string> = IsRuntimeDoc<D> extends true ? string : D extends {
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 {
40
96
  paths: infer Paths;
41
- } ? Paths extends Record<string, unknown> ? P extends keyof Paths ? Extract<keyof Paths[P], HttpMethod> : HttpMethod : HttpMethod : HttpMethod;
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;
42
105
  /**
43
106
  * True for the runtime-document sentinel — a `Record<string, unknown>`
44
107
  * (or wider) where `keyof` collapses to `string`. Used to drop
@@ -46,40 +109,52 @@ type MethodKeysOf<D, P extends string> = IsRuntimeDoc<D> extends true ? string :
46
109
  * freedom to pass arbitrary path/method/status values.
47
110
  */
48
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);
49
130
  /**
50
131
  * Extract the status-code keys declared by an operation's `responses`
51
132
  * map. Includes class wildcards (`2XX`, etc.) and the `default`
52
133
  * sentinel; runtime documents widen to `string`.
53
134
  */
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 {
135
+ type StatusKeysOf<D, P extends string, M extends string> = ResolveOperation<D, P, M> extends {
57
136
  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;
137
+ } ? R extends Record<string, unknown> ? string extends keyof R ? string : Extract<keyof R, string> : string : string;
59
138
  /**
60
139
  * Extract the content-type keys declared on a request body's
61
140
  * `content` map for the given path and method. Runtime documents
62
141
  * widen to `string`.
63
142
  */
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 {
143
+ type RequestContentTypesOf<D, P extends string, M extends string> = ResolveOperation<D, P, M> extends {
67
144
  requestBody: {
68
145
  content: infer C;
69
146
  };
70
- } ? C extends Record<string, unknown> ? string extends keyof C ? string : Extract<keyof C, string> : string : string : string : string : string : string : string;
147
+ } ? C extends Record<string, unknown> ? string extends keyof C ? string : Extract<keyof C, string> : string : string;
71
148
  /**
72
149
  * Extract the content-type keys declared on a response entry's
73
150
  * `content` map for the given path, method, and status. Runtime
74
151
  * documents widen to `string`.
75
152
  */
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 {
153
+ type ResponseContentTypesOf<D, P extends string, M extends string, S extends string> = ResolveOperation<D, P, M> extends {
79
154
  responses: infer R;
80
155
  } ? R extends Record<string, unknown> ? S extends keyof R ? R[S] extends {
81
156
  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;
157
+ } ? C extends Record<string, unknown> ? string extends keyof C ? string : Extract<keyof C, string> : string : string : string : string : string;
83
158
  /**
84
159
  * Diagnostics props accepted by every top-level OpenAPI component.
85
160
  *
@@ -93,7 +168,7 @@ interface ApiDiagnosticsProps {
93
168
  onDiagnostic?: DiagnosticSink;
94
169
  strict?: boolean;
95
170
  }
96
- interface ApiOperationProps<Doc = unknown, Path extends PathKeysOf<Doc> = PathKeysOf<Doc>, Method extends MethodKeysOf<Doc, Path> = MethodKeysOf<Doc, Path>> 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 {
97
172
  schema: Doc;
98
173
  path: Path;
99
174
  method: Method;
@@ -101,16 +176,20 @@ interface ApiOperationProps<Doc = unknown, Path extends PathKeysOf<Doc> = PathKe
101
176
  onRequestBodyChange?: (value: unknown) => void;
102
177
  responseValue?: unknown;
103
178
  meta?: SchemaMeta;
104
- requestBodyFields?: Doc extends Record<string, unknown> ? InferRequestBodyFields<Doc, Path & string, Method & string> : Record<string, FieldOverride>;
105
- /** Escape hatch for recursive schemas where type-level inference fails.
106
- * Typed as Record<string, FieldOverride> use when the schema contains
107
- * 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>`.
108
186
  */
109
- unsafeFields?: UnsafeFields;
187
+ requestBodyContentType?: ContentType;
188
+ requestBodyFields?: Doc extends Record<string, unknown> ? InferRequestBodyFields<Doc, Path & string, Method & string, ContentType & string> : Record<string, FieldOverride>;
110
189
  /** Instance-scoped widgets. */
111
190
  widgets?: WidgetMap;
112
191
  }
113
- declare function ApiOperation<Doc = unknown, Path extends PathKeysOf<Doc> = PathKeysOf<Doc>, Method extends MethodKeysOf<Doc, Path> = MethodKeysOf<Doc, Path>>({
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>>({
114
193
  schema: doc,
115
194
  path,
116
195
  method,
@@ -122,7 +201,7 @@ declare function ApiOperation<Doc = unknown, Path extends PathKeysOf<Doc> = Path
122
201
  widgets,
123
202
  onDiagnostic,
124
203
  strict
125
- }: ApiOperationProps<Doc, Path, Method>): ReactNode;
204
+ }: ApiOperationProps<Doc, Path, Method, ContentType>): ReactNode;
126
205
  interface ApiParametersProps<Doc = unknown, Path extends PathKeysOf<Doc> = PathKeysOf<Doc>, Method extends MethodKeysOf<Doc, Path> = MethodKeysOf<Doc, Path>> extends ApiDiagnosticsProps {
127
206
  schema: Doc;
128
207
  path: Path;
@@ -1,5 +1,6 @@
1
1
  import { isObject, toRecordOrUndefined } from "../core/guards.mjs";
2
2
  import { emitDiagnostic } from "../core/diagnostics.mjs";
3
+ import { extractRootMetaFromJson } from "../core/adapter.mjs";
3
4
  import { walk } from "../core/walker.mjs";
4
5
  import { ApiCallbacks } from "./ApiCallbacks.mjs";
5
6
  import { ApiLinks } from "./ApiLinks.mjs";
@@ -53,7 +54,7 @@ function resolveRootDoc(doc, diagnostics) {
53
54
  function noop() {}
54
55
  function renderSchema(schema, rootDocument, options) {
55
56
  if (!isObject(schema)) throw new Error("renderSchema received a non-object schema from the resolver.");
56
- const rootMeta = extractRootMetaFromSchema(schema);
57
+ const rootMeta = extractRootMetaFromJson(schema);
57
58
  const componentMeta = {};
58
59
  if (options.readOnly === true) componentMeta.readOnly = true;
59
60
  if (options.meta !== void 0) for (const [k, v] of Object.entries(options.meta)) componentMeta[k] = v;
@@ -138,7 +139,9 @@ function ApiOperation({ schema: doc, path, method, requestBodyValue, onRequestBo
138
139
  rootDoc,
139
140
  meta,
140
141
  widgets,
141
- idPrefix: joinPath(instancePrefix, "params")
142
+ idPrefix: joinPath(instancePrefix, "params"),
143
+ diagnostics,
144
+ pointerPrefix: operationPointer(path, method)
142
145
  })]
143
146
  }),
144
147
  resolved.requestBody?.schema !== void 0 && /* @__PURE__ */ jsxs("section", {
@@ -196,7 +199,9 @@ function ApiParameters({ schema: doc, path, method, meta, overrides, widgets, on
196
199
  overrides,
197
200
  meta,
198
201
  widgets,
199
- idPrefix: instancePrefix
202
+ idPrefix: instancePrefix,
203
+ diagnostics,
204
+ pointerPrefix: operationPointer(path, method)
200
205
  })]
201
206
  });
202
207
  }
@@ -331,25 +336,39 @@ function OperationHeader({ operation, pathItem }) {
331
336
  })
332
337
  ] });
333
338
  }
334
- function ParameterList({ parameters, rootDoc, overrides, meta, widgets, idPrefix }) {
335
- return /* @__PURE__ */ jsx(Fragment, { children: parameters.map((param) => /* @__PURE__ */ jsxs("div", {
336
- "data-parameter": param.name,
337
- children: [
338
- /* @__PURE__ */ jsxs("label", { children: [param.name, param.required && /* @__PURE__ */ jsx("span", {
339
- "data-required": true,
340
- children: "*"
341
- })] }),
342
- param.description && /* @__PURE__ */ jsx("span", {
343
- "data-description": true,
344
- children: param.description
345
- }),
346
- renderSchema(param.schema ?? { type: "string" }, rootDoc, {
347
- meta: buildParamMeta(param, overrides, meta),
348
- widgets,
349
- rootPath: joinPath(idPrefix, param.name)
350
- })
351
- ]
352
- }, param.name)) });
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
+ }) });
353
372
  }
354
373
  function ResponseCard({ response, rootDoc, parsed, value, fields, meta, widgets, path, method, idPrefix }) {
355
374
  if (response.schema === void 0) return /* @__PURE__ */ jsxs("div", {
@@ -382,6 +401,19 @@ function ResponseCard({ response, rootDoc, parsed, value, fields, meta, widgets,
382
401
  ]
383
402
  });
384
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
+ }
385
417
  function buildParamMeta(param, overrides, meta) {
386
418
  const result = {};
387
419
  if (param.description !== void 0) result.description = param.description;
@@ -391,20 +423,5 @@ function buildParamMeta(param, overrides, meta) {
391
423
  if (meta !== void 0) for (const [k, v] of Object.entries(meta)) result[k] = v;
392
424
  return Object.keys(result).length > 0 ? result : void 0;
393
425
  }
394
- /**
395
- * Extract root-level meta (title, description, readOnly, etc.) from a
396
- * JSON Schema node. Mirrors `extractRootMetaFromJson` in the adapter so
397
- * pre-normalised schemas (extracted from `getParsed`) still surface root
398
- * meta to the walker without an extra adapter round-trip.
399
- */
400
- function extractRootMetaFromSchema(jsonSchema) {
401
- const meta = {};
402
- if (jsonSchema.readOnly === true) meta.readOnly = true;
403
- if (jsonSchema.writeOnly === true) meta.writeOnly = true;
404
- if (typeof jsonSchema.description === "string") meta.description = jsonSchema.description;
405
- if (typeof jsonSchema.title === "string") meta.title = jsonSchema.title;
406
- if (typeof jsonSchema.deprecated === "boolean") meta.deprecated = jsonSchema.deprecated;
407
- return Object.keys(meta).length > 0 ? meta : void 0;
408
- }
409
426
  //#endregion
410
427
  export { ApiOperation, ApiParameters, ApiRequestBody, ApiResponse, ApiWebhook, ApiWebhooks };
@@ -1,4 +1,5 @@
1
- import { m as JsonObject } from "../types-BrRMV0en.mjs";
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 };