fluid-oas
Version:
Build declarative OpenApiv3.* specifications.
19 lines (18 loc) • 654 B
JavaScript
import { withUnionTypes } from "../common";
import { SchemaBase } from "../lib/base";
const TypeArrayBase = withUnionTypes((SchemaBase))();
class _OpenApiUnion extends TypeArrayBase {
}
/**
* A special utility schema to capture multple types into one.
*
* WARNING: If multiple schemas have the same field type, one may overwrite another.
* In addition, do not provide multiple of the same schema types, doing so will result
* in those schema types overwriting each other.
*/
export const Union = (...val) => {
if (val.length === 0) {
throw new Error("Schemas cannot be empty.");
}
return new _OpenApiUnion().ofTypes(...val);
};