Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/specmap/lib/all-of.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default {
// Remove the `allOf` property so it doesn't get added to the result of the `allOf` plugin
let originalDefinitionObj = patch.value
parent.forEach((part) => {
if (!originalDefinitionObj) return // bail out if we've lost sight of our target
originalDefinitionObj = originalDefinitionObj[part]
})
originalDefinitionObj = Object.assign({}, originalDefinitionObj)
Expand Down
62 changes: 62 additions & 0 deletions test/specmap/all-of.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,68 @@ describe('allOf', function () {
})
})

it('should suppport nested allOfs with $refs', function () {
return mapSpec({
plugins: [plugins.refs, plugins.allOf],
spec: {
definitions: {
Alpha: {
allOf: [{type: 'object'}],
properties: {
one: {
$ref: '#/definitions/Bravo'
},
two: {
type: 'string'
}
}
},
Bravo: {
allOf: [{
type: 'object',
properties: {
three: {
type: 'string'
}
}
}]
}
}
}
}).then((res) => {
// To show the error, unfortunately, the expect call doesn't pretty print it nicely
// console.log(res.errors[0])
expect(res.errors).toEqual([])
expect(res.spec).toEqual({
definitions: {
Alpha: {
type: 'object',
properties: {
one: {
type: 'object',
properties: {
three: {
type: 'string',
}
}
},
two: {
type: 'string'
}
}
},
Bravo: {
type: 'object',
properties: {
three: {
type: 'string'
}
}
}
},
})
})
})
it('merges arrays inside of an `allOf`', function () {
return mapSpec({
plugins: [plugins.refs, plugins.allOf],
Expand Down