@redpanda-data/docs-extensions-and-macros 4.15.10 → 4.16.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redpanda-data/docs-extensions-and-macros",
3
- "version": "4.15.10",
3
+ "version": "4.16.0",
4
4
  "description": "Antora extensions and macros developed for Redpanda documentation.",
5
5
  "keywords": [
6
6
  "antora",
@@ -248,6 +248,55 @@ function createEntrypoint(tempDir, apiSurface) {
248
248
  return fragmentFiles;
249
249
  }
250
250
 
251
+ /**
252
+ * Wrap $ref siblings into allOf to preserve field-level descriptions.
253
+ *
254
+ * In OpenAPI 3.0, sibling properties next to $ref are ignored per spec.
255
+ * Some renderers (e.g. Bump.sh) follow this behavior, displaying the generic
256
+ * description from the referenced schema instead of field-level overrides.
257
+ * This function transforms { $ref, description, ... } into
258
+ * { allOf: [{ $ref }], description, ... } so renderers pick up field-level
259
+ * descriptions correctly.
260
+ *
261
+ * @param {*} node - Any value from the parsed OpenAPI spec.
262
+ * @returns {*} The transformed value (mutates in place for objects).
263
+ */
264
+ function wrapRefSiblings(node) {
265
+ if (node === null || typeof node !== 'object') {
266
+ return node;
267
+ }
268
+
269
+ if (Array.isArray(node)) {
270
+ node.forEach((item, i) => {
271
+ node[i] = wrapRefSiblings(item);
272
+ });
273
+ return node;
274
+ }
275
+
276
+ // Check if this object has $ref with sibling properties that need wrapping
277
+ if (node['$ref'] && typeof node['$ref'] === 'string') {
278
+ const keys = Object.keys(node);
279
+ const hasSiblings = keys.length > 1;
280
+
281
+ if (hasSiblings) {
282
+ // Skip if allOf already exists — assumes a pre-existing structure
283
+ // from the source spec that should not be modified.
284
+ if (!node.allOf) {
285
+ const ref = node['$ref'];
286
+ delete node['$ref'];
287
+ node.allOf = [{ '$ref': ref }];
288
+ }
289
+ }
290
+ }
291
+
292
+ // Recurse into all object values
293
+ for (const key of Object.keys(node)) {
294
+ node[key] = wrapRefSiblings(node[key]);
295
+ }
296
+
297
+ return node;
298
+ }
299
+
251
300
  /**
252
301
  * Bundle one or more OpenAPI fragment files into a single bundled YAML using a selected external bundler.
253
302
  *
@@ -529,6 +578,9 @@ function postProcessBundle(filePath, options, quiet = false) {
529
578
  bundle.info['x-generated-at'] = new Date().toISOString();
530
579
  bundle.info['x-generator'] = 'redpanda-docs-openapi-bundler';
531
580
 
581
+ // Wrap $ref siblings into allOf so renderers display field descriptions
582
+ bundle = wrapRefSiblings(bundle);
583
+
532
584
  // Sort keys for deterministic output
533
585
  const sortedBundle = sortObjectKeys(bundle);
534
586
 
@@ -776,6 +828,7 @@ module.exports = {
776
828
  normalizeTag,
777
829
  getMajorMinor,
778
830
  sortObjectKeys,
831
+ wrapRefSiblings,
779
832
  detectBundler,
780
833
  createEntrypoint,
781
834
  postProcessBundle