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

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,12 +466,28 @@ 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';
479
+ /**
480
+ * Collapse structurally identical schemas and enums into a single shared definition.
481
+ *
482
+ * Duplicated inline shapes (especially enums repeated across many properties) are hoisted
483
+ * into one named schema; every other occurrence — and any structurally identical top-level
484
+ * component — becomes a `ref` to it. Equality is shape-only: documentation such as
485
+ * `description` and `example` is ignored. Enabled by default; set to `false` to keep every
486
+ * occurrence inline and produce byte-for-byte identical output to earlier versions.
487
+ *
488
+ * @default true
489
+ */
490
+ dedupe?: boolean;
469
491
  } & Partial<ast.ParserOptions>;
470
492
  /**
471
493
  * Adapter options after defaults have been applied and schema name collisions resolved.
@@ -476,6 +498,7 @@ type AdapterOasResolvedOptions = {
476
498
  serverIndex: AdapterOasOptions['serverIndex'];
477
499
  serverVariables: AdapterOasOptions['serverVariables'];
478
500
  discriminator: NonNullable<AdapterOasOptions['discriminator']>;
501
+ dedupe: NonNullable<AdapterOasOptions['dedupe']>;
479
502
  dateType: NonNullable<AdapterOasOptions['dateType']>;
480
503
  integerType: NonNullable<AdapterOasOptions['integerType']>;
481
504
  unknownType: NonNullable<AdapterOasOptions['unknownType']>;
@@ -500,14 +523,17 @@ type AdapterOas = AdapterFactoryOptions<'oas', AdapterOasOptions, AdapterOasReso
500
523
  //#endregion
501
524
  //#region src/adapter.d.ts
502
525
  /**
503
- * Stable string identifier for the OAS adapter used in Kubb's adapter registry.
526
+ * Canonical adapter name for `@kubb/adapter-oas`. Used for driver lookups.
504
527
  */
505
528
  declare const adapterOasName = "oas";
506
529
  /**
507
- * Creates the default OpenAPI / Swagger adapter for Kubb.
530
+ * Default Kubb adapter for OpenAPI 2.0, 3.0, and 3.1 specifications. Reads the
531
+ * file at `input.path`, validates it, resolves the base URL, and converts every
532
+ * schema and operation into the universal AST that every downstream plugin
533
+ * consumes.
508
534
  *
509
- * Parses the spec, optionally validates it, resolves the base URL, and converts
510
- * everything into an `InputNode` that downstream plugins consume.
535
+ * Configure once on `defineConfig`. The adapter's choices (date representation,
536
+ * integer width, server URL) apply to every plugin in the build.
511
537
  *
512
538
  * @example
513
539
  * ```ts
@@ -516,8 +542,13 @@ declare const adapterOasName = "oas";
516
542
  * import { pluginTs } from '@kubb/plugin-ts'
517
543
  *
518
544
  * export default defineConfig({
519
- * adapter: adapterOas({ dateType: 'date', serverIndex: 0 }),
520
- * input: { path: './openapi.yaml' },
545
+ * input: { path: './petStore.yaml' },
546
+ * output: { path: './src/gen' },
547
+ * adapter: adapterOas({
548
+ * serverIndex: 0,
549
+ * discriminator: 'inherit',
550
+ * dateType: 'date',
551
+ * }),
521
552
  * plugins: [pluginTs()],
522
553
  * })
523
554
  * ```
@@ -525,30 +556,9 @@ declare const adapterOasName = "oas";
525
556
  declare const adapterOas: (options?: AdapterOasOptions | undefined) => _$_kubb_core0.Adapter<AdapterOas>;
526
557
  //#endregion
527
558
  //#region src/factory.d.ts
528
- type ParseOptions = {
529
- canBundle?: boolean;
530
- enablePaths?: boolean;
531
- };
532
559
  type ValidateDocumentOptions = {
533
560
  throwOnError?: boolean;
534
561
  };
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
562
  /**
553
563
  * Deep-merges multiple OpenAPI documents into a single `Document`.
554
564
  *
@@ -561,32 +571,6 @@ declare function parseDocument(pathOrApi: string | Document, {
561
571
  * ```
562
572
  */
563
573
  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
574
  //#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 };
575
+ 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
576
  //# sourceMappingURL=index.d.ts.map