@kubb/adapter-oas 5.21.0 → 5.21.1

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
@@ -1,10 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- // \0rolldown/runtime.js
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", {
5
- value,
6
- configurable: true
7
- });
2
+ const require_rolldown_runtime = require("./rolldown-runtime-BRMrT0dX.cjs");
8
3
  let _kubb_core = require("@kubb/core");
9
4
  let _kubb_kit = require("@kubb/kit");
10
5
  let node_fs_promises = require("node:fs/promises");
@@ -21,7 +16,7 @@ var compatibility = {
21
16
  "node": ">=22.22"
22
17
  };
23
18
  // package.json
24
- var version = "5.21.0";
19
+ var version = "5.21.1";
25
20
  // src/constants.ts
26
21
  /**
27
22
  * Default parser options applied when no explicit options are provided.
@@ -908,7 +903,7 @@ function parse$1(source) {
908
903
  return;
909
904
  }
910
905
  }
911
- __name(parse$1, "parse");
906
+ require_rolldown_runtime.__name(parse$1, "parse");
912
907
  function rememberEvents({ source, events }) {
913
908
  indexes.set(source, indexEvents(events));
914
909
  }
@@ -1236,6 +1231,10 @@ async function parseFromConfig(source, sources = [], { fileRefs } = {}) {
1236
1231
  fileRefs
1237
1232
  });
1238
1233
  })();
1234
+ return upgradeDocument(raw, { pathRefs: scans.get(raw)?.pathRefs ?? true });
1235
+ }
1236
+ /** Upgrades Swagger 2.0 or OpenAPI 3.0 to 3.1. `pathRefs: false` skips the `#/paths/` ref walk. */
1237
+ function upgradeDocument(raw, { pathRefs = true } = {}) {
1239
1238
  if (raw && typeof raw === "object") {
1240
1239
  const document = raw;
1241
1240
  for (const key of ["swagger", "openapi"]) {
@@ -1243,7 +1242,7 @@ async function parseFromConfig(source, sources = [], { fileRefs } = {}) {
1243
1242
  if (typeof version === "number") document[key] = Number.isInteger(version) ? version.toFixed(1) : String(version);
1244
1243
  }
1245
1244
  }
1246
- if (raw && typeof raw === "object" && "swagger" in raw && (scans.get(raw)?.pathRefs ?? true)) {
1245
+ if (raw && typeof raw === "object" && "swagger" in raw && pathRefs) {
1247
1246
  const refs = createRefs(raw);
1248
1247
  inlinePathRefs(raw, (ref) => refs.resolve(ref, { report: false }));
1249
1248
  }
@@ -1308,23 +1307,23 @@ async function validateDocument(document, { throwOnError = false } = {}) {
1308
1307
  _kubb_kit.Diagnostics.report(diagnostic);
1309
1308
  return;
1310
1309
  }
1311
- const { compileErrors, validate } = await import("@readme/openapi-parser");
1312
- let result;
1313
- try {
1314
- result = await validate(structuredClone(document), { validate: { errors: { colorize: throwOnError } } });
1315
- } catch (error) {
1316
- if (throwOnError) throw error;
1317
- reportInvalidSpec(getErrorMessage(error));
1318
- return;
1310
+ if (!throwOnError) {
1311
+ const { validateSpec } = await Promise.resolve().then(() => require("./validateSpec-DCiUXkMn.cjs"));
1312
+ return reportResult(await validateSpec(structuredClone(document)));
1319
1313
  }
1314
+ const { compileErrors, validate } = await import("@readme/openapi-parser");
1315
+ const result = await validate(structuredClone(document), { validate: { errors: { colorize: true } } });
1320
1316
  if (result.valid) return;
1321
- if (throwOnError) throw new _kubb_kit.Diagnostics.Error({
1317
+ throw new _kubb_kit.Diagnostics.Error({
1322
1318
  code: _kubb_kit.Diagnostics.code.invalidSpec,
1323
1319
  severity: "error",
1324
1320
  message: compileErrors(result),
1325
1321
  help: "Fix each problem listed in the spec, then validate again."
1326
1322
  });
1327
- reportValidationErrors(result);
1323
+ }
1324
+ function reportResult(result) {
1325
+ if ("thrown" in result) return reportInvalidSpec(result.thrown);
1326
+ if (!result.valid) reportValidationErrors(result);
1328
1327
  }
1329
1328
  function reportValidationErrors({ errors, additionalErrors }) {
1330
1329
  for (const { message } of errors) reportInvalidSpec(message.replace(/\n.*/s, ""));
@@ -1351,8 +1350,7 @@ async function validateDocumentInWorker(document) {
1351
1350
  } catch {
1352
1351
  return validateDocument(document);
1353
1352
  }
1354
- if ("thrown" in message) return reportInvalidSpec(message.thrown);
1355
- if (!message.valid) reportValidationErrors(message);
1353
+ reportResult(message);
1356
1354
  }
1357
1355
  // src/model/components.ts
1358
1356
  /**