You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am generating zod schemas based on types generated by swagger-typescript-api. The schema generation doesn't work well with generics so I was wondering if it would be possible to have an alternative way of generating types with discriminators?
Today, this is the syntax it seems:
export type Value = BaseValue &
(
| BaseValueTypeMapping<"Type1", Value1>
| BaseValueTypeMapping<"Type2", Value2>
| BaseValueTypeMapping<"Type3", Value3>;
export type Value1 = BaseValue;
export type Value2 = BaseValue ;
export type Value3 = BaseValue ;
interface BaseValue {
$type: string;
value: number;
}
type BaseValueTypeMapping<Key, Type> = {
$type: Key;
} & Type;
It would be nice if it was possible to just generate the types with discriminators like so:
I am generating zod schemas based on types generated by swagger-typescript-api. The schema generation doesn't work well with generics so I was wondering if it would be possible to have an alternative way of generating types with discriminators?
Today, this is the syntax it seems:
It would be nice if it was possible to just generate the types with discriminators like so:
Is this possible?
Thanks
The text was updated successfully, but these errors were encountered: