|
| 1 | +import { isPlainObject } from 'ramda-adjunct'; |
| 2 | + |
1 | 3 | import opId from '../../../helpers/op-id.js';
|
2 | 4 |
|
3 | 5 | export default function normalize(parsedSpec) {
|
@@ -78,18 +80,22 @@ export default function normalize(parsedSpec) {
|
78 | 80 | for (const inherits of inheritsList) {
|
79 | 81 | // eslint-disable-next-line no-restricted-syntax
|
80 | 82 | for (const inheritName in inherits) {
|
81 |
| - if (!operation[inheritName]) { |
| 83 | + if (!Array.isArray(operation[inheritName])) { |
82 | 84 | operation[inheritName] = inherits[inheritName];
|
83 | 85 | } else if (inheritName === 'parameters') {
|
84 | 86 | // eslint-disable-next-line no-restricted-syntax
|
85 | 87 | for (const param of inherits[inheritName]) {
|
86 |
| - const exists = operation[inheritName].some( |
87 |
| - (opParam) => |
88 |
| - (opParam.name && opParam.name === param.name) || |
89 |
| - (opParam.$ref && opParam.$ref === param.$ref) || |
90 |
| - (opParam.$$ref && opParam.$$ref === param.$$ref) || |
91 |
| - opParam === param |
92 |
| - ); |
| 88 | + const exists = operation[inheritName].some((opParam) => { |
| 89 | + if (!isPlainObject(opParam) && !isPlainObject(param)) return false; |
| 90 | + if (opParam === param) return true; |
| 91 | + |
| 92 | + return ['name', '$ref', '$$ref'].some( |
| 93 | + (key) => |
| 94 | + typeof opParam[key] === 'string' && |
| 95 | + typeof param[key] === 'string' && |
| 96 | + opParam[key] === param[key] |
| 97 | + ); |
| 98 | + }); |
93 | 99 |
|
94 | 100 | if (!exists) {
|
95 | 101 | operation[inheritName].push(param);
|
|
0 commit comments