Azure / Azure/typespec-azure

[ask] Will we recommand discriminated union compared with general union?

Open
#657 1 comment 0 reactions 0 assignees View on GitHub
lib:azure-core
Dominant language
TypeScript
Stars
27
Forks
90
Avg merge
1d 22h
Merged PRs (30d)
156

Description

Say we have a following spec, the operation would have a union response, for `Foo | Bar` some emitters may not serialize them easily without a discriminator property so they may fallback to binary data.

In that case does the TypeSpec would more recommand [discriminated union](https://typespec.io/docs/standard-library/discriminated-types#implementing-unions) compared with general union?
```
model Foo {
foz: string;
}

model Bar {
baz: string;
}

op test(): Foo | Bar;
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.