updated embedded struct schema test

This commit is contained in:
Shreyas Goenka 2023-01-18 10:42:33 +01:00
parent 8a8f93e150
commit 410ba97ebc
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
1 changed files with 36 additions and 8 deletions

View File

@ -508,16 +508,17 @@ func TestSliceOfStructSchema(t *testing.T) {
}
func TestEmbeddedStructSchema(t *testing.T) {
type Person struct {
Name string `json:"name"`
Age int `json:"age,omitempty"`
}
type Location struct {
Country string `json:"country"`
State string `json:"state,omitempty"`
}
type Person struct {
Name string `json:"name"`
Age int `json:"age,omitempty"`
Home Location `json:"home"`
}
type Plot struct {
Events map[string]Person `json:"events"`
}
@ -546,6 +547,18 @@ func TestEmbeddedStructSchema(t *testing.T) {
"country": {
"type": "string"
},
"home": {
"type": "object",
"properties": {
"country": {
"type": "string"
},
"state": {
"type": "string"
}
},
"additionalProperties": false
},
"name": {
"type": "string"
},
@ -560,18 +573,33 @@ func TestEmbeddedStructSchema(t *testing.T) {
"age": {
"type": "number"
},
"home": {
"type": "object",
"properties": {
"country": {
"type": "string"
},
"state": {
"type": "string"
}
},
"additionalProperties": false
},
"name": {
"type": "string"
}
}
},
"additionalProperties": false
}
}
}
},
"additionalProperties": false
},
"state": {
"type": "string"
}
}
},
"additionalProperties": false
}`
t.Log("[DEBUG] actual: ", string(jsonSchema))