@kubb/oas 4.27.2 → 4.27.3

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 CHANGED
@@ -45,16 +45,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
45
45
  var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
46
 
47
47
  //#endregion
48
- let oas_utils = require("oas/utils");
49
48
  let jsonpointer = require("jsonpointer");
50
49
  jsonpointer = __toESM(jsonpointer);
51
50
  let oas = require("oas");
52
51
  oas = __toESM(oas);
52
+ let oas_utils = require("oas/utils");
53
53
  let node_path = require("node:path");
54
54
  node_path = __toESM(node_path);
55
55
  let _kubb_core_transformers = require("@kubb/core/transformers");
56
56
  let _kubb_core_utils = require("@kubb/core/utils");
57
- let _redocly_openapi_core = require("@redocly/openapi-core");
57
+ let _readme_openapi_parser = require("@readme/openapi-parser");
58
58
  let oas_types = require("oas/types");
59
59
  let oas_normalize = require("oas-normalize");
60
60
  oas_normalize = __toESM(oas_normalize);
@@ -4441,16 +4441,15 @@ function getDefaultValue(schema) {
4441
4441
  }
4442
4442
  if (schema.type === "object" || schema.properties) return "{}";
4443
4443
  }
4444
- async function parse(pathOrApi, { oasClass = Oas, canBundle = true, enablePaths = true } = {}) {
4445
- if (typeof pathOrApi === "string" && canBundle) return parse((await (0, _redocly_openapi_core.bundle)({
4446
- ref: pathOrApi,
4447
- config: await (0, _redocly_openapi_core.loadConfig)(),
4448
- base: pathOrApi
4449
- })).bundle.parsed, {
4450
- oasClass,
4451
- canBundle,
4452
- enablePaths
4453
- });
4444
+ async function parse(pathOrApi, { oasClass = Oas, enablePaths = true } = {}) {
4445
+ if (typeof pathOrApi === "string" && !pathOrApi.match(/\n/) && !pathOrApi.match(/^\s*\{/) && enablePaths) try {
4446
+ return parse(await (0, _readme_openapi_parser.bundle)(pathOrApi), {
4447
+ oasClass,
4448
+ enablePaths
4449
+ });
4450
+ } catch (e) {
4451
+ console.warn(`[kubb] Failed to bundle external $refs in "${pathOrApi}": ${e.message}. Falling back to plain load.`);
4452
+ }
4454
4453
  const document = await new oas_normalize.default(pathOrApi, {
4455
4454
  enablePaths,
4456
4455
  colorizeErrors: true
@@ -4464,8 +4463,7 @@ async function parse(pathOrApi, { oasClass = Oas, canBundle = true, enablePaths
4464
4463
  async function merge(pathOrApi, { oasClass = Oas } = {}) {
4465
4464
  const instances = await Promise.all(pathOrApi.map((p) => parse(p, {
4466
4465
  oasClass,
4467
- enablePaths: false,
4468
- canBundle: false
4466
+ enablePaths: false
4469
4467
  })));
4470
4468
  if (instances.length === 0) throw new Error("No OAS instances provided for merging.");
4471
4469
  return parse(instances.reduce((acc, current) => {
@@ -4960,12 +4958,6 @@ const HttpMethods = {
4960
4958
  //#endregion
4961
4959
  exports.HttpMethods = HttpMethods;
4962
4960
  exports.Oas = Oas;
4963
- Object.defineProperty(exports, 'findSchemaDefinition', {
4964
- enumerable: true,
4965
- get: function () {
4966
- return oas_utils.findSchemaDefinition;
4967
- }
4968
- });
4969
4961
  exports.getDefaultValue = getDefaultValue;
4970
4962
  exports.isAllOptional = isAllOptional;
4971
4963
  exports.isDiscriminator = isDiscriminator;
@@ -4975,12 +4967,6 @@ exports.isOptional = isOptional;
4975
4967
  exports.isParameterObject = isParameterObject;
4976
4968
  exports.isReference = isReference;
4977
4969
  exports.isRequired = isRequired;
4978
- Object.defineProperty(exports, 'matchesMimeType', {
4979
- enumerable: true,
4980
- get: function () {
4981
- return oas_utils.matchesMimeType;
4982
- }
4983
- });
4984
4970
  exports.merge = merge;
4985
4971
  exports.parse = parse;
4986
4972
  exports.parseFromConfig = parseFromConfig;