Skip to content

Commit 5e5d039

Browse files
authored
DOC-13343 call allOf recursively (#852)
1 parent 064870d commit 5e5d039

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

lib/helpers/lib/each-openapi-module.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,10 @@ function child_entries(node) {
137137
format_additionalProperties(node.additionalProperties) ]]
138138
: []
139139

140-
const via_allOf = node.allOf?.flatMap(
141-
a => Object.entries(a.properties || {})) || []
140+
// allOf can be nested, so call child_entries recursively
141+
const via_allOf = (node.allOf || []).flatMap(subNode =>
142+
child_entries(subNode)
143+
)
142144

143145
return [...via_properties, ...via_additionalProperties, ...via_allOf]
144146
}

test/fixtures/toc-bootstrap.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,19 @@
7373
}
7474
},
7575
console: {
76-
76+
<a href="#logging-console-collation_buffer_size">collation_buffer_size</a>: 10,
77+
<a href="#logging-console-color_enabled">color_enabled</a>: false,
78+
<a href="#logging-console-enabled">enabled</a>: false,
79+
<a href="#logging-console-file_output">file_output</a>: "string",
80+
<a href="#logging-console-log_keys">log_keys</a>: ["CRUD,HTTP,Query"...],
81+
<a href="#logging-console-log_level">log_level</a>: "info",
82+
<a href="#logging-console-rotation">rotation</a>: {
83+
<a href="#logging-console-rotation-localtime">localtime</a>: false,
84+
<a href="#logging-console-rotation-max_age">max_age</a>: 0,
85+
<a href="#logging-console-rotation-max_size">max_size</a>: 100,
86+
<a href="#logging-console-rotation-rotated_logs_size_limit">rotated_logs_size_limit</a>: 1024,
87+
<a href="#logging-console-rotation-rotation_interval">rotation_interval</a>: "0"
88+
}
7789
},
7890
<a href="#logging-debug">debug</a>: {
7991
<a href="#logging-debug-collation_buffer_size">collation_buffer_size</a>: 1000,

test/test-each-openapi.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,21 @@ describe('child_entries', function () {
310310
['bar', {type: 'number'}]
311311
])
312312
})
313+
314+
ok('via allOf recursive', function () {
315+
assert.deepEqual(
316+
child_entries({
317+
allOf: [
318+
{properties: {'outer': {type: 'string'}}},
319+
{allOf: [{properties: {'inner': {type: 'number'}}}]}
320+
]
321+
}),
322+
[
323+
['outer', {type: 'string'}],
324+
['inner', {type: 'number'}]
325+
])
326+
})
327+
313328
})
314329

315330
// Helper function to clean up whitespace in strings for comparison
@@ -318,4 +333,4 @@ function assert_equal_no_whitespace (actual, expected) {
318333
assert.equal(
319334
cleanup_whitespace(actual),
320335
cleanup_whitespace(expected))
321-
}
336+
}

0 commit comments

Comments
 (0)