(members: Array<JsonSchema7>)
| 1027 | } |
| 1028 | |
| 1029 | function compactUnion(members: Array<JsonSchema7>): Array<JsonSchema7> { |
| 1030 | const out: Array<JsonSchema7> = [] |
| 1031 | for (const m of members) { |
| 1032 | if (isNeverWithoutCustomAnnotations(m)) continue |
| 1033 | if (isAny(m) || isUnknown(m) || isVoid(m)) return [m] |
| 1034 | if (isCompactableLiteral(m) && out.length > 0) { |
| 1035 | const last = out[out.length - 1] |
| 1036 | if (isCompactableLiteral(last) && last.type === m.type) { |
| 1037 | out[out.length - 1] = { |
| 1038 | type: last.type, |
| 1039 | enum: [...last.enum, ...m.enum] |
| 1040 | } as JsonSchema7Enum |
| 1041 | continue |
| 1042 | } |
| 1043 | } |
| 1044 | out.push(m) |
| 1045 | } |
| 1046 | return out |
| 1047 | } |
no test coverage detected