@kubb/adapter-oas 5.0.0-alpha.8 → 5.0.0-beta.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,115 +1,450 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
2
- import * as _kubb_core0 from "@kubb/core";
3
- import { AdapterFactoryOptions } from "@kubb/core";
4
- import { DiscriminatorObject, OASDocument, SchemaObject } from "oas/types";
5
- import BaseOas from "oas";
6
- import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
7
- import { Operation } from "oas/operation";
8
- import { OpenAPIV3 } from "openapi-types";
2
+ import * as _$_kubb_core0 from "@kubb/core";
3
+ import { AdapterFactoryOptions, AdapterSource, ast } from "@kubb/core";
4
+ import { DiscriminatorObject as DiscriminatorObject$2, MediaTypeObject as MediaTypeObject$2, OASDocument, ResponseObject as ResponseObject$2, SchemaObject as SchemaObject$2 } from "oas/types";
5
+ import { Operation as Operation$1 } from "oas/operation";
9
6
 
10
- //#region src/oas/types.d.ts
11
- type contentType = 'application/json' | (string & {});
12
- type SchemaObject$1 = SchemaObject & {
7
+ //#region ../../node_modules/.pnpm/openapi-types@12.1.3/node_modules/openapi-types/dist/index.d.ts
8
+ declare namespace OpenAPIV3 {
9
+ interface Document<T extends {} = {}> {
10
+ openapi: string;
11
+ info: InfoObject;
12
+ servers?: ServerObject[];
13
+ paths: PathsObject<T>;
14
+ components?: ComponentsObject;
15
+ security?: SecurityRequirementObject[];
16
+ tags?: TagObject[];
17
+ externalDocs?: ExternalDocumentationObject;
18
+ 'x-express-openapi-additional-middleware'?: (((request: any, response: any, next: any) => Promise<void>) | ((request: any, response: any, next: any) => void))[];
19
+ 'x-express-openapi-validation-strict'?: boolean;
20
+ }
21
+ interface InfoObject {
22
+ title: string;
23
+ description?: string;
24
+ termsOfService?: string;
25
+ contact?: ContactObject;
26
+ license?: LicenseObject;
27
+ version: string;
28
+ }
29
+ interface ContactObject {
30
+ name?: string;
31
+ url?: string;
32
+ email?: string;
33
+ }
34
+ interface LicenseObject {
35
+ name: string;
36
+ url?: string;
37
+ }
38
+ interface ServerObject {
39
+ url: string;
40
+ description?: string;
41
+ variables?: {
42
+ [variable: string]: ServerVariableObject;
43
+ };
44
+ }
45
+ interface ServerVariableObject {
46
+ enum?: string[];
47
+ default: string;
48
+ description?: string;
49
+ }
50
+ interface PathsObject<T extends {} = {}, P extends {} = {}> {
51
+ [pattern: string]: (PathItemObject<T> & P) | undefined;
52
+ }
53
+ enum HttpMethods {
54
+ GET = "get",
55
+ PUT = "put",
56
+ POST = "post",
57
+ DELETE = "delete",
58
+ OPTIONS = "options",
59
+ HEAD = "head",
60
+ PATCH = "patch",
61
+ TRACE = "trace"
62
+ }
63
+ type PathItemObject<T extends {} = {}> = {
64
+ $ref?: string;
65
+ summary?: string;
66
+ description?: string;
67
+ servers?: ServerObject[];
68
+ parameters?: (ReferenceObject | ParameterObject)[];
69
+ } & { [method in HttpMethods]?: OperationObject<T> };
70
+ type OperationObject<T extends {} = {}> = {
71
+ tags?: string[];
72
+ summary?: string;
73
+ description?: string;
74
+ externalDocs?: ExternalDocumentationObject;
75
+ operationId?: string;
76
+ parameters?: (ReferenceObject | ParameterObject)[];
77
+ requestBody?: ReferenceObject | RequestBodyObject;
78
+ responses: ResponsesObject;
79
+ callbacks?: {
80
+ [callback: string]: ReferenceObject | CallbackObject;
81
+ };
82
+ deprecated?: boolean;
83
+ security?: SecurityRequirementObject[];
84
+ servers?: ServerObject[];
85
+ } & T;
86
+ interface ExternalDocumentationObject {
87
+ description?: string;
88
+ url: string;
89
+ }
90
+ interface ParameterObject extends ParameterBaseObject {
91
+ name: string;
92
+ in: string;
93
+ }
94
+ interface HeaderObject extends ParameterBaseObject {}
95
+ interface ParameterBaseObject {
96
+ description?: string;
97
+ required?: boolean;
98
+ deprecated?: boolean;
99
+ allowEmptyValue?: boolean;
100
+ style?: string;
101
+ explode?: boolean;
102
+ allowReserved?: boolean;
103
+ schema?: ReferenceObject | SchemaObject;
104
+ example?: any;
105
+ examples?: {
106
+ [media: string]: ReferenceObject | ExampleObject;
107
+ };
108
+ content?: {
109
+ [media: string]: MediaTypeObject;
110
+ };
111
+ }
112
+ type NonArraySchemaObjectType = 'boolean' | 'object' | 'number' | 'string' | 'integer';
113
+ type ArraySchemaObjectType = 'array';
114
+ type SchemaObject = ArraySchemaObject | NonArraySchemaObject;
115
+ interface ArraySchemaObject extends BaseSchemaObject {
116
+ type: ArraySchemaObjectType;
117
+ items: ReferenceObject | SchemaObject;
118
+ }
119
+ interface NonArraySchemaObject extends BaseSchemaObject {
120
+ type?: NonArraySchemaObjectType;
121
+ }
122
+ interface BaseSchemaObject {
123
+ title?: string;
124
+ description?: string;
125
+ format?: string;
126
+ default?: any;
127
+ multipleOf?: number;
128
+ maximum?: number;
129
+ exclusiveMaximum?: boolean;
130
+ minimum?: number;
131
+ exclusiveMinimum?: boolean;
132
+ maxLength?: number;
133
+ minLength?: number;
134
+ pattern?: string;
135
+ additionalProperties?: boolean | ReferenceObject | SchemaObject;
136
+ maxItems?: number;
137
+ minItems?: number;
138
+ uniqueItems?: boolean;
139
+ maxProperties?: number;
140
+ minProperties?: number;
141
+ required?: string[];
142
+ enum?: any[];
143
+ properties?: {
144
+ [name: string]: ReferenceObject | SchemaObject;
145
+ };
146
+ allOf?: (ReferenceObject | SchemaObject)[];
147
+ oneOf?: (ReferenceObject | SchemaObject)[];
148
+ anyOf?: (ReferenceObject | SchemaObject)[];
149
+ not?: ReferenceObject | SchemaObject;
150
+ nullable?: boolean;
151
+ discriminator?: DiscriminatorObject;
152
+ readOnly?: boolean;
153
+ writeOnly?: boolean;
154
+ xml?: XMLObject;
155
+ externalDocs?: ExternalDocumentationObject;
156
+ example?: any;
157
+ deprecated?: boolean;
158
+ }
159
+ interface DiscriminatorObject {
160
+ propertyName: string;
161
+ mapping?: {
162
+ [value: string]: string;
163
+ };
164
+ }
165
+ interface XMLObject {
166
+ name?: string;
167
+ namespace?: string;
168
+ prefix?: string;
169
+ attribute?: boolean;
170
+ wrapped?: boolean;
171
+ }
172
+ interface ReferenceObject {
173
+ $ref: string;
174
+ }
175
+ interface ExampleObject {
176
+ summary?: string;
177
+ description?: string;
178
+ value?: any;
179
+ externalValue?: string;
180
+ }
181
+ interface MediaTypeObject {
182
+ schema?: ReferenceObject | SchemaObject;
183
+ example?: any;
184
+ examples?: {
185
+ [media: string]: ReferenceObject | ExampleObject;
186
+ };
187
+ encoding?: {
188
+ [media: string]: EncodingObject;
189
+ };
190
+ }
191
+ interface EncodingObject {
192
+ contentType?: string;
193
+ headers?: {
194
+ [header: string]: ReferenceObject | HeaderObject;
195
+ };
196
+ style?: string;
197
+ explode?: boolean;
198
+ allowReserved?: boolean;
199
+ }
200
+ interface RequestBodyObject {
201
+ description?: string;
202
+ content: {
203
+ [media: string]: MediaTypeObject;
204
+ };
205
+ required?: boolean;
206
+ }
207
+ interface ResponsesObject {
208
+ [code: string]: ReferenceObject | ResponseObject;
209
+ }
210
+ interface ResponseObject {
211
+ description: string;
212
+ headers?: {
213
+ [header: string]: ReferenceObject | HeaderObject;
214
+ };
215
+ content?: {
216
+ [media: string]: MediaTypeObject;
217
+ };
218
+ links?: {
219
+ [link: string]: ReferenceObject | LinkObject;
220
+ };
221
+ }
222
+ interface LinkObject {
223
+ operationRef?: string;
224
+ operationId?: string;
225
+ parameters?: {
226
+ [parameter: string]: any;
227
+ };
228
+ requestBody?: any;
229
+ description?: string;
230
+ server?: ServerObject;
231
+ }
232
+ interface CallbackObject {
233
+ [url: string]: PathItemObject;
234
+ }
235
+ interface SecurityRequirementObject {
236
+ [name: string]: string[];
237
+ }
238
+ interface ComponentsObject {
239
+ schemas?: {
240
+ [key: string]: ReferenceObject | SchemaObject;
241
+ };
242
+ responses?: {
243
+ [key: string]: ReferenceObject | ResponseObject;
244
+ };
245
+ parameters?: {
246
+ [key: string]: ReferenceObject | ParameterObject;
247
+ };
248
+ examples?: {
249
+ [key: string]: ReferenceObject | ExampleObject;
250
+ };
251
+ requestBodies?: {
252
+ [key: string]: ReferenceObject | RequestBodyObject;
253
+ };
254
+ headers?: {
255
+ [key: string]: ReferenceObject | HeaderObject;
256
+ };
257
+ securitySchemes?: {
258
+ [key: string]: ReferenceObject | SecuritySchemeObject;
259
+ };
260
+ links?: {
261
+ [key: string]: ReferenceObject | LinkObject;
262
+ };
263
+ callbacks?: {
264
+ [key: string]: ReferenceObject | CallbackObject;
265
+ };
266
+ }
267
+ type SecuritySchemeObject = HttpSecurityScheme | ApiKeySecurityScheme | OAuth2SecurityScheme | OpenIdSecurityScheme;
268
+ interface HttpSecurityScheme {
269
+ type: 'http';
270
+ description?: string;
271
+ scheme: string;
272
+ bearerFormat?: string;
273
+ }
274
+ interface ApiKeySecurityScheme {
275
+ type: 'apiKey';
276
+ description?: string;
277
+ name: string;
278
+ in: string;
279
+ }
280
+ interface OAuth2SecurityScheme {
281
+ type: 'oauth2';
282
+ description?: string;
283
+ flows: {
284
+ implicit?: {
285
+ authorizationUrl: string;
286
+ refreshUrl?: string;
287
+ scopes: {
288
+ [scope: string]: string;
289
+ };
290
+ };
291
+ password?: {
292
+ tokenUrl: string;
293
+ refreshUrl?: string;
294
+ scopes: {
295
+ [scope: string]: string;
296
+ };
297
+ };
298
+ clientCredentials?: {
299
+ tokenUrl: string;
300
+ refreshUrl?: string;
301
+ scopes: {
302
+ [scope: string]: string;
303
+ };
304
+ };
305
+ authorizationCode?: {
306
+ authorizationUrl: string;
307
+ tokenUrl: string;
308
+ refreshUrl?: string;
309
+ scopes: {
310
+ [scope: string]: string;
311
+ };
312
+ };
313
+ };
314
+ }
315
+ interface OpenIdSecurityScheme {
316
+ type: 'openIdConnect';
317
+ description?: string;
318
+ openIdConnectUrl: string;
319
+ }
320
+ interface TagObject {
321
+ name: string;
322
+ description?: string;
323
+ externalDocs?: ExternalDocumentationObject;
324
+ }
325
+ }
326
+ //#endregion
327
+ //#region src/types.d.ts
328
+ /**
329
+ * Content-type string for selecting request/response schemas from an OpenAPI spec.
330
+ * Supports `'application/json'` or any other media type.
331
+ *
332
+ * @example
333
+ * ```ts
334
+ * const ct: ContentType = 'application/vnd.api+json'
335
+ * ```
336
+ */
337
+ type ContentType = 'application/json' | (string & {});
338
+ /**
339
+ * Extended OpenAPI 3.0 schema object that includes OpenAPI 3.1 and JSON Schema fields.
340
+ * The parser uses these additional fields to handle newer spec versions.
341
+ *
342
+ * @example
343
+ * ```ts
344
+ * const schema: SchemaObject = {
345
+ * type: 'string',
346
+ * const: 'dog',
347
+ * contentMediaType: 'application/octet-stream',
348
+ * }
349
+ * ```
350
+ */
351
+ type SchemaObject$1 = SchemaObject$2 & {
13
352
  /**
14
- * OAS 3.1 extension: allows marking a schema as nullable even when `type` does not include `'null'`.
353
+ * OAS 3.0 vendor extension: marks a schema as nullable without using `type: ['null', ...]`.
15
354
  */
16
355
  'x-nullable'?: boolean;
17
356
  /**
18
- * OAS 3.1: constrains the schema to a single fixed value.
19
- * Semantically equivalent to a one-item `enum`.
357
+ * OAS 3.1: constrains the schema to a single fixed value (equivalent to a one-item `enum`).
20
358
  */
21
359
  const?: string | number | boolean | null;
22
360
  /**
23
- * OAS 3.1: specifies the media type of the schema content.
24
- * When set to `'application/octet-stream'` on a `string` schema, the schema is treated as binary (`blob`).
361
+ * OAS 3.1: media type of the schema content. `'application/octet-stream'` on a `string` schema maps to `blob`.
25
362
  */
26
363
  contentMediaType?: string;
27
364
  $ref?: string;
28
365
  /**
29
- * OAS 3.1 / JSON Schema: positional items in a tuple schema.
30
- * Replaces the OAS 3.0 multi-item `items` array syntax.
366
+ * OAS 3.1: positional tuple items, replacing the multi-item `items` array from OAS 3.0.
31
367
  */
32
- prefixItems?: Array<SchemaObject$1 | ReferenceObject>;
368
+ prefixItems?: Array<SchemaObject$1 | ReferenceObject$1>;
33
369
  /**
34
- * JSON Schema: maps regex patterns to sub-schemas for additional property validation.
370
+ * JSON Schema: maps regex patterns to sub-schemas for validating additional properties.
35
371
  */
36
372
  patternProperties?: Record<string, SchemaObject$1 | boolean>;
37
373
  /**
38
- * OAS 3.0 / JSON Schema: single-schema form.
39
- * The OAS base type already includes this, but we re-declare it here to ensure
40
- * the single-schema overload takes precedence over the multi-schema tuple form.
374
+ * Single-schema form of `items`. Narrowed from the base type to take precedence over the tuple overload.
41
375
  */
42
- items?: SchemaObject$1 | ReferenceObject;
376
+ items?: SchemaObject$1 | ReferenceObject$1;
43
377
  /**
44
- * Enum values for this schema (narrowed from `unknown[]` in the base type).
378
+ * Enum values for this schema (narrowed from `unknown[]`).
45
379
  */
46
380
  enum?: Array<string | number | boolean | null>;
47
381
  };
382
+ /**
383
+ * Maps uppercase HTTP method names to lowercase for backwards compatibility.
384
+ *
385
+ * @example
386
+ * ```ts
387
+ * HttpMethods['GET'] // 'get'
388
+ * HttpMethods['POST'] // 'post'
389
+ * ```
390
+ */
391
+ declare const HttpMethods$1: Record<Uppercase<ast.HttpMethod>, Lowercase<ast.HttpMethod>>;
392
+ /**
393
+ * HTTP method as a lowercase string (`'get' | 'post' | ...`).
394
+ */
395
+ type HttpMethod = Lowercase<ast.HttpMethod>;
396
+ /**
397
+ * Normalized OpenAPI document after parsing.
398
+ */
48
399
  type Document = OASDocument;
49
- type Operation$1 = Operation;
50
- type DiscriminatorObject$1 = DiscriminatorObject;
51
- type ReferenceObject = OpenAPIV3.ReferenceObject;
52
- //#endregion
53
- //#region src/oas/Oas.d.ts
54
- type OasOptions = {
55
- contentType?: contentType;
56
- discriminator?: 'strict' | 'inherit';
57
- /**
58
- * Resolve name collisions when schemas from different components share the same name (case-insensitive).
59
- * @default false
60
- */
61
- collisionDetection?: boolean;
62
- };
63
- declare class Oas extends BaseOas {
64
- #private;
65
- document: Document;
66
- constructor(document: Document);
67
- setOptions(options: OasOptions): void;
68
- get options(): OasOptions;
69
- get<T = unknown>($ref: string): T | null;
70
- getKey($ref: string): string | undefined;
71
- set($ref: string, value: unknown): false | undefined;
72
- getDiscriminator(schema: SchemaObject$1 | null): DiscriminatorObject$1 | null;
73
- dereferenceWithRef<T = unknown>(schema?: T): T;
74
- getResponseSchema(operation: Operation$1, statusCode: string | number): SchemaObject$1;
75
- getRequestSchema(operation: Operation$1): SchemaObject$1 | undefined;
76
- getParametersSchema(operation: Operation$1, inKey: 'path' | 'query' | 'header'): SchemaObject$1 | null;
77
- validate(): Promise<oas_normalize_lib_types0.ValidationResult>;
78
- flattenSchema(schema: SchemaObject$1 | null): SchemaObject$1 | null;
79
- /**
80
- * Get schemas from OpenAPI components (schemas, responses, requestBodies).
81
- * Returns schemas in dependency order along with name mapping for collision resolution.
82
- */
83
- getSchemas(options?: {
84
- contentType?: contentType;
85
- includes?: Array<'schemas' | 'responses' | 'requestBodies'>;
86
- collisionDetection?: boolean;
87
- }): {
88
- schemas: Record<string, SchemaObject$1>;
89
- nameMapping: Map<string, string>;
90
- };
91
- }
92
- //#endregion
93
- //#region src/types.d.ts
94
- type OasAdapterOptions = {
400
+ /**
401
+ * API operation extracted from an OpenAPI document.
402
+ */
403
+ type Operation = Operation$1;
404
+ /**
405
+ * Discriminator object for `oneOf`/`anyOf` schemas in OpenAPI.
406
+ */
407
+ type DiscriminatorObject$1 = DiscriminatorObject$2;
408
+ /**
409
+ * OpenAPI reference object pointing to a schema definition via `$ref`.
410
+ */
411
+ type ReferenceObject$1 = OpenAPIV3.ReferenceObject;
412
+ /**
413
+ * OpenAPI response object from a spec that contains schema, status code, and headers.
414
+ */
415
+ type ResponseObject$1 = ResponseObject$2;
416
+ /**
417
+ * OpenAPI media type object that maps a content-type string to its schema.
418
+ */
419
+ type MediaTypeObject$1 = MediaTypeObject$2;
420
+ /**
421
+ * Configuration options for the OpenAPI adapter.
422
+ * Controls spec validation, content-type selection, and server URL resolution.
423
+ *
424
+ * @example
425
+ * ```ts
426
+ * adapterOas({
427
+ * validate: false,
428
+ * dateType: 'date',
429
+ * serverIndex: 0,
430
+ * serverVariables: { env: 'prod' },
431
+ * })
432
+ * ```
433
+ */
434
+ type AdapterOasOptions = {
95
435
  /**
96
436
  * Validate the OpenAPI spec before parsing.
97
437
  * @default true
98
438
  */
99
439
  validate?: boolean;
100
440
  /**
101
- * Override the `Oas` class (e.g. for custom subclass behavior).
441
+ * Preferred content-type used when extracting request/response schemas.
442
+ * Defaults to the first valid JSON media type found in the spec.
102
443
  */
103
- oasClass?: typeof Oas;
444
+ contentType?: ContentType;
104
445
  /**
105
- * Restrict which content-type is used when extracting request/response schemas.
106
- * By default, the first valid JSON media type is used.
107
- */
108
- contentType?: contentType;
109
- /**
110
- * Which server to use from `oas.api.servers` when computing `baseURL`.
111
- * - `0` → first server, `1` → second server, etc.
112
- * - When omitted, `baseURL` in the resulting `RootNode.meta` is `undefined`.
446
+ * Index into `oas.api.servers` for computing `baseURL`.
447
+ * `0` → first server, `1` second server. Omit to leave `baseURL` undefined.
113
448
  */
114
449
  serverIndex?: number;
115
450
  /**
@@ -117,89 +452,141 @@ type OasAdapterOptions = {
117
452
  * Only used when `serverIndex` is set.
118
453
  *
119
454
  * @example
455
+ * ```ts
120
456
  * // spec server: "https://api.{env}.example.com"
121
457
  * serverVariables: { env: 'prod' }
122
458
  * // → baseURL: "https://api.prod.example.com"
459
+ * ```
123
460
  */
124
461
  serverVariables?: Record<string, string>;
125
462
  /**
126
- * How the discriminator field should be interpreted.
127
- * - `'strict'` — uses `oneOf` schemas as defined.
128
- * - `'inherit'` — replaces `oneOf` with the schema from `discriminator.mapping`.
463
+ * How the discriminator field is interpreted.
464
+ * - `'strict'` — uses `oneOf` schemas as written in the spec.
465
+ * - `'inherit'` — propagates discriminator values into child schemas from `discriminator.mapping`.
129
466
  * @default 'strict'
130
467
  */
131
468
  discriminator?: 'strict' | 'inherit';
132
- /**
133
- * Automatically resolve name collisions across schema components.
134
- * @default false
135
- */
136
- collisionDetection?: boolean;
137
- /**
138
- * How `format: 'date-time'` schemas are represented in the AST.
139
- * - `'string'` maps to a `datetime` string node.
140
- * - `'date'` maps to a JavaScript `Date` node.
141
- * - `false` falls through to a plain `string` node.
142
- * @default 'string'
143
- */
144
- dateType?: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
145
- /**
146
- * Whether `type: 'integer'` / `format: 'int64'` produces `number` or `bigint` nodes.
147
- * @default 'number'
148
- */
149
- integerType?: 'number' | 'bigint';
150
- /**
151
- * AST type used when no schema type can be inferred.
152
- * @default 'any'
153
- */
154
- unknownType?: 'any' | 'unknown' | 'void';
155
- /**
156
- * AST type used for completely empty schemas (`{}`).
157
- * @default `unknownType`
158
- */
159
- emptySchemaType?: 'any' | 'unknown' | 'void';
160
- };
161
- type OasAdapterResolvedOptions = {
469
+ } & Partial<ast.ParserOptions>;
470
+ /**
471
+ * Adapter options after defaults have been applied and schema name collisions resolved.
472
+ */
473
+ type AdapterOasResolvedOptions = {
162
474
  validate: boolean;
163
- oasClass: OasAdapterOptions['oasClass'];
164
- contentType: OasAdapterOptions['contentType'];
165
- serverIndex: OasAdapterOptions['serverIndex'];
166
- serverVariables: OasAdapterOptions['serverVariables'];
167
- discriminator: NonNullable<OasAdapterOptions['discriminator']>;
168
- collisionDetection: boolean;
169
- dateType: NonNullable<OasAdapterOptions['dateType']>;
170
- integerType: NonNullable<OasAdapterOptions['integerType']>;
171
- unknownType: NonNullable<OasAdapterOptions['unknownType']>;
172
- emptySchemaType: NonNullable<OasAdapterOptions['emptySchemaType']>;
475
+ contentType: AdapterOasOptions['contentType'];
476
+ serverIndex: AdapterOasOptions['serverIndex'];
477
+ serverVariables: AdapterOasOptions['serverVariables'];
478
+ discriminator: NonNullable<AdapterOasOptions['discriminator']>;
479
+ dateType: NonNullable<AdapterOasOptions['dateType']>;
480
+ integerType: NonNullable<AdapterOasOptions['integerType']>;
481
+ unknownType: NonNullable<AdapterOasOptions['unknownType']>;
482
+ emptySchemaType: NonNullable<AdapterOasOptions['emptySchemaType']>;
483
+ enumSuffix: AdapterOasOptions['enumSuffix'];
173
484
  /**
174
485
  * Map from original `$ref` paths to their collision-resolved schema names.
175
- * Populated by the adapter after each `parse()` call.
176
- * e.g. `'#/components/schemas/Order'` → `'OrderSchema'`
486
+ * Populated after each `parse()` call.
487
+ *
488
+ * @example
489
+ * ```ts
490
+ * nameMapping.get('#/components/schemas/Order') // 'Order'
491
+ * nameMapping.get('#/components/responses/Order') // 'OrderResponse'
492
+ * ```
177
493
  */
178
494
  nameMapping: Map<string, string>;
179
495
  };
180
- type OasAdapter = AdapterFactoryOptions<'oas', OasAdapterOptions, OasAdapterResolvedOptions>;
496
+ /**
497
+ * `@kubb/core` adapter factory type for the OpenAPI adapter.
498
+ */
499
+ type AdapterOas = AdapterFactoryOptions<'oas', AdapterOasOptions, AdapterOasResolvedOptions, Document>;
181
500
  //#endregion
182
501
  //#region src/adapter.d.ts
502
+ /**
503
+ * Stable string identifier for the OAS adapter used in Kubb's adapter registry.
504
+ */
183
505
  declare const adapterOasName = "oas";
184
506
  /**
185
- * Creates an OpenAPI / Swagger adapter for Kubb.
507
+ * Creates the default OpenAPI / Swagger adapter for Kubb.
186
508
  *
187
- * This is the default adapter you can omit it from your config when using
188
- * an OpenAPI spec, but supplying it explicitly lets you pass options.
509
+ * Parses the spec, optionally validates it, resolves the base URL, and converts
510
+ * everything into an `InputNode` that downstream plugins consume.
189
511
  *
190
512
  * @example
191
513
  * ```ts
192
- * import { defineConfig } from '@kubb/core'
514
+ * import { defineConfig } from 'kubb'
193
515
  * import { adapterOas } from '@kubb/adapter-oas'
516
+ * import { pluginTs } from '@kubb/plugin-ts'
194
517
  *
195
518
  * export default defineConfig({
196
- * adapter: adapterOas({ validate: true, dateType: 'date' }),
197
- * input: { path: './openapi.yaml' },
198
- * plugins: [pluginTs(), pluginZod()],
519
+ * adapter: adapterOas({ dateType: 'date', serverIndex: 0 }),
520
+ * input: { path: './openapi.yaml' },
521
+ * plugins: [pluginTs()],
199
522
  * })
200
523
  * ```
201
524
  */
202
- declare const adapterOas: (options?: OasAdapterOptions | undefined) => _kubb_core0.Adapter<OasAdapter>;
525
+ declare const adapterOas: (options?: AdapterOasOptions | undefined) => _$_kubb_core0.Adapter<AdapterOas>;
526
+ //#endregion
527
+ //#region src/factory.d.ts
528
+ type ParseOptions = {
529
+ canBundle?: boolean;
530
+ enablePaths?: boolean;
531
+ };
532
+ type ValidateDocumentOptions = {
533
+ throwOnError?: boolean;
534
+ };
535
+ /**
536
+ * Loads and dereferences an OpenAPI document, returning the raw `Document`.
537
+ *
538
+ * Accepts a file path string or an already-parsed document object. File paths are bundled via
539
+ * Redocly to resolve external `$ref`s. Swagger 2.0 documents are automatically up-converted
540
+ * to OpenAPI 3.0 via `swagger2openapi`.
541
+ *
542
+ * @example
543
+ * ```ts
544
+ * const document = await parseDocument('./openapi.yaml')
545
+ * const document = await parse(rawDocumentObject, { canBundle: false })
546
+ * ```
547
+ */
548
+ declare function parseDocument(pathOrApi: string | Document, {
549
+ canBundle,
550
+ enablePaths
551
+ }?: ParseOptions): Promise<Document>;
552
+ /**
553
+ * Deep-merges multiple OpenAPI documents into a single `Document`.
554
+ *
555
+ * Each document is parsed independently then recursively merged via `mergeDeep` from `@internals/utils`.
556
+ * Throws when the input array is empty.
557
+ *
558
+ * @example
559
+ * ```ts
560
+ * const document = await mergeDocuments(['./pets.yaml', './orders.yaml'])
561
+ * ```
562
+ */
563
+ declare function mergeDocuments(pathOrApi: Array<string | Document>): Promise<Document>;
564
+ /**
565
+ * Creates a `Document` from an `AdapterSource`.
566
+ *
567
+ * Handles all three source types:
568
+ * - `{ type: 'path' }` — resolves and bundles a local file path or remote URL.
569
+ * - `{ type: 'paths' }` — merges multiple file paths into a single document.
570
+ * - `{ type: 'data' }` — parses an inline string (YAML/JSON) or raw object.
571
+ *
572
+ * @example
573
+ * ```ts
574
+ * const document = await parseFromConfig({ type: 'path', path: './openapi.yaml' })
575
+ * const document = await parseFromConfig({ type: 'data', data: '{"openapi":"3.0.0",...}' })
576
+ * ```
577
+ */
578
+ declare function parseFromConfig(source: AdapterSource): Promise<Document>;
579
+ /**
580
+ * Validates an OpenAPI document using `oas-normalize` with colorized error output.
581
+ *
582
+ * @example
583
+ * ```ts
584
+ * await validateDocument(document)
585
+ * ```
586
+ */
587
+ declare function validateDocument(document: Document, {
588
+ throwOnError
589
+ }?: ValidateDocumentOptions): Promise<void>;
203
590
  //#endregion
204
- export { adapterOas, adapterOasName };
591
+ export { type AdapterOas, type AdapterOasOptions, type AdapterOasResolvedOptions, type ContentType, type DiscriminatorObject$1 as DiscriminatorObject, type Document, type HttpMethod, HttpMethods$1 as HttpMethods, type MediaTypeObject$1 as MediaTypeObject, type Operation, type ParseOptions, type ReferenceObject$1 as ReferenceObject, type ResponseObject$1 as ResponseObject, type SchemaObject$1 as SchemaObject, type ValidateDocumentOptions, adapterOas, adapterOasName, mergeDocuments, parseDocument, parseFromConfig, validateDocument };
205
592
  //# sourceMappingURL=index.d.ts.map