spread-discriminated-model
@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.
โ Incorrect
Section titled โโ Incorrectโ@discriminator("kind")model Pet { kind: string;}
model Cat { ...Pet; meow: boolean;}
โ Correct
Section titled โโ Correctโmodel Pet { kind: string;}
model Cat { ...Pet; meow: boolean;}
@discriminator("kind")model Pet { kind: string;}
model Cat extends Pet { kind: "cat"; meow: boolean;}