@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.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import "./rolldown-runtime-BowF1xt-.js";
2
2
  import { defineExtension, pascalCase } from "@kubb/core";
3
3
  import { Diagnostics, Url, ast, childName, enumPrimitive, enumPropName, macroDedupeUnion, macroDiscriminatorEnum, macroEnumName, mergeAdjacentObjectsLazy } from "@kubb/kit";
4
- import { dirname, join, resolve } from "node:path";
4
+ import { dirname, join, normalize, resolve } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { upgrade } from "@scalar/openapi-upgrader";
7
- import { bundle, parseRef } from "api-ref-bundler";
7
+ import { bundle } from "api-ref-bundler";
8
8
  import { readFile } from "node:fs";
9
9
  import { access } from "node:fs/promises";
10
10
  import { COLLECTION_STYLE, CORE_SCHEMA, EVENT_ID, SCALAR_STYLE, constructFromEvents, load, parseEvents } from "js-yaml";
@@ -14,7 +14,7 @@ var compatibility = {
14
14
  "node": ">=22.22"
15
15
  };
16
16
  // package.json
17
- var version = "5.29.1";
17
+ var version = "5.29.2";
18
18
  // src/constants.ts
19
19
  /**
20
20
  * Default parser options applied when no explicit options are provided.
@@ -1246,6 +1246,18 @@ function isExtensionPath(path) {
1246
1246
  return false;
1247
1247
  }
1248
1248
  /**
1249
+ * True when `node` is the value at `path` in `document`. api-ref-bundler reports the output path of a
1250
+ * failed `$ref`, so this tells a `$ref` in the input itself from one in a file it pulled in.
1251
+ */
1252
+ function isNodeAt(document, path, node) {
1253
+ let current = document;
1254
+ for (const token of path) {
1255
+ if (!current || typeof current !== "object" || !Object.hasOwn(current, token)) return false;
1256
+ current = current[token];
1257
+ }
1258
+ return current === node;
1259
+ }
1260
+ /**
1249
1261
  * Returns the base for relative `$ref`s: the 3.2 `$self` resolved against `pathOrUrl`, else `pathOrUrl`.
1250
1262
  */
1251
1263
  function getBaseUri(pathOrUrl, root) {
@@ -1289,7 +1301,7 @@ function getBaseUri(pathOrUrl, root) {
1289
1301
  */
1290
1302
  async function bundleDocument(pathOrUrl, { document, sources = [], harness, signal } = {}) {
1291
1303
  const cache = memo.create();
1292
- const toKey = (sourcePath) => urlRegExp.test(sourcePath) ? new URL(sourcePath).href : sourcePath;
1304
+ const toKey = (sourcePath) => urlRegExp.test(sourcePath) ? new URL(sourcePath).href : normalize(sourcePath);
1293
1305
  const refused = /* @__PURE__ */ new Set();
1294
1306
  const harnessRefusals = /* @__PURE__ */ new Map();
1295
1307
  const read = ({ sourcePath, isRef }) => {
@@ -1307,10 +1319,6 @@ async function bundleDocument(pathOrUrl, { document, sources = [], harness, sign
1307
1319
  throw error;
1308
1320
  });
1309
1321
  };
1310
- const refTarget = ({ value, baseFile }) => {
1311
- const ref = value?.$ref;
1312
- return typeof ref === "string" ? toKey(parseRef(ref, baseFile).filePath) : void 0;
1313
- };
1314
1322
  const refDiagnostic = ({ message, target }) => {
1315
1323
  const harnessRefusal = target === void 0 ? void 0 : harnessRefusals.get(target);
1316
1324
  if (harnessRefusal) return harnessRefusal;
@@ -1353,16 +1361,13 @@ async function bundleDocument(pathOrUrl, { document, sources = [], harness, sign
1353
1361
  }
1354
1362
  entry = getBaseUri(pathOrUrl, root);
1355
1363
  entryDocument = root;
1356
- return await bundle(entry, resolver, { hooks: { onError: (message, { path, state, value }) => {
1364
+ return await bundle(entry, resolver, { hooks: { onError: (message, { path, value }, detail) => {
1357
1365
  signal?.throwIfAborted();
1358
- const pointer = toKey(state.baseFile) === toKey(entry) ? `#/${path.map((token) => escapePointerToken(String(token))).join("/")}` : void 0;
1366
+ const pointer = isNodeAt(root, path, value) ? `#/${path.map((token) => escapePointerToken(String(token))).join("/")}` : void 0;
1359
1367
  const diagnostic = {
1360
1368
  ...refDiagnostic({
1361
1369
  message,
1362
- target: refTarget({
1363
- value,
1364
- baseFile: state.baseFile
1365
- })
1370
+ target: detail && toKey(detail.document)
1366
1371
  }),
1367
1372
  severity: isExtensionPath(path) ? "warning" : "error",
1368
1373
  ...pointer && { location: {