Discriminator
@tsed/schema
Usage
typescript
import { Discriminator } from "@tsed/schema";
See /packages/specs/schema/src/types/domain/JsonDiscriminator.ts.
Overview
ts
class Discriminator {
propertyName: string;
base: Type<any>;
values: Map<string, Type>;
types: Map<Type, string[]>;
constructor({ base, propertyName, types, values }?: Partial<{
base: Type<any>;
propertyName: string;
values: Map<string, Type<any>>;
types: Map<Type, string[]>;
}>);
add(type: Type<string>, values: string[]): this;
getType(discriminatorValue: string): Type<any>;
getValues(type: Type): string[] | undefined;
getDefaultValue(type: Type<any>): string | undefined;
children(): Type<any>[];
}
propertyName
ts
propertyName: string;
base
ts
base: Type<any>;
values
ts
values: Map<string, Type>;
types
ts
types: Map<Type, string[]>;
add
ts
add(type: Type<string>, values: string[]): this;
getType
ts
getType(discriminatorValue: string): Type<any>;
getValues
ts
getValues(type: Type): string[] | undefined;
getDefaultValue
ts
getDefaultValue(type: Type<any>): string | undefined;
children
ts
children(): Type<any>[];