@kubb/adapter-oas 5.21.0 → 5.21.2

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.js CHANGED
@@ -1,3 +1,4 @@
1
+ import "./rolldown-runtime-BowF1xt-.js";
1
2
  import { defineExtension } from "@kubb/core";
2
3
  import { Diagnostics, Url, ast, childName, enumPrimitive, enumPropName, macroDedupeUnion, macroDiscriminatorEnum, macroEnumName, mergeAdjacentObjectsLazy } from "@kubb/kit";
3
4
  import { access, realpath } from "node:fs/promises";
@@ -14,7 +15,7 @@ var compatibility = {
14
15
  "node": ">=22.22"
15
16
  };
16
17
  // package.json
17
- var version = "5.21.0";
18
+ var version = "5.21.2";
18
19
  // src/constants.ts
19
20
  /**
20
21
  * Default parser options applied when no explicit options are provided.
@@ -1228,6 +1229,10 @@ async function parseFromConfig(source, sources = [], { fileRefs } = {}) {
1228
1229
  fileRefs
1229
1230
  });
1230
1231
  })();
1232
+ return upgradeDocument(raw, { pathRefs: scans.get(raw)?.pathRefs ?? true });
1233
+ }
1234
+ /** Upgrades Swagger 2.0 or OpenAPI 3.0 to 3.1. `pathRefs: false` skips the `#/paths/` ref walk. */
1235
+ function upgradeDocument(raw, { pathRefs = true } = {}) {
1231
1236
  if (raw && typeof raw === "object") {
1232
1237
  const document = raw;
1233
1238
  for (const key of ["swagger", "openapi"]) {
@@ -1235,7 +1240,7 @@ async function parseFromConfig(source, sources = [], { fileRefs } = {}) {
1235
1240
  if (typeof version === "number") document[key] = Number.isInteger(version) ? version.toFixed(1) : String(version);
1236
1241
  }
1237
1242
  }
1238
- if (raw && typeof raw === "object" && "swagger" in raw && (scans.get(raw)?.pathRefs ?? true)) {
1243
+ if (raw && typeof raw === "object" && "swagger" in raw && pathRefs) {
1239
1244
  const refs = createRefs(raw);
1240
1245
  inlinePathRefs(raw, (ref) => refs.resolve(ref, { report: false }));
1241
1246
  }
@@ -1300,23 +1305,23 @@ async function validateDocument(document, { throwOnError = false } = {}) {
1300
1305
  Diagnostics.report(diagnostic);
1301
1306
  return;
1302
1307
  }
1303
- const { compileErrors, validate } = await import("@readme/openapi-parser");
1304
- let result;
1305
- try {
1306
- result = await validate(structuredClone(document), { validate: { errors: { colorize: throwOnError } } });
1307
- } catch (error) {
1308
- if (throwOnError) throw error;
1309
- reportInvalidSpec(getErrorMessage(error));
1310
- return;
1308
+ if (!throwOnError) {
1309
+ const { validateSpec } = await import("./validateSpec-9zbtcjcA.js");
1310
+ return reportResult(await validateSpec(structuredClone(document)));
1311
1311
  }
1312
+ const { compileErrors, validate } = await import("@readme/openapi-parser");
1313
+ const result = await validate(structuredClone(document), { validate: { errors: { colorize: true } } });
1312
1314
  if (result.valid) return;
1313
- if (throwOnError) throw new Diagnostics.Error({
1315
+ throw new Diagnostics.Error({
1314
1316
  code: Diagnostics.code.invalidSpec,
1315
1317
  severity: "error",
1316
1318
  message: compileErrors(result),
1317
1319
  help: "Fix each problem listed in the spec, then validate again."
1318
1320
  });
1319
- reportValidationErrors(result);
1321
+ }
1322
+ function reportResult(result) {
1323
+ if ("thrown" in result) return reportInvalidSpec(result.thrown);
1324
+ if (!result.valid) reportValidationErrors(result);
1320
1325
  }
1321
1326
  function reportValidationErrors({ errors, additionalErrors }) {
1322
1327
  for (const { message } of errors) reportInvalidSpec(message.replace(/\n.*/s, ""));
@@ -1343,8 +1348,7 @@ async function validateDocumentInWorker(document) {
1343
1348
  } catch {
1344
1349
  return validateDocument(document);
1345
1350
  }
1346
- if ("thrown" in message) return reportInvalidSpec(message.thrown);
1347
- if (!message.valid) reportValidationErrors(message);
1351
+ reportResult(message);
1348
1352
  }
1349
1353
  // src/model/components.ts
1350
1354
  /**