schema-components 1.28.2 → 2.0.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 (105) hide show
  1. package/README.md +38 -16
  2. package/dist/core/adapter.d.mts +213 -3
  3. package/dist/core/adapter.mjs +21 -2
  4. package/dist/core/constraintHint.d.mts +15 -0
  5. package/dist/core/constraintHint.mjs +24 -0
  6. package/dist/core/constraints.d.mts +34 -2
  7. package/dist/core/constraints.mjs +33 -1
  8. package/dist/core/cssClasses.d.mts +1 -0
  9. package/dist/core/diagnostics.d.mts +1 -1
  10. package/dist/core/errors.d.mts +1 -1
  11. package/dist/core/errors.mjs +22 -12
  12. package/dist/core/fieldOrder.d.mts +1 -1
  13. package/dist/core/formats.d.mts +7 -1
  14. package/dist/core/formats.mjs +6 -0
  15. package/dist/core/idPath.d.mts +35 -5
  16. package/dist/core/idPath.mjs +79 -7
  17. package/dist/core/inferValue.d.mts +2 -0
  18. package/dist/core/inferValue.mjs +1 -0
  19. package/dist/core/limits.d.mts +1 -1
  20. package/dist/core/limits.mjs +6 -0
  21. package/dist/core/merge.d.mts +22 -1
  22. package/dist/core/merge.mjs +66 -3
  23. package/dist/core/normalise.d.mts +17 -2
  24. package/dist/core/normalise.mjs +1 -1
  25. package/dist/core/openapi30.mjs +1 -1
  26. package/dist/core/openapiConstants.d.mts +1 -0
  27. package/dist/core/ref.d.mts +1 -1
  28. package/dist/core/refChain.d.mts +3 -4
  29. package/dist/core/refChain.mjs +2 -3
  30. package/dist/core/renderer.d.mts +199 -2
  31. package/dist/core/renderer.mjs +5 -0
  32. package/dist/core/swagger2.d.mts +1 -1
  33. package/dist/core/swagger2.mjs +1 -1
  34. package/dist/core/typeInference.d.mts +3 -3
  35. package/dist/core/types.d.mts +1 -1
  36. package/dist/core/types.mjs +17 -0
  37. package/dist/core/unionMatch.d.mts +1 -1
  38. package/dist/core/uri.d.mts +12 -4
  39. package/dist/core/uri.mjs +30 -4
  40. package/dist/core/version.d.mts +1 -1
  41. package/dist/core/walkBuilders.d.mts +63 -6
  42. package/dist/core/walkBuilders.mjs +33 -1
  43. package/dist/core/walker.d.mts +14 -1
  44. package/dist/core/walker.mjs +18 -0
  45. package/dist/{diagnostics-Cbwak-ZX.d.mts → diagnostics-BTrm3O6J.d.mts} +9 -1
  46. package/dist/{errors-DQSIK4n1.d.mts → errors-Dki7tji4.d.mts} +23 -13
  47. package/dist/html/a11y.d.mts +3 -7
  48. package/dist/html/a11y.mjs +1 -16
  49. package/dist/html/html.d.mts +11 -0
  50. package/dist/html/html.mjs +11 -0
  51. package/dist/html/renderToHtml.d.mts +45 -12
  52. package/dist/html/renderToHtml.mjs +20 -4
  53. package/dist/html/renderToHtmlStream.d.mts +63 -18
  54. package/dist/html/renderToHtmlStream.mjs +34 -8
  55. package/dist/html/renderers.d.mts +6 -31
  56. package/dist/html/renderers.mjs +45 -91
  57. package/dist/html/streamRenderers.d.mts +31 -3
  58. package/dist/html/streamRenderers.mjs +41 -8
  59. package/dist/inferValue-PPXWJpbN.d.mts +77 -0
  60. package/dist/{limits-DJhgx5Ay.d.mts → limits-x4OiyJxh.d.mts} +6 -0
  61. package/dist/{normalise-Db1xaxgx.mjs → normalise-DB-Xtjmn.mjs} +43 -2
  62. package/dist/openapi/ApiCallbacks.d.mts +13 -1
  63. package/dist/openapi/ApiCallbacks.mjs +7 -0
  64. package/dist/openapi/ApiLinks.d.mts +13 -1
  65. package/dist/openapi/ApiLinks.mjs +7 -0
  66. package/dist/openapi/ApiResponseHeaders.d.mts +13 -1
  67. package/dist/openapi/ApiResponseHeaders.mjs +7 -0
  68. package/dist/openapi/ApiSecurity.d.mts +14 -1
  69. package/dist/openapi/ApiSecurity.mjs +29 -8
  70. package/dist/openapi/bundle.d.mts +31 -0
  71. package/dist/openapi/components.d.mts +135 -20
  72. package/dist/openapi/components.mjs +90 -15
  73. package/dist/openapi/parser.d.mts +140 -13
  74. package/dist/openapi/parser.mjs +84 -12
  75. package/dist/openapi/resolve.d.mts +42 -47
  76. package/dist/openapi/resolve.mjs +62 -56
  77. package/dist/react/SchemaComponent.d.mts +90 -88
  78. package/dist/react/SchemaComponent.mjs +74 -2
  79. package/dist/react/SchemaErrorBoundary.d.mts +18 -1
  80. package/dist/react/SchemaErrorBoundary.mjs +13 -1
  81. package/dist/react/SchemaView.d.mts +39 -11
  82. package/dist/react/SchemaView.mjs +23 -6
  83. package/dist/react/a11y.d.mts +74 -7
  84. package/dist/react/a11y.mjs +67 -6
  85. package/dist/react/fieldPath.d.mts +16 -1
  86. package/dist/react/fieldPath.mjs +25 -1
  87. package/dist/react/fieldShell.d.mts +49 -0
  88. package/dist/react/fieldShell.mjs +37 -0
  89. package/dist/react/headless.d.mts +1 -1
  90. package/dist/react/headlessRenderers.d.mts +13 -2
  91. package/dist/react/headlessRenderers.mjs +134 -54
  92. package/dist/{ref-TdeMfaV_.d.mts → ref-DdsbekXX.d.mts} +33 -1
  93. package/dist/themes/mantine.d.mts +54 -12
  94. package/dist/themes/mantine.mjs +195 -140
  95. package/dist/themes/mui.d.mts +64 -11
  96. package/dist/themes/mui.mjs +277 -213
  97. package/dist/themes/radix.d.mts +67 -15
  98. package/dist/themes/radix.mjs +235 -170
  99. package/dist/themes/shadcn.d.mts +25 -1
  100. package/dist/themes/shadcn.mjs +112 -91
  101. package/dist/{types-BTB73MB8.d.mts → types-BrYbjC7_.d.mts} +30 -0
  102. package/dist/{version-ZzL5R6cS.d.mts → version-DL8U5RuA.d.mts} +6 -0
  103. package/package.json +8 -1
  104. package/dist/adapter-DqlAnZ_w.d.mts +0 -172
  105. package/dist/renderer-Ul9taFYp.d.mts +0 -169
@@ -1,11 +1,22 @@
1
- import { m as JsonObject } from "../types-BTB73MB8.mjs";
2
- import { i as DiagnosticsOptions } from "../diagnostics-Cbwak-ZX.mjs";
1
+ import { m as JsonObject } from "../types-BrYbjC7_.mjs";
2
+ import { i as DiagnosticsOptions } from "../diagnostics-BTrm3O6J.mjs";
3
3
 
4
4
  //#region src/openapi/parser.d.ts
5
+ /**
6
+ * Parsed OpenAPI document: the raw root JSON plus a cache of resolved
7
+ * `#/components/schemas/*` (or Swagger 2.0 `#/definitions/*`) entries.
8
+ * Produced by {@link parseOpenApiDocument} and consumed by every other
9
+ * parser/resolver helper in this module.
10
+ */
5
11
  interface OpenApiDocument {
6
12
  doc: JsonObject;
7
13
  schemas: Map<string, JsonObject>;
8
14
  }
15
+ /**
16
+ * Lightweight summary of an OpenAPI operation: its location, identity,
17
+ * description fields, deprecation flag, and the underlying Operation
18
+ * Object. Returned by {@link listOperations} / {@link listAllOperations}.
19
+ */
9
20
  interface OperationInfo {
10
21
  path: string;
11
22
  method: string;
@@ -15,7 +26,12 @@ interface OperationInfo {
15
26
  deprecated: boolean;
16
27
  operation: JsonObject;
17
28
  }
29
+ /** Canonical four-value OpenAPI parameter `in` location. */
18
30
  type ParameterLocation = "query" | "path" | "header" | "cookie";
31
+ /**
32
+ * Parsed view of an OpenAPI Parameter Object — name, location,
33
+ * required flag, deprecation flag, description, and resolved schema.
34
+ */
19
35
  interface ParameterInfo {
20
36
  name: string;
21
37
  location: ParameterLocation;
@@ -24,6 +40,10 @@ interface ParameterInfo {
24
40
  description: string | undefined;
25
41
  schema: JsonObject | undefined;
26
42
  }
43
+ /**
44
+ * Parsed view of an OpenAPI Response Object — status code, description,
45
+ * declared content types, response schema, and resolved headers.
46
+ */
27
47
  interface ResponseInfo {
28
48
  statusCode: string;
29
49
  description: string | undefined;
@@ -31,16 +51,29 @@ interface ResponseInfo {
31
51
  schema: JsonObject | undefined;
32
52
  headers: Map<string, HeaderInfo>;
33
53
  }
54
+ /**
55
+ * Parsed view of an OpenAPI Request Body Object — required flag,
56
+ * description, declared content types, and the request body schema.
57
+ */
34
58
  interface RequestBodyInfo {
35
59
  required: boolean;
36
60
  description: string | undefined;
37
61
  contentTypes: string[];
38
62
  schema: JsonObject | undefined;
39
63
  }
64
+ /**
65
+ * A single entry in an OpenAPI Security Requirement Object — the name
66
+ * of a security scheme paired with its list of required scopes.
67
+ */
40
68
  interface SecurityRequirement {
41
69
  name: string;
42
70
  scopes: string[];
43
71
  }
72
+ /**
73
+ * Parsed view of an OpenAPI Security Scheme Object covering every
74
+ * field defined for `apiKey`, `http`, `oauth2`, `openIdConnect`, and
75
+ * `mutualTLS` schemes.
76
+ */
44
77
  interface SecurityScheme {
45
78
  type: string | undefined;
46
79
  description: string | undefined;
@@ -51,6 +84,10 @@ interface SecurityScheme {
51
84
  flows: JsonObject | undefined;
52
85
  openIdConnectUrl: string | undefined;
53
86
  }
87
+ /**
88
+ * Parsed view of an OpenAPI Header Object — name, description, required
89
+ * and deprecated flags, and resolved schema.
90
+ */
54
91
  interface HeaderInfo {
55
92
  name: string;
56
93
  description: string | undefined;
@@ -58,14 +95,23 @@ interface HeaderInfo {
58
95
  deprecated: boolean;
59
96
  schema: JsonObject | undefined;
60
97
  }
98
+ /**
99
+ * Parsed view of a single OpenAPI 3.1 webhook entry: its name and the
100
+ * operations declared on its Path Item Object.
101
+ */
61
102
  interface WebhookInfo {
62
103
  name: string;
63
104
  operations: OperationInfo[];
64
105
  }
106
+ /** Parsed view of an OpenAPI External Documentation Object. */
65
107
  interface ExternalDocs {
66
108
  url: string;
67
109
  description: string | undefined;
68
110
  }
111
+ /**
112
+ * Parsed view of an OpenAPI XML Object — controls how a schema field
113
+ * is serialised in an XML payload.
114
+ */
69
115
  interface XmlInfo {
70
116
  name: string | undefined;
71
117
  namespace: string | undefined;
@@ -73,10 +119,19 @@ interface XmlInfo {
73
119
  attribute: boolean;
74
120
  wrapped: boolean;
75
121
  }
122
+ /**
123
+ * Parsed view of a single OpenAPI Callback Object: its name and the
124
+ * operations declared on every callback path.
125
+ */
76
126
  interface CallbackInfo {
77
127
  name: string;
78
128
  operations: OperationInfo[];
79
129
  }
130
+ /**
131
+ * Parsed view of an OpenAPI Link Object — name, target operation
132
+ * (`operationId` or `operationRef`), description, parameter mappings,
133
+ * and the optional request body expression.
134
+ */
80
135
  interface LinkInfo {
81
136
  name: string;
82
137
  operationId: string | undefined;
@@ -85,15 +140,67 @@ interface LinkInfo {
85
140
  parameters: Map<string, string>;
86
141
  requestBody: string | undefined;
87
142
  }
143
+ /**
144
+ * Build an {@link OpenApiDocument} from a raw OpenAPI JSON object.
145
+ *
146
+ * Eagerly indexes the document's `#/components/schemas/*` entries and
147
+ * lazily caches any other `$ref` lookup on first request. Used by
148
+ * every other helper in this module as the single entry point for
149
+ * structured access to an OpenAPI document.
150
+ */
88
151
  declare function parseOpenApiDocument(doc: JsonObject): OpenApiDocument;
89
- declare function getSchema(parsed: OpenApiDocument, ref: string): JsonObject | undefined;
152
+ /**
153
+ * Resolve a `$ref` string against a parsed OpenAPI document. Returns
154
+ * the cached entry for `#/components/schemas/*` refs (or the lazily
155
+ * resolved value for arbitrary fragment refs), or `undefined` when the
156
+ * ref cannot be resolved.
157
+ */
158
+ declare function extractSchema(parsed: OpenApiDocument, ref: string): JsonObject | undefined;
159
+ /**
160
+ * List every operation declared under the document's `paths` map.
161
+ * Follows Path Item `$ref` chains internally; cycles and over-deep
162
+ * chains surface as diagnostics when a sink is supplied.
163
+ */
90
164
  declare function listOperations(parsed: OpenApiDocument, diagnostics?: DiagnosticsOptions, seenIds?: Map<string, string>): OperationInfo[];
91
- declare function getParameters(parsed: OpenApiDocument, path: string, method: string, diagnostics?: DiagnosticsOptions): ParameterInfo[];
92
- declare function getRequestBody(parsed: OpenApiDocument, path: string, method: string): RequestBodyInfo | undefined;
93
- declare function getResponses(parsed: OpenApiDocument, path: string, method: string, diagnostics?: DiagnosticsOptions): ResponseInfo[];
94
- declare function getSecurityRequirements(parsed: OpenApiDocument, path: string, method: string): SecurityRequirement[];
95
- declare function getSecuritySchemes(parsed: OpenApiDocument): Map<string, SecurityScheme>;
96
- declare function getResponseHeaders(response: JsonObject, doc?: JsonObject, diagnostics?: DiagnosticsOptions): Map<string, HeaderInfo>;
165
+ /**
166
+ * Resolve the parameters of a single operation, merging path-level
167
+ * parameters with operation-level overrides and following any
168
+ * Parameter Object `$ref` chains.
169
+ */
170
+ declare function extractParameters(parsed: OpenApiDocument, path: string, method: string, diagnostics?: DiagnosticsOptions): ParameterInfo[];
171
+ /**
172
+ * Resolve the request body of a single operation, including its
173
+ * declared content types and schema. Returns `undefined` when the
174
+ * operation declares no request body.
175
+ */
176
+ declare function extractRequestBody(parsed: OpenApiDocument, path: string, method: string): RequestBodyInfo | undefined;
177
+ /**
178
+ * Resolve the responses of a single operation, returning one
179
+ * {@link ResponseInfo} per declared status code (including class
180
+ * wildcards and `default`).
181
+ */
182
+ declare function extractResponses(parsed: OpenApiDocument, path: string, method: string, diagnostics?: DiagnosticsOptions): ResponseInfo[];
183
+ /**
184
+ * Resolve the effective security requirements for a single operation.
185
+ * Operation-level requirements override the document-level defaults
186
+ * when present.
187
+ */
188
+ declare function extractSecurityRequirements(parsed: OpenApiDocument, path: string, method: string): SecurityRequirement[];
189
+ /**
190
+ * Read the document's `components.securitySchemes` map as a map of
191
+ * scheme names to {@link SecurityScheme} entries.
192
+ */
193
+ declare function extractSecuritySchemes(parsed: OpenApiDocument): Map<string, SecurityScheme>;
194
+ /**
195
+ * Resolve the headers of a single OpenAPI Response Object as a map of
196
+ * header name to {@link HeaderInfo}. Follows Header Object `$ref`
197
+ * chains via the optional document root.
198
+ */
199
+ declare function extractResponseHeaders(response: JsonObject, doc?: JsonObject, diagnostics?: DiagnosticsOptions): Map<string, HeaderInfo>;
200
+ /**
201
+ * List every OpenAPI 3.1 webhook declared under the document's
202
+ * `webhooks` map, each with its name and resolved operations.
203
+ */
97
204
  declare function listWebhooks(parsed: OpenApiDocument, diagnostics?: DiagnosticsOptions, seenIds?: Map<string, string>): WebhookInfo[];
98
205
  /**
99
206
  * Enumerate every operation in the document — both the `paths` map and
@@ -104,9 +211,29 @@ declare function listWebhooks(parsed: OpenApiDocument, diagnostics?: Diagnostics
104
211
  * grouping should call `listWebhooks` directly.
105
212
  */
106
213
  declare function listAllOperations(parsed: OpenApiDocument, diagnostics?: DiagnosticsOptions): OperationInfo[];
107
- declare function getExternalDocs(obj: JsonObject): ExternalDocs | undefined;
108
- declare function getXmlInfo(schema: JsonObject): XmlInfo | undefined;
214
+ /**
215
+ * Read the optional `externalDocs` field on an OpenAPI object
216
+ * (document, operation, tag, schema, ...) into an {@link ExternalDocs}
217
+ * record. Returns `undefined` when absent or malformed.
218
+ */
219
+ declare function extractExternalDocs(obj: JsonObject): ExternalDocs | undefined;
220
+ /**
221
+ * Read the optional `xml` keyword on a JSON Schema object into an
222
+ * {@link XmlInfo} record describing how the field is serialised in an
223
+ * XML payload. Returns `undefined` when absent or malformed.
224
+ */
225
+ declare function extractXmlInfo(schema: JsonObject): XmlInfo | undefined;
226
+ /**
227
+ * List the OpenAPI callback definitions declared on a single
228
+ * operation. Each entry carries the callback name and the operations
229
+ * declared on its Path Item Object.
230
+ */
109
231
  declare function listCallbacks(parsed: OpenApiDocument, path: string, method: string, diagnostics?: DiagnosticsOptions): CallbackInfo[];
110
- declare function getLinks(parsed: OpenApiDocument, path: string, method: string, statusCode: string, diagnostics?: DiagnosticsOptions): LinkInfo[];
232
+ /**
233
+ * List the OpenAPI link definitions declared on a specific response of
234
+ * a single operation, returning each link's parsed
235
+ * {@link LinkInfo} entry.
236
+ */
237
+ declare function extractLinks(parsed: OpenApiDocument, path: string, method: string, statusCode: string, diagnostics?: DiagnosticsOptions): LinkInfo[];
111
238
  //#endregion
112
- 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, listAllOperations, listCallbacks, listOperations, listWebhooks, parseOpenApiDocument };
239
+ export { CallbackInfo, ExternalDocs, HeaderInfo, LinkInfo, OpenApiDocument, OperationInfo, ParameterInfo, ParameterLocation, RequestBodyInfo, ResponseInfo, SecurityRequirement, SecurityScheme, WebhookInfo, XmlInfo, extractExternalDocs, extractLinks, extractParameters, extractRequestBody, extractResponseHeaders, extractResponses, extractSchema, extractSecurityRequirements, extractSecuritySchemes, extractXmlInfo, listAllOperations, listCallbacks, listOperations, listWebhooks, parseOpenApiDocument };
@@ -33,6 +33,14 @@ function toParameterLocation(value, parameterName, pointer, diagnostics) {
33
33
  }
34
34
  });
35
35
  }
36
+ /**
37
+ * Build an {@link OpenApiDocument} from a raw OpenAPI JSON object.
38
+ *
39
+ * Eagerly indexes the document's `#/components/schemas/*` entries and
40
+ * lazily caches any other `$ref` lookup on first request. Used by
41
+ * every other helper in this module as the single entry point for
42
+ * structured access to an OpenAPI document.
43
+ */
36
44
  function parseOpenApiDocument(doc) {
37
45
  const schemas = /* @__PURE__ */ new Map();
38
46
  const componentSchemas = getProperty(getProperty(doc, "components"), "schemas");
@@ -44,7 +52,13 @@ function parseOpenApiDocument(doc) {
44
52
  schemas
45
53
  };
46
54
  }
47
- function getSchema(parsed, ref) {
55
+ /**
56
+ * Resolve a `$ref` string against a parsed OpenAPI document. Returns
57
+ * the cached entry for `#/components/schemas/*` refs (or the lazily
58
+ * resolved value for arbitrary fragment refs), or `undefined` when the
59
+ * ref cannot be resolved.
60
+ */
61
+ function extractSchema(parsed, ref) {
48
62
  const cached = parsed.schemas.get(ref);
49
63
  if (cached !== void 0) return cached;
50
64
  const resolved = resolveRefInDoc(parsed.doc, ref);
@@ -125,6 +139,11 @@ function recordOperationId(operationId, location, pointer, seenIds, diagnostics)
125
139
  }
126
140
  seenIds.set(operationId, location);
127
141
  }
142
+ /**
143
+ * List every operation declared under the document's `paths` map.
144
+ * Follows Path Item `$ref` chains internally; cycles and over-deep
145
+ * chains surface as diagnostics when a sink is supplied.
146
+ */
128
147
  function listOperations(parsed, diagnostics, seenIds = /* @__PURE__ */ new Map()) {
129
148
  const operations = [];
130
149
  const paths = getProperty(parsed.doc, "paths");
@@ -150,7 +169,12 @@ function listOperations(parsed, diagnostics, seenIds = /* @__PURE__ */ new Map()
150
169
  }
151
170
  return operations;
152
171
  }
153
- function getParameters(parsed, path, method, diagnostics) {
172
+ /**
173
+ * Resolve the parameters of a single operation, merging path-level
174
+ * parameters with operation-level overrides and following any
175
+ * Parameter Object `$ref` chains.
176
+ */
177
+ function extractParameters(parsed, path, method, diagnostics) {
154
178
  const pathItem = lookupPathItem(parsed, path);
155
179
  if (pathItem === void 0) return [];
156
180
  const operation = getProperty(pathItem, method);
@@ -246,7 +270,12 @@ function resolveParam(doc, param, diagnostics) {
246
270
  function jsonPointerEscape(segment) {
247
271
  return segment.replace(/~/g, "~0").replace(/\//g, "~1");
248
272
  }
249
- function getRequestBody(parsed, path, method) {
273
+ /**
274
+ * Resolve the request body of a single operation, including its
275
+ * declared content types and schema. Returns `undefined` when the
276
+ * operation declares no request body.
277
+ */
278
+ function extractRequestBody(parsed, path, method) {
250
279
  const requestBodyRaw = getProperty(getProperty(lookupPathItem(parsed, path), method), "requestBody");
251
280
  if (!isObject(requestBodyRaw)) return void 0;
252
281
  const requestBody = resolveWrapperRef(parsed.doc, requestBodyRaw);
@@ -267,7 +296,12 @@ function getRequestBody(parsed, path, method) {
267
296
  schema
268
297
  };
269
298
  }
270
- function getResponses(parsed, path, method, diagnostics) {
299
+ /**
300
+ * Resolve the responses of a single operation, returning one
301
+ * {@link ResponseInfo} per declared status code (including class
302
+ * wildcards and `default`).
303
+ */
304
+ function extractResponses(parsed, path, method, diagnostics) {
271
305
  const responses = getProperty(getProperty(lookupPathItem(parsed, path), method), "responses");
272
306
  if (!isObject(responses)) return [];
273
307
  const result = [];
@@ -278,7 +312,7 @@ function getResponses(parsed, path, method, diagnostics) {
278
312
  const content = getProperty(response, "content");
279
313
  const contentTypes = isObject(content) ? Object.keys(content) : [];
280
314
  const schema = isObject(content) ? extractSchemaFromContent(content) : void 0;
281
- const headers = getResponseHeaders(response, parsed.doc, diagnostics);
315
+ const headers = extractResponseHeaders(response, parsed.doc, diagnostics);
282
316
  result.push({
283
317
  statusCode,
284
318
  description: getString(response, "description"),
@@ -409,7 +443,12 @@ function resolveRefInDoc(doc, ref) {
409
443
  }
410
444
  return isObject(current) ? current : void 0;
411
445
  }
412
- function getSecurityRequirements(parsed, path, method) {
446
+ /**
447
+ * Resolve the effective security requirements for a single operation.
448
+ * Operation-level requirements override the document-level defaults
449
+ * when present.
450
+ */
451
+ function extractSecurityRequirements(parsed, path, method) {
413
452
  const opSecurity = getProperty(getProperty(lookupPathItem(parsed, path), method), "security");
414
453
  const globalSecurity = getProperty(parsed.doc, "security");
415
454
  const securityArray = Array.isArray(opSecurity) ? opSecurity : Array.isArray(globalSecurity) ? globalSecurity : [];
@@ -423,7 +462,11 @@ function getSecurityRequirements(parsed, path, method) {
423
462
  }
424
463
  return result;
425
464
  }
426
- function getSecuritySchemes(parsed) {
465
+ /**
466
+ * Read the document's `components.securitySchemes` map as a map of
467
+ * scheme names to {@link SecurityScheme} entries.
468
+ */
469
+ function extractSecuritySchemes(parsed) {
427
470
  const result = /* @__PURE__ */ new Map();
428
471
  const securitySchemes = getProperty(getProperty(parsed.doc, "components"), "securitySchemes");
429
472
  if (!isObject(securitySchemes)) return result;
@@ -443,7 +486,12 @@ function getSecuritySchemes(parsed) {
443
486
  }
444
487
  return result;
445
488
  }
446
- function getResponseHeaders(response, doc, diagnostics) {
489
+ /**
490
+ * Resolve the headers of a single OpenAPI Response Object as a map of
491
+ * header name to {@link HeaderInfo}. Follows Header Object `$ref`
492
+ * chains via the optional document root.
493
+ */
494
+ function extractResponseHeaders(response, doc, diagnostics) {
447
495
  const result = /* @__PURE__ */ new Map();
448
496
  const headers = getProperty(response, "headers");
449
497
  if (!isObject(headers)) return result;
@@ -461,6 +509,10 @@ function getResponseHeaders(response, doc, diagnostics) {
461
509
  }
462
510
  return result;
463
511
  }
512
+ /**
513
+ * List every OpenAPI 3.1 webhook declared under the document's
514
+ * `webhooks` map, each with its name and resolved operations.
515
+ */
464
516
  function listWebhooks(parsed, diagnostics, seenIds = /* @__PURE__ */ new Map()) {
465
517
  const result = [];
466
518
  const webhooks = getProperty(parsed.doc, "webhooks");
@@ -505,7 +557,12 @@ function listAllOperations(parsed, diagnostics) {
505
557
  const webhookOps = listWebhooks(parsed, diagnostics, seenIds).flatMap((w) => w.operations);
506
558
  return [...pathOps, ...webhookOps];
507
559
  }
508
- function getExternalDocs(obj) {
560
+ /**
561
+ * Read the optional `externalDocs` field on an OpenAPI object
562
+ * (document, operation, tag, schema, ...) into an {@link ExternalDocs}
563
+ * record. Returns `undefined` when absent or malformed.
564
+ */
565
+ function extractExternalDocs(obj) {
509
566
  const docs = getProperty(obj, "externalDocs");
510
567
  if (!isObject(docs)) return void 0;
511
568
  const url = getString(docs, "url");
@@ -515,7 +572,12 @@ function getExternalDocs(obj) {
515
572
  description: getString(docs, "description")
516
573
  };
517
574
  }
518
- function getXmlInfo(schema) {
575
+ /**
576
+ * Read the optional `xml` keyword on a JSON Schema object into an
577
+ * {@link XmlInfo} record describing how the field is serialised in an
578
+ * XML payload. Returns `undefined` when absent or malformed.
579
+ */
580
+ function extractXmlInfo(schema) {
519
581
  const xml = getProperty(schema, "xml");
520
582
  if (!isObject(xml)) return void 0;
521
583
  return {
@@ -526,6 +588,11 @@ function getXmlInfo(schema) {
526
588
  wrapped: getProperty(xml, "wrapped") === true
527
589
  };
528
590
  }
591
+ /**
592
+ * List the OpenAPI callback definitions declared on a single
593
+ * operation. Each entry carries the callback name and the operations
594
+ * declared on its Path Item Object.
595
+ */
529
596
  function listCallbacks(parsed, path, method, diagnostics) {
530
597
  const operation = getProperty(lookupPathItem(parsed, path), method);
531
598
  if (!isObject(operation)) return [];
@@ -559,7 +626,12 @@ function listCallbacks(parsed, path, method, diagnostics) {
559
626
  }
560
627
  return result;
561
628
  }
562
- function getLinks(parsed, path, method, statusCode, diagnostics) {
629
+ /**
630
+ * List the OpenAPI link definitions declared on a specific response of
631
+ * a single operation, returning each link's parsed
632
+ * {@link LinkInfo} entry.
633
+ */
634
+ function extractLinks(parsed, path, method, statusCode, diagnostics) {
563
635
  const response = getProperty(getProperty(getProperty(lookupPathItem(parsed, path), method), "responses"), statusCode);
564
636
  if (!isObject(response)) return [];
565
637
  const links = getProperty(response, "links");
@@ -585,4 +657,4 @@ function getLinks(parsed, path, method, statusCode, diagnostics) {
585
657
  return result;
586
658
  }
587
659
  //#endregion
588
- export { getExternalDocs, getLinks, getParameters, getRequestBody, getResponseHeaders, getResponses, getSchema, getSecurityRequirements, getSecuritySchemes, getXmlInfo, listAllOperations, listCallbacks, listOperations, listWebhooks, parseOpenApiDocument };
660
+ export { extractExternalDocs, extractLinks, extractParameters, extractRequestBody, extractResponseHeaders, extractResponses, extractSchema, extractSecurityRequirements, extractSecuritySchemes, extractXmlInfo, listAllOperations, listCallbacks, listOperations, listWebhooks, parseOpenApiDocument };
@@ -1,5 +1,5 @@
1
- import { i as DiagnosticsOptions } from "../diagnostics-Cbwak-ZX.mjs";
2
- import { OpenApiDocument, OperationInfo, ParameterInfo, ResponseInfo, getRequestBody } from "./parser.mjs";
1
+ import { i as DiagnosticsOptions } from "../diagnostics-BTrm3O6J.mjs";
2
+ import { OpenApiDocument, OperationInfo, ParameterInfo, RequestBodyInfo, ResponseInfo } from "./parser.mjs";
3
3
 
4
4
  //#region src/openapi/resolve.d.ts
5
5
  /**
@@ -11,7 +11,7 @@ import { OpenApiDocument, OperationInfo, ParameterInfo, ResponseInfo, getRequest
11
11
  * keywords (`nullable`, `discriminator`, `example`), OpenAPI 3.1.x
12
12
  * `discriminator`, and Swagger 2.0 documents are all converted to
13
13
  * canonical Draft 2020-12 form. The parser and downstream extractors
14
- * (`getRequestBody`, `getResponses`, etc.) then observe schemas in the
14
+ * (`extractRequestBody`, `extractResponses`, etc.) then observe schemas in the
15
15
  * same form `<SchemaComponent>` does, keeping the OpenAPI components on
16
16
  * the same pipeline as the top-level adapter.
17
17
  *
@@ -58,74 +58,69 @@ interface PathItemInfo {
58
58
  summary: string | undefined;
59
59
  description: string | undefined;
60
60
  }
61
+ /**
62
+ * Aggregate view of a single OpenAPI operation: the operation itself,
63
+ * its Path Item Object context, merged parameters, request body, and
64
+ * responses. Produced by {@link resolveOperation} for rendering and
65
+ * inspection.
66
+ */
61
67
  interface ResolvedOperation {
62
68
  operation: OperationInfo;
63
69
  pathItem: PathItemInfo;
64
70
  parameters: ParameterInfo[];
65
- requestBody: ReturnType<typeof getRequestBody>;
71
+ requestBody: RequestBodyInfo | undefined;
66
72
  responses: ResponseInfo[];
67
73
  }
68
- /**
69
- * Resolve an operation against an already-parsed document. Throws if
70
- * the operation is not found.
71
- *
72
- * Used by callers that have already obtained a parsed document via
73
- * {@link getParsed} — most importantly the React components, which
74
- * supply `diagnostics` to `getParsed` and must avoid re-running the
75
- * normalisation pipeline (every re-run would emit each diagnostic
76
- * again into the sink).
77
- */
78
- declare function resolveOperationFromParsed(parsed: OpenApiDocument, path: string, method: string, diagnostics?: DiagnosticsOptions): ResolvedOperation;
79
74
  /**
80
75
  * Resolve an operation from an OpenAPI document by path and method.
81
76
  * Throws if the operation is not found.
82
77
  *
83
- * `diagnostics` is forwarded to {@link getParsed} so normalisation
84
- * events surface to the caller's sink.
85
- */
86
- declare function resolveOperation(doc: Record<string, unknown>, path: string, method: string, diagnostics?: DiagnosticsOptions): ResolvedOperation;
87
- /**
88
- * Resolve parameters against an already-parsed document. See
89
- * {@link resolveOperationFromParsed} for the rationale.
90
- */
91
- declare function resolveParametersFromParsed(parsed: OpenApiDocument, path: string, method: string): ParameterInfo[];
92
- /**
93
- * Resolve parameters for an operation. Returns empty array if none.
78
+ * Accepts either a raw document (parsed lazily via {@link getParsed}'s
79
+ * WeakMap cache) or an already-parsed {@link OpenApiDocument}. Callers
80
+ * that have a parsed document at hand can pass it directly to avoid
81
+ * an extra cache lookup; everyone else trusts the cache.
94
82
  *
95
83
  * `diagnostics` is forwarded to {@link getParsed} so normalisation
96
- * events surface to the caller's sink.
84
+ * events surface to the caller's sink exactly once per `(doc, sink)`
85
+ * pair, no matter how many times this function is called.
97
86
  */
98
- declare function resolveParameters(doc: Record<string, unknown>, path: string, method: string, diagnostics?: DiagnosticsOptions): ParameterInfo[];
87
+ declare function resolveOperation(doc: Record<string, unknown> | OpenApiDocument, path: string, method: string, diagnostics?: DiagnosticsOptions): ResolvedOperation;
99
88
  /**
100
- * Resolve a request body against an already-parsed document. See
101
- * {@link resolveOperationFromParsed} for the rationale.
102
- */
103
- declare function resolveRequestBodyFromParsed(parsed: OpenApiDocument, path: string, method: string): ReturnType<typeof getRequestBody>;
104
- /**
105
- * Resolve request body for an operation. Returns undefined if none.
89
+ * Resolve parameters for an operation. Returns an empty array if none.
106
90
  *
107
- * `diagnostics` is forwarded to {@link getParsed} so normalisation
108
- * events surface to the caller's sink.
91
+ * Accepts either a raw document or an already-parsed
92
+ * {@link OpenApiDocument}. `diagnostics` is forwarded to
93
+ * {@link getParsed} so normalisation events surface to the caller's
94
+ * sink.
109
95
  */
110
- declare function resolveRequestBody(doc: Record<string, unknown>, path: string, method: string, diagnostics?: DiagnosticsOptions): ReturnType<typeof getRequestBody>;
96
+ declare function resolveParameters(doc: Record<string, unknown> | OpenApiDocument, path: string, method: string, diagnostics?: DiagnosticsOptions): ParameterInfo[];
111
97
  /**
112
- * Resolve a specific response against an already-parsed document. See
113
- * {@link resolveOperationFromParsed} for the rationale.
98
+ * Resolve the request body for an operation. Returns `undefined` if
99
+ * the operation declares no request body.
100
+ *
101
+ * Accepts either a raw document or an already-parsed
102
+ * {@link OpenApiDocument}. `diagnostics` is forwarded to
103
+ * {@link getParsed} so normalisation events surface to the caller's
104
+ * sink.
114
105
  */
115
- declare function resolveResponseFromParsed(parsed: OpenApiDocument, path: string, method: string, statusCode: string): ResponseInfo;
106
+ declare function resolveRequestBody(doc: Record<string, unknown> | OpenApiDocument, path: string, method: string, diagnostics?: DiagnosticsOptions): RequestBodyInfo | undefined;
116
107
  /**
117
108
  * Resolve a specific response by status code. Throws if not found.
118
109
  *
119
- * `diagnostics` is forwarded to {@link getParsed} so normalisation
120
- * events surface to the caller's sink.
110
+ * Accepts either a raw document or an already-parsed
111
+ * {@link OpenApiDocument}. `diagnostics` is forwarded to
112
+ * {@link getParsed} so normalisation events surface to the caller's
113
+ * sink.
121
114
  */
122
- declare function resolveResponse(doc: Record<string, unknown>, path: string, method: string, statusCode: string, diagnostics?: DiagnosticsOptions): ResponseInfo;
115
+ declare function resolveResponse(doc: Record<string, unknown> | OpenApiDocument, path: string, method: string, statusCode: string, diagnostics?: DiagnosticsOptions): ResponseInfo;
123
116
  /**
124
117
  * Resolve all responses for an operation.
125
118
  *
126
- * `diagnostics` is forwarded to {@link getParsed} so normalisation
127
- * events surface to the caller's sink.
119
+ * Accepts either a raw document or an already-parsed
120
+ * {@link OpenApiDocument}. `diagnostics` is forwarded to
121
+ * {@link getParsed} so normalisation events surface to the caller's
122
+ * sink.
128
123
  */
129
- declare function resolveResponses(doc: Record<string, unknown>, path: string, method: string, diagnostics?: DiagnosticsOptions): ResponseInfo[];
124
+ declare function resolveResponses(doc: Record<string, unknown> | OpenApiDocument, path: string, method: string, diagnostics?: DiagnosticsOptions): ResponseInfo[];
130
125
  //#endregion
131
- export { PathItemInfo, ResolvedOperation, getParsed, resolveOperation, resolveOperationFromParsed, resolveParameters, resolveParametersFromParsed, resolveRequestBody, resolveRequestBodyFromParsed, resolveResponse, resolveResponseFromParsed, resolveResponses, toDoc };
126
+ export { PathItemInfo, ResolvedOperation, getParsed, resolveOperation, resolveParameters, resolveRequestBody, resolveResponse, resolveResponses, toDoc };