microsoft / microsoft/typespec
Should `|` in a union declaration be equivalent to a `,`
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
Seen a few people mistakely use `|` in a union declaration cause it actually create a nested union expression inside
```tsp
union Foo {
string,
int32 | int8,
}
```
```yaml
Foo:
anyOf:
- type: string
- anyOf:
- type: integer
format: int32
- type: integer
format: int8
```
[Playground Link](https://typespec.io/playground/?c=dW5pb24gRm9vIHsKICBzdHJpbmcsCiAgaW50MzIgfMQIOCwKfQo%3D&e=%40typespec%2Fopenapi3&options=%7B%7D)
Feels like is highly likely this is a user error and allowing that would allow the formatter to fix it. If someone really wants to do that they could force wrap it with `()`
```tsp
union Foo {
string,
(int32 | int8),
}
```
Contributor guide
Assessment
This issue has not been assessed yet.