glideapps / glideapps/quicktype
JSONSchema: "OneOf" in "Array.Items" is ignored
- Dominant language
- TypeScript
- Stars
- 13.9k
- Forks
- 1.2k
- Avg merge
- 8h 53m
- Merged PRs (30d)
- 369
Description
Given the following json-schema:
```json
{
"$id": "https://json-schema.hyperjump.io/schema",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"items": {
"oneOf": [
{"type": "object", "additionalProperties": false, "properties": { "aa": { "type": "string" }, "bb": { "type": "string" }}},
{"type": "object", "additionalProperties": false, "properties": { "cc": { "type": "string" }, "dd": { "type": "string" }}}
]
}
}
```
Quicktype generates the following incorrect types:
```ts
export interface PurpleArray {
aa?: string;
bb?: string;
cc?: string;
dd?: string;
}
```
According to the json-schema spec, this is valid:
```json
[
{"aa": "aa", "bb":"bb"},
{"cc": "cc", "dd":"dd"}
]
```
But this one is not:
```
[
{"aa": "aa", "bb":"bb"},
{"aa": "aa", "cc": "cc", "dd":"dd"}
]
```
Contributor guide
Assessment
This issue has not been assessed yet.