@kubb/adapter-oas 5.0.0-beta.4 → 5.0.0-beta.40

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