@kubb/adapter-oas 5.0.0-beta.63 → 5.0.0-beta.64
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.cjs +50 -81
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +51 -82
- package/dist/index.js.map +1 -1
- package/package.json +4 -6
- package/src/adapter.bench.ts +0 -60
- package/src/adapter.ts +0 -207
- package/src/bundler.ts +0 -71
- package/src/constants.ts +0 -135
- package/src/dedupe.ts +0 -237
- package/src/dialect.ts +0 -42
- package/src/discriminator.ts +0 -132
- package/src/factory.ts +0 -180
- package/src/guards.ts +0 -68
- package/src/index.ts +0 -15
- package/src/mime.ts +0 -21
- package/src/operation.ts +0 -194
- package/src/parser.ts +0 -1129
- package/src/refs.ts +0 -86
- package/src/resolvers.ts +0 -590
- package/src/schemaDiagnostics.ts +0 -76
- package/src/stream.ts +0 -221
- package/src/types.ts +0 -235
- /package/dist/{chunk-C0LytTxp.js → rolldown-runtime-C0LytTxp.js} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -26,6 +26,7 @@ let node_path = require("node:path");
|
|
|
26
26
|
node_path = __toESM(node_path, 1);
|
|
27
27
|
let node_fs_promises = require("node:fs/promises");
|
|
28
28
|
let _readme_openapi_parser = require("@readme/openapi-parser");
|
|
29
|
+
let _scalar_openapi_upgrader = require("@scalar/openapi-upgrader");
|
|
29
30
|
let yaml = require("yaml");
|
|
30
31
|
let api_ref_bundler = require("api-ref-bundler");
|
|
31
32
|
let _kubb_ast_macros = require("@kubb/ast/macros");
|
|
@@ -317,19 +318,6 @@ async function read(path) {
|
|
|
317
318
|
//#endregion
|
|
318
319
|
//#region ../../internals/utils/src/object.ts
|
|
319
320
|
/**
|
|
320
|
-
* Returns `true` when `value` is a plain (non-null, non-array) object.
|
|
321
|
-
*
|
|
322
|
-
* @example
|
|
323
|
-
* ```ts
|
|
324
|
-
* isPlainObject({}) // true
|
|
325
|
-
* isPlainObject([]) // false
|
|
326
|
-
* isPlainObject(null) // false
|
|
327
|
-
* ```
|
|
328
|
-
*/
|
|
329
|
-
function isPlainObject(value) {
|
|
330
|
-
return typeof value === "object" && value !== null && Object.getPrototypeOf(value) === Object.prototype;
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
321
|
* Recursively merges `source` into `target`, combining nested plain objects.
|
|
334
322
|
* Arrays and non-object values from `source` override the corresponding values in `target`.
|
|
335
323
|
*
|
|
@@ -596,66 +584,6 @@ async function bundleDocument(pathOrUrl) {
|
|
|
596
584
|
return await (0, api_ref_bundler.bundle)(pathOrUrl, resolver);
|
|
597
585
|
}
|
|
598
586
|
//#endregion
|
|
599
|
-
//#region src/guards.ts
|
|
600
|
-
/**
|
|
601
|
-
* Returns `true` when `doc` is a Swagger 2.0 document (no `openapi` key).
|
|
602
|
-
*
|
|
603
|
-
* @example
|
|
604
|
-
* ```ts
|
|
605
|
-
* if (isOpenApiV2Document(doc)) {
|
|
606
|
-
* // doc is OpenAPIV2.Document
|
|
607
|
-
* }
|
|
608
|
-
* ```
|
|
609
|
-
*/
|
|
610
|
-
function isOpenApiV2Document(doc) {
|
|
611
|
-
return !!doc && isPlainObject(doc) && !("openapi" in doc);
|
|
612
|
-
}
|
|
613
|
-
/**
|
|
614
|
-
* Returns `true` when a schema should be treated as nullable.
|
|
615
|
-
*
|
|
616
|
-
* Recognizes all nullable signals across OAS versions: `nullable: true` (OAS 3.0),
|
|
617
|
-
* `x-nullable: true` (vendor extension), `type: 'null'`, and `type: ['null', ...]` (OAS 3.1).
|
|
618
|
-
*
|
|
619
|
-
* @example
|
|
620
|
-
* ```ts
|
|
621
|
-
* isNullable({ type: 'string', nullable: true }) // true
|
|
622
|
-
* isNullable({ type: ['string', 'null'] }) // true
|
|
623
|
-
* isNullable({ type: 'string' }) // false
|
|
624
|
-
* ```
|
|
625
|
-
*/
|
|
626
|
-
function isNullable(schema) {
|
|
627
|
-
if ((schema?.nullable ?? schema?.["x-nullable"]) === true) return true;
|
|
628
|
-
const schemaType = schema?.type;
|
|
629
|
-
if (schemaType === "null") return true;
|
|
630
|
-
if (Array.isArray(schemaType)) return schemaType.includes("null");
|
|
631
|
-
return false;
|
|
632
|
-
}
|
|
633
|
-
/**
|
|
634
|
-
* Returns `true` when `obj` is an OpenAPI `$ref` pointer object.
|
|
635
|
-
*
|
|
636
|
-
* @example
|
|
637
|
-
* ```ts
|
|
638
|
-
* isReference({ $ref: '#/components/schemas/Pet' }) // true
|
|
639
|
-
* isReference({ type: 'string' }) // false
|
|
640
|
-
* ```
|
|
641
|
-
*/
|
|
642
|
-
function isReference(obj) {
|
|
643
|
-
return !!obj && typeof obj === "object" && "$ref" in obj;
|
|
644
|
-
}
|
|
645
|
-
/**
|
|
646
|
-
* Returns `true` when `obj` is a schema with a structured OAS 3.x `discriminator` object.
|
|
647
|
-
*
|
|
648
|
-
* @example
|
|
649
|
-
* ```ts
|
|
650
|
-
* isDiscriminator({ discriminator: { propertyName: 'type', mapping: {} } }) // true
|
|
651
|
-
* isDiscriminator({ discriminator: 'type' }) // false (Swagger 2 string form)
|
|
652
|
-
* ```
|
|
653
|
-
*/
|
|
654
|
-
function isDiscriminator(obj) {
|
|
655
|
-
const record = obj;
|
|
656
|
-
return !!obj && !!record["discriminator"] && typeof record["discriminator"] !== "string";
|
|
657
|
-
}
|
|
658
|
-
//#endregion
|
|
659
587
|
//#region src/factory.ts
|
|
660
588
|
/**
|
|
661
589
|
* Loads and bundles an OpenAPI document, returning the raw `Document`.
|
|
@@ -663,7 +591,7 @@ function isDiscriminator(obj) {
|
|
|
663
591
|
* Accepts a file path string or an already-parsed document object. File paths and URLs are
|
|
664
592
|
* bundled via `api-ref-bundler`, hoisting external file schemas into named `components.schemas`
|
|
665
593
|
* entries so generators can emit named types and imports. Swagger 2.0 documents are
|
|
666
|
-
* automatically up-converted to OpenAPI 3.0 via
|
|
594
|
+
* automatically up-converted to OpenAPI 3.0 via `@scalar/openapi-upgrader`.
|
|
667
595
|
*
|
|
668
596
|
* @example
|
|
669
597
|
* ```ts
|
|
@@ -673,13 +601,7 @@ function isDiscriminator(obj) {
|
|
|
673
601
|
*/
|
|
674
602
|
async function parseDocument(pathOrApi, { canBundle = true } = {}) {
|
|
675
603
|
if (typeof pathOrApi === "string" && canBundle) return parseDocument(await bundleDocument(pathOrApi), { canBundle: false });
|
|
676
|
-
|
|
677
|
-
if (isOpenApiV2Document(document)) {
|
|
678
|
-
const { default: swagger2openapi } = await import("swagger2openapi");
|
|
679
|
-
const { openapi } = await swagger2openapi.convertObj(document, { anchors: true });
|
|
680
|
-
return openapi;
|
|
681
|
-
}
|
|
682
|
-
return document;
|
|
604
|
+
return (0, _scalar_openapi_upgrader.upgrade)(typeof pathOrApi === "string" ? (0, yaml.parse)(pathOrApi) : pathOrApi, "3.0");
|
|
683
605
|
}
|
|
684
606
|
/**
|
|
685
607
|
* Deep-merges multiple OpenAPI documents into a single `Document`.
|
|
@@ -931,6 +853,53 @@ function plan(roots, context) {
|
|
|
931
853
|
};
|
|
932
854
|
}
|
|
933
855
|
//#endregion
|
|
856
|
+
//#region src/guards.ts
|
|
857
|
+
/**
|
|
858
|
+
* Returns `true` when a schema should be treated as nullable.
|
|
859
|
+
*
|
|
860
|
+
* Recognizes all nullable signals across OAS versions: `nullable: true` (OAS 3.0),
|
|
861
|
+
* `x-nullable: true` (vendor extension), `type: 'null'`, and `type: ['null', ...]` (OAS 3.1).
|
|
862
|
+
*
|
|
863
|
+
* @example
|
|
864
|
+
* ```ts
|
|
865
|
+
* isNullable({ type: 'string', nullable: true }) // true
|
|
866
|
+
* isNullable({ type: ['string', 'null'] }) // true
|
|
867
|
+
* isNullable({ type: 'string' }) // false
|
|
868
|
+
* ```
|
|
869
|
+
*/
|
|
870
|
+
function isNullable(schema) {
|
|
871
|
+
if ((schema?.nullable ?? schema?.["x-nullable"]) === true) return true;
|
|
872
|
+
const schemaType = schema?.type;
|
|
873
|
+
if (schemaType === "null") return true;
|
|
874
|
+
if (Array.isArray(schemaType)) return schemaType.includes("null");
|
|
875
|
+
return false;
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* Returns `true` when `obj` is an OpenAPI `$ref` pointer object.
|
|
879
|
+
*
|
|
880
|
+
* @example
|
|
881
|
+
* ```ts
|
|
882
|
+
* isReference({ $ref: '#/components/schemas/Pet' }) // true
|
|
883
|
+
* isReference({ type: 'string' }) // false
|
|
884
|
+
* ```
|
|
885
|
+
*/
|
|
886
|
+
function isReference(obj) {
|
|
887
|
+
return !!obj && typeof obj === "object" && "$ref" in obj;
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* Returns `true` when `obj` is a schema with a structured OAS 3.x `discriminator` object.
|
|
891
|
+
*
|
|
892
|
+
* @example
|
|
893
|
+
* ```ts
|
|
894
|
+
* isDiscriminator({ discriminator: { propertyName: 'type', mapping: {} } }) // true
|
|
895
|
+
* isDiscriminator({ discriminator: 'type' }) // false (Swagger 2 string form)
|
|
896
|
+
* ```
|
|
897
|
+
*/
|
|
898
|
+
function isDiscriminator(obj) {
|
|
899
|
+
const record = obj;
|
|
900
|
+
return !!obj && !!record["discriminator"] && typeof record["discriminator"] !== "string";
|
|
901
|
+
}
|
|
902
|
+
//#endregion
|
|
934
903
|
//#region src/refs.ts
|
|
935
904
|
const _refCache = /* @__PURE__ */ new WeakMap();
|
|
936
905
|
/**
|