microsoft / microsoft/typespec
JsonSchema shouldn't union of primitive types use multiple type instead of `anyOf`
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
```tsp
model Foo {
optional?: string | null = null;
}
```
currently produce
```yaml
$schema: https://json-schema.org/draft/2020-12/schema
$id: Foo.yaml
type: object
properties:
optional:
anyOf:
- type: string
- type: "null"
```
but shouldn't it make
```yaml
$schema: https://json-schema.org/draft/2020-12/schema
$id: Foo.yaml
type: object
properties:
optional:
type:
- string
- "null"
```
[Playground Link](https://cadlplayground.z22.web.core.windows.net/?c=aW1wb3J0ICJAdHlwZXNwZWMvanNvbi1zY2hlbWEiOwoKdXNpbmcgVHlwZVNwZWMuSnNvblPFHTsKCkDELMYOCm5hbWVzcGFjZSDGEXM7Cgptb2RlbCBGb28gewogIG9wdGlvbmFsPzogc3RyxFZ8IG51bGwgPcUHOwp9Cg%3D%3D&e=%40typespec%2Fjson-schema&options=%7B%7D)
Contributor guide
Assessment
This issue has not been assessed yet.