@kubb/adapter-oas 5.0.0-beta.50 → 5.0.0-beta.52
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 +11 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -28
- package/dist/index.js +11 -25
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/factory.ts +6 -14
- package/src/index.ts +0 -3
- package/src/resolvers.ts +1 -1
- package/src/types.ts +1 -20
package/dist/index.d.ts
CHANGED
|
@@ -378,16 +378,6 @@ type SchemaObject$1 = SchemaObject$2 & {
|
|
|
378
378
|
*/
|
|
379
379
|
enum?: Array<string | number | boolean | null>;
|
|
380
380
|
};
|
|
381
|
-
/**
|
|
382
|
-
* Maps uppercase HTTP method names to lowercase for backwards compatibility.
|
|
383
|
-
*
|
|
384
|
-
* @example
|
|
385
|
-
* ```ts
|
|
386
|
-
* HttpMethods['GET'] // 'get'
|
|
387
|
-
* HttpMethods['POST'] // 'post'
|
|
388
|
-
* ```
|
|
389
|
-
*/
|
|
390
|
-
declare const HttpMethods$1: Record<Uppercase<ast.HttpMethod>, Lowercase<ast.HttpMethod>>;
|
|
391
381
|
/**
|
|
392
382
|
* HTTP method as a lowercase string (`'get' | 'post' | ...`).
|
|
393
383
|
*/
|
|
@@ -554,22 +544,5 @@ declare const adapterOasName = "oas";
|
|
|
554
544
|
*/
|
|
555
545
|
declare const adapterOas: (options?: AdapterOasOptions | undefined) => import("@kubb/core").Adapter<AdapterOas>;
|
|
556
546
|
//#endregion
|
|
557
|
-
|
|
558
|
-
type ValidateDocumentOptions = {
|
|
559
|
-
throwOnError?: boolean;
|
|
560
|
-
};
|
|
561
|
-
/**
|
|
562
|
-
* Deep-merges multiple OpenAPI documents into a single `Document`.
|
|
563
|
-
*
|
|
564
|
-
* Each document is parsed independently then recursively merged via `mergeDeep` from `@internals/utils`.
|
|
565
|
-
* Throws when the input array is empty.
|
|
566
|
-
*
|
|
567
|
-
* @example
|
|
568
|
-
* ```ts
|
|
569
|
-
* const document = await mergeDocuments(['./pets.yaml', './orders.yaml'])
|
|
570
|
-
* ```
|
|
571
|
-
*/
|
|
572
|
-
declare function mergeDocuments(pathOrApi: Array<string | Document>): Promise<Document>;
|
|
573
|
-
//#endregion
|
|
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 };
|
|
547
|
+
export { type AdapterOas, type AdapterOasOptions, type AdapterOasResolvedOptions, type ContentType, type DiscriminatorObject$1 as DiscriminatorObject, type Document, type HttpMethod, type MediaTypeObject$1 as MediaTypeObject, type Operation, type ReferenceObject$1 as ReferenceObject, type ResponseObject$1 as ResponseObject, type SchemaObject$1 as SchemaObject, adapterOas, adapterOasName };
|
|
575
548
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -3,9 +3,7 @@ import { Diagnostics, ast, createAdapter } from "@kubb/core";
|
|
|
3
3
|
import BaseOas from "oas";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { access } from "node:fs/promises";
|
|
6
|
-
import { bundle, loadConfig } from "@redocly/openapi-core";
|
|
7
6
|
import OASNormalize from "oas-normalize";
|
|
8
|
-
import swagger2openapi from "swagger2openapi";
|
|
9
7
|
import { childName, enumPropName, extractRefName, findDiscriminator } from "@kubb/ast/utils";
|
|
10
8
|
import { isRef } from "oas/types";
|
|
11
9
|
import { matchesMimeType } from "oas/utils";
|
|
@@ -606,8 +604,8 @@ function isDiscriminator(obj) {
|
|
|
606
604
|
* Loads and dereferences an OpenAPI document, returning the raw `Document`.
|
|
607
605
|
*
|
|
608
606
|
* Accepts a file path string or an already-parsed document object. File paths are bundled via
|
|
609
|
-
*
|
|
610
|
-
* to OpenAPI 3.0 via `swagger2openapi`.
|
|
607
|
+
* `@apidevtools/json-schema-ref-parser` to resolve external `$ref`s. Swagger 2.0 documents are
|
|
608
|
+
* automatically up-converted to OpenAPI 3.0 via `swagger2openapi`.
|
|
611
609
|
*
|
|
612
610
|
* @example
|
|
613
611
|
* ```ts
|
|
@@ -616,19 +614,19 @@ function isDiscriminator(obj) {
|
|
|
616
614
|
* ```
|
|
617
615
|
*/
|
|
618
616
|
async function parseDocument(pathOrApi, { canBundle = true, enablePaths = true } = {}) {
|
|
619
|
-
if (typeof pathOrApi === "string" && canBundle)
|
|
620
|
-
ref
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
});
|
|
617
|
+
if (typeof pathOrApi === "string" && canBundle) {
|
|
618
|
+
const { $RefParser } = await import("@apidevtools/json-schema-ref-parser");
|
|
619
|
+
return parseDocument(await $RefParser.bundle(pathOrApi), {
|
|
620
|
+
canBundle: false,
|
|
621
|
+
enablePaths
|
|
622
|
+
});
|
|
623
|
+
}
|
|
627
624
|
const document = await new OASNormalize(pathOrApi, {
|
|
628
625
|
enablePaths,
|
|
629
626
|
colorizeErrors: true
|
|
630
627
|
}).load();
|
|
631
628
|
if (isOpenApiV2Document(document)) {
|
|
629
|
+
const { default: swagger2openapi } = await import("swagger2openapi");
|
|
632
630
|
const { openapi } = await swagger2openapi.convertObj(document, { anchors: true });
|
|
633
631
|
return openapi;
|
|
634
632
|
}
|
|
@@ -2587,18 +2585,6 @@ const adapterOas = createAdapter((options) => {
|
|
|
2587
2585
|
};
|
|
2588
2586
|
});
|
|
2589
2587
|
//#endregion
|
|
2590
|
-
|
|
2591
|
-
/**
|
|
2592
|
-
* Maps uppercase HTTP method names to lowercase for backwards compatibility.
|
|
2593
|
-
*
|
|
2594
|
-
* @example
|
|
2595
|
-
* ```ts
|
|
2596
|
-
* HttpMethods['GET'] // 'get'
|
|
2597
|
-
* HttpMethods['POST'] // 'post'
|
|
2598
|
-
* ```
|
|
2599
|
-
*/
|
|
2600
|
-
const HttpMethods = Object.fromEntries(Object.entries(ast.httpMethods).map(([lower, upper]) => [upper, lower]));
|
|
2601
|
-
//#endregion
|
|
2602
|
-
export { HttpMethods, adapterOas, adapterOasName, mergeDocuments };
|
|
2588
|
+
export { adapterOas, adapterOasName };
|
|
2603
2589
|
|
|
2604
2590
|
//# sourceMappingURL=index.js.map
|