@kubb/adapter-oas 5.29.1 → 5.29.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.cjs CHANGED
@@ -15,7 +15,7 @@ var compatibility = {
15
15
  "node": ">=22.22"
16
16
  };
17
17
  // package.json
18
- var version = "5.29.1";
18
+ var version = "5.29.2";
19
19
  // src/constants.ts
20
20
  /**
21
21
  * Default parser options applied when no explicit options are provided.
@@ -1247,6 +1247,18 @@ function isExtensionPath(path) {
1247
1247
  return false;
1248
1248
  }
1249
1249
  /**
1250
+ * True when `node` is the value at `path` in `document`. api-ref-bundler reports the output path of a
1251
+ * failed `$ref`, so this tells a `$ref` in the input itself from one in a file it pulled in.
1252
+ */
1253
+ function isNodeAt(document, path, node) {
1254
+ let current = document;
1255
+ for (const token of path) {
1256
+ if (!current || typeof current !== "object" || !Object.hasOwn(current, token)) return false;
1257
+ current = current[token];
1258
+ }
1259
+ return current === node;
1260
+ }
1261
+ /**
1250
1262
  * Returns the base for relative `$ref`s: the 3.2 `$self` resolved against `pathOrUrl`, else `pathOrUrl`.
1251
1263
  */
1252
1264
  function getBaseUri(pathOrUrl, root) {
@@ -1290,7 +1302,7 @@ function getBaseUri(pathOrUrl, root) {
1290
1302
  */
1291
1303
  async function bundleDocument(pathOrUrl, { document, sources = [], harness, signal } = {}) {
1292
1304
  const cache = memo.create();
1293
- const toKey = (sourcePath) => urlRegExp.test(sourcePath) ? new URL(sourcePath).href : sourcePath;
1305
+ const toKey = (sourcePath) => urlRegExp.test(sourcePath) ? new URL(sourcePath).href : (0, node_path.normalize)(sourcePath);
1294
1306
  const refused = /* @__PURE__ */ new Set();
1295
1307
  const harnessRefusals = /* @__PURE__ */ new Map();
1296
1308
  const read = ({ sourcePath, isRef }) => {
@@ -1308,10 +1320,6 @@ async function bundleDocument(pathOrUrl, { document, sources = [], harness, sign
1308
1320
  throw error;
1309
1321
  });
1310
1322
  };
1311
- const refTarget = ({ value, baseFile }) => {
1312
- const ref = value?.$ref;
1313
- return typeof ref === "string" ? toKey((0, api_ref_bundler.parseRef)(ref, baseFile).filePath) : void 0;
1314
- };
1315
1323
  const refDiagnostic = ({ message, target }) => {
1316
1324
  const harnessRefusal = target === void 0 ? void 0 : harnessRefusals.get(target);
1317
1325
  if (harnessRefusal) return harnessRefusal;
@@ -1354,16 +1362,13 @@ async function bundleDocument(pathOrUrl, { document, sources = [], harness, sign
1354
1362
  }
1355
1363
  entry = getBaseUri(pathOrUrl, root);
1356
1364
  entryDocument = root;
1357
- return await (0, api_ref_bundler.bundle)(entry, resolver, { hooks: { onError: (message, { path, state, value }) => {
1365
+ return await (0, api_ref_bundler.bundle)(entry, resolver, { hooks: { onError: (message, { path, value }, detail) => {
1358
1366
  signal?.throwIfAborted();
1359
- const pointer = toKey(state.baseFile) === toKey(entry) ? `#/${path.map((token) => escapePointerToken(String(token))).join("/")}` : void 0;
1367
+ const pointer = isNodeAt(root, path, value) ? `#/${path.map((token) => escapePointerToken(String(token))).join("/")}` : void 0;
1360
1368
  const diagnostic = {
1361
1369
  ...refDiagnostic({
1362
1370
  message,
1363
- target: refTarget({
1364
- value,
1365
- baseFile: state.baseFile
1366
- })
1371
+ target: detail && toKey(detail.document)
1367
1372
  }),
1368
1373
  severity: isExtensionPath(path) ? "warning" : "error",
1369
1374
  ...pointer && { location: {