@kubb/ast 5.3.13 → 5.3.14

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
@@ -1370,6 +1370,25 @@ function resolveRefName(node) {
1370
1370
  if (node.ref) return node.ref.split("/").at(-1) ?? node.ref;
1371
1371
  return node.name ?? node.schema?.name ?? null;
1372
1372
  }
1373
+ /**
1374
+ * Returns `true` when a schema is a bare ref without modifiers, metadata, or omit keys.
1375
+ *
1376
+ * Modifiers inherited from the resolved schema are included in the check because a ref emits the
1377
+ * referenced schema variable with those modifiers already applied.
1378
+ */
1379
+ function isBareRef(node, keysToOmit) {
1380
+ if (!node || node.type !== "ref") return false;
1381
+ const meta = (() => {
1382
+ if (!node.schema) return node;
1383
+ const { kind: _kind, type: _type, name: _name, ref: _ref, schema: _schema, ...overrides } = node;
1384
+ const definedOverrides = Object.fromEntries(Object.entries(overrides).filter(([, value]) => value !== void 0));
1385
+ return {
1386
+ ...node.schema,
1387
+ ...definedOverrides
1388
+ };
1389
+ })();
1390
+ return !meta.nullable && !meta.optional && !meta.nullish && meta.default === void 0 && !meta.description && !meta.examples?.length && !keysToOmit?.length;
1391
+ }
1373
1392
  //#endregion
1374
1393
  //#region src/utils/schemaGraph.ts
1375
1394
  /**
@@ -1731,6 +1750,7 @@ var exports_exports = /* @__PURE__ */ __exportAll({
1731
1750
  importDef: () => importDef,
1732
1751
  inferDiscriminatorPropertyName: () => inferDiscriminatorPropertyName,
1733
1752
  inputDef: () => inputDef,
1753
+ isBareRef: () => isBareRef,
1734
1754
  isHttpOperationNode: () => isHttpOperationNode,
1735
1755
  jsxDef: () => jsxDef,
1736
1756
  narrowSchema: () => narrowSchema,
@@ -1787,6 +1807,7 @@ exports.getSchemaLiteralValues = getSchemaLiteralValues;
1787
1807
  exports.importDef = importDef;
1788
1808
  exports.inferDiscriminatorPropertyName = inferDiscriminatorPropertyName;
1789
1809
  exports.inputDef = inputDef;
1810
+ exports.isBareRef = isBareRef;
1790
1811
  exports.isHttpOperationNode = isHttpOperationNode;
1791
1812
  exports.jsxDef = jsxDef;
1792
1813
  exports.narrowSchema = narrowSchema;