@kubb/adapter-oas 5.0.0-beta.3 → 5.0.0-beta.30

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,6 +1,6 @@
1
1
  import { t as __name } from "./chunk--u3MIqq1.js";
2
2
  import * as _$_kubb_core0 from "@kubb/core";
3
- import { AdapterFactoryOptions, AdapterSource, ast } from "@kubb/core";
3
+ import { AdapterFactoryOptions, ast } from "@kubb/core";
4
4
  import { DiscriminatorObject as DiscriminatorObject$2, MediaTypeObject as MediaTypeObject$2, OASDocument, ResponseObject as ResponseObject$2, SchemaObject as SchemaObject$2 } from "oas/types";
5
5
  import { Operation as Operation$1 } from "oas/operation";
6
6
 
@@ -418,8 +418,9 @@ type ResponseObject$1 = ResponseObject$2;
418
418
  */
419
419
  type MediaTypeObject$1 = MediaTypeObject$2;
420
420
  /**
421
- * Configuration options for the OpenAPI adapter.
422
- * Controls spec validation, content-type selection, and server URL resolution.
421
+ * Configuration options for the OpenAPI adapter. Controls spec validation,
422
+ * content-type selection, server URL resolution, and how types are derived
423
+ * from the spec.
423
424
  *
424
425
  * @example
425
426
  * ```ts
@@ -433,23 +434,28 @@ type MediaTypeObject$1 = MediaTypeObject$2;
433
434
  */
434
435
  type AdapterOasOptions = {
435
436
  /**
436
- * Validate the OpenAPI spec before parsing.
437
+ * Validate the OpenAPI spec with `@readme/openapi-parser` before parsing.
438
+ * Set to `false` only when you have a known-invalid spec you still want to
439
+ * generate from.
440
+ *
437
441
  * @default true
438
442
  */
439
443
  validate?: boolean;
440
444
  /**
441
- * Preferred content-type used when extracting request/response schemas.
442
- * Defaults to the first valid JSON media type found in the spec.
445
+ * Preferred media type when an operation defines several. Defaults to the
446
+ * first JSON-compatible media type found in the spec.
443
447
  */
444
448
  contentType?: ContentType;
445
449
  /**
446
- * Index into `oas.api.servers` for computing `baseURL`.
447
- * `0` first server, `1` second server. Omit to leave `baseURL` undefined.
450
+ * Index into the `servers` array from your OpenAPI spec. Used to compute the
451
+ * base URL for plugins that need it. Most projects pick `0` for the primary
452
+ * server. Omit to leave `baseURL` undefined.
448
453
  */
449
454
  serverIndex?: number;
450
455
  /**
451
456
  * Override values for `{variable}` placeholders in the selected server URL.
452
- * Only used when `serverIndex` is set.
457
+ * Only used when `serverIndex` is set. Variables you do not provide use
458
+ * their `default` value from the spec.
453
459
  *
454
460
  * @example
455
461
  * ```ts
@@ -460,9 +466,13 @@ type AdapterOasOptions = {
460
466
  */
461
467
  serverVariables?: Record<string, string>;
462
468
  /**
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`.
469
+ * How the `discriminator` field on `oneOf`/`anyOf` schemas is interpreted.
470
+ * - `'strict'` child schemas stay exactly as written; the discriminator
471
+ * narrows types at the call site but child shapes are not modified.
472
+ * - `'inherit'` — Kubb propagates the discriminator property as a literal
473
+ * value into each child schema, so each branch's discriminator field is
474
+ * precisely typed.
475
+ *
466
476
  * @default 'strict'
467
477
  */
468
478
  discriminator?: 'strict' | 'inherit';
@@ -500,14 +510,17 @@ type AdapterOas = AdapterFactoryOptions<'oas', AdapterOasOptions, AdapterOasReso
500
510
  //#endregion
501
511
  //#region src/adapter.d.ts
502
512
  /**
503
- * Stable string identifier for the OAS adapter used in Kubb's adapter registry.
513
+ * Canonical adapter name for `@kubb/adapter-oas`. Used for driver lookups.
504
514
  */
505
515
  declare const adapterOasName = "oas";
506
516
  /**
507
- * Creates the default OpenAPI / Swagger adapter for Kubb.
517
+ * Default Kubb adapter for OpenAPI 2.0, 3.0, and 3.1 specifications. Reads the
518
+ * file at `input.path`, validates it, resolves the base URL, and converts every
519
+ * schema and operation into the universal AST that every downstream plugin
520
+ * consumes.
508
521
  *
509
- * Parses the spec, optionally validates it, resolves the base URL, and converts
510
- * everything into an `InputNode` that downstream plugins consume.
522
+ * Configure once on `defineConfig`. The adapter's choices (date representation,
523
+ * integer width, server URL) apply to every plugin in the build.
511
524
  *
512
525
  * @example
513
526
  * ```ts
@@ -516,8 +529,13 @@ declare const adapterOasName = "oas";
516
529
  * import { pluginTs } from '@kubb/plugin-ts'
517
530
  *
518
531
  * export default defineConfig({
519
- * adapter: adapterOas({ dateType: 'date', serverIndex: 0 }),
520
- * input: { path: './openapi.yaml' },
532
+ * input: { path: './petStore.yaml' },
533
+ * output: { path: './src/gen' },
534
+ * adapter: adapterOas({
535
+ * serverIndex: 0,
536
+ * discriminator: 'inherit',
537
+ * dateType: 'date',
538
+ * }),
521
539
  * plugins: [pluginTs()],
522
540
  * })
523
541
  * ```
@@ -525,30 +543,9 @@ declare const adapterOasName = "oas";
525
543
  declare const adapterOas: (options?: AdapterOasOptions | undefined) => _$_kubb_core0.Adapter<AdapterOas>;
526
544
  //#endregion
527
545
  //#region src/factory.d.ts
528
- type ParseOptions = {
529
- canBundle?: boolean;
530
- enablePaths?: boolean;
531
- };
532
546
  type ValidateDocumentOptions = {
533
547
  throwOnError?: boolean;
534
548
  };
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
549
  /**
553
550
  * Deep-merges multiple OpenAPI documents into a single `Document`.
554
551
  *
@@ -561,32 +558,6 @@ declare function parseDocument(pathOrApi: string | Document, {
561
558
  * ```
562
559
  */
563
560
  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>;
590
561
  //#endregion
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 };
562
+ 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 ReferenceObject$1 as ReferenceObject, type ResponseObject$1 as ResponseObject, type SchemaObject$1 as SchemaObject, type ValidateDocumentOptions, adapterOas, adapterOasName, mergeDocuments };
592
563
  //# sourceMappingURL=index.d.ts.map