-
Notifications
You must be signed in to change notification settings - Fork 112
Open
Milestone
Description
With the upgrade to 0.18, I noticed that we lose information about some of our objects. To reproduce, take the simplified schema of an object that is requiring one of multiple fields (e.g. full name or individual name fields)
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/foo",
"definitions": {
"foo": {
"type": "object",
"additionalProperties": false,
"properties": {
"bar": {
"type": "string"
},
"baz": {
"type": "string"
},
"optional": {
"type": "string"
}
},
"anyOf": [
{"required": ["bar"]},
{"required": ["baz"]}
]
}
}
}
and run the generation. With the upgrade, we lose all information about the structure of the object
go run github.com/atombender/[email protected] -p "test" -o "./old.go" schema.json
go run github.com/atombender/[email protected] -p "test" -o "./new.go" schema.json
diff old.go new.go
5,14c5
< type Foo struct {
< // Bar corresponds to the JSON schema field "bar".
< Bar *string `json:"bar,omitempty" yaml:"bar,omitempty" mapstructure:"bar,omitempty"`
<
< // Baz corresponds to the JSON schema field "baz".
< Baz *string `json:"baz,omitempty" yaml:"baz,omitempty" mapstructure:"baz,omitempty"`
<
< // Optional corresponds to the JSON schema field "optional".
< Optional *string `json:"optional,omitempty" yaml:"optional,omitempty" mapstructure:"optional,omitempty"`
< }
---
> type Foo interface{}
timo102 and shellhazard
Metadata
Metadata
Assignees
Labels
No labels