@kubb/adapter-oas 5.29.1 → 5.29.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
@@ -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.3";
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: {
@@ -4640,9 +4645,9 @@ function toInputMeta({ document, server, authSchemes }) {
4640
4645
  }
4641
4646
  /**
4642
4647
  * Default Kubb adapter for OpenAPI 2.0, 3.0, 3.1, and 3.2 specifications. Reads the
4643
- * spec from `input` (a file path, URL, inline content, or parsed object), validates
4644
- * it, resolves the base URL, and converts every schema and operation into the
4645
- * universal AST that every downstream plugin consumes.
4648
+ * spec from `input` (a file path, URL, inline content, or parsed object), resolves
4649
+ * the base URL, and converts every schema and operation into the universal AST that
4650
+ * every downstream plugin consumes. Set `validate: true` to also check the spec.
4646
4651
  *
4647
4652
  * Configure once on `defineConfig`. The adapter's choices (date representation,
4648
4653
  * integer width, server URL) apply to every plugin in the build.
@@ -4673,7 +4678,7 @@ const adapterOas = (0, _kubb_core.defineExtension)({
4673
4678
  compatibility,
4674
4679
  issues: "https://github.com/kubb-labs/kubb/issues"
4675
4680
  },
4676
- setup: ({ validate = true, contentType, server, discriminator = "preserve", enums = "inline", pathParamsCasing, dateType = DEFAULT_PARSER_OPTIONS.dateType, integerType = DEFAULT_PARSER_OPTIONS.integerType, unknownType = DEFAULT_PARSER_OPTIONS.unknownType, enumSuffix = DEFAULT_PARSER_OPTIONS.enumSuffix, emptySchemaType = unknownType || DEFAULT_PARSER_OPTIONS.emptySchemaType }) => ({
4681
+ setup: ({ validate = false, contentType, server, discriminator = "preserve", enums = "inline", pathParamsCasing, dateType = DEFAULT_PARSER_OPTIONS.dateType, integerType = DEFAULT_PARSER_OPTIONS.integerType, unknownType = DEFAULT_PARSER_OPTIONS.unknownType, enumSuffix = DEFAULT_PARSER_OPTIONS.enumSuffix, emptySchemaType = unknownType || DEFAULT_PARSER_OPTIONS.emptySchemaType }) => ({
4677
4682
  validate,
4678
4683
  contentType,
4679
4684
  server,