no-closed-literal-union
@azure-tools/typespec-azure-core/no-closed-literal-unionAzure services favor extensible enums to avoid breaking changes as new enum values are added. When using a union of only string or numeric literals it is the equivalent to a closed enum.
Adding the base scalar(string, int32, int64, etc.) as a variant to the union makes it extensible.
โ Incorrect
Section titled โโ Incorrectโunion PetKind { Cat: "cat", Dog: "dog",}model Pet { kind: "cat" | "dog";}โ Correct
Section titled โโ Correctโunion PetKind { Cat: "Cat", Dog: "Dog", string,}model Pet { kind: "cat" | "dog" | string;}