glideapps / glideapps/quicktype

allOf doesn't seem to merge to output

Open
#1,574 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
13.9k
Forks
1.2k
Avg merge
8h 53m
Merged PRs (30d)
369

Description

I have the following schema, which when run via the web tool, I only get a type with the `properties` fields defined, nothing from the `allOf`. What am I doing wrong?
```json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"product_type": {
"type": "string",
"enum": [
"x",
"y",
"z"
]
}
},
"allOf": [
{
"if": {
"properties": {
"product_type": {
"enum": [
"x",
"y"

]
}
}
},
"then": {
"properties": {
"foo": {
"type": "string"
}
}
}
},
{
"if": {
"properties": {
"product_type": {
"enum": [
"y",
"z"
]
}
}
},
"then": {
"properties": {
"bar": {
"type": "string"
}
}

}
}
]

}
```

Output from web tool:
```go
package main

type Test struct {
ID *string `json:"id,omitempty"`
ProductType *ProductType `json:"product_type,omitempty"`
}

type ProductType string
const (
X ProductType = "x"
Y ProductType = "y"
Z ProductType = "z"
)
```

I expected:
```go
package main

type Test struct {
ID *string `json:"id,omitempty"`
ProductType *ProductType `json:"product_type,omitempty"`
Foo *string ...
Bar *string...
}

type ProductType string
const (
X ProductType = "x"
Y ProductType = "y"
Z ProductType = "z"
)
```

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.