Skip to content

spread-discriminated-model

Full name
@azure-tools/typespec-azure-core/spread-discriminated-model

A model using @discriminator is meant to be used in a polymorphic context. It should be extended to represent the relation. Spreading this model is a sign that either the @discriminator decorator is unnecessary or that model extends should have been used instead.

@discriminator("kind")
model Pet {
kind: string;
}
model Cat {
...Pet;
meow: boolean;
}
model Pet {
kind: string;
}
model Cat {
...Pet;
meow: boolean;
}
@discriminator("kind")
model Pet {
kind: string;
}
model Cat extends Pet {
kind: "cat";
meow: boolean;
}