From 410ba97ebc977f60cb94eca5cfb5f77719dd2ba1 Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Wed, 18 Jan 2023 10:42:33 +0100 Subject: [PATCH] updated embedded struct schema test --- bundle/schema/schema_test.go | 44 +++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/bundle/schema/schema_test.go b/bundle/schema/schema_test.go index 3c98532e5..5acc0b77e 100644 --- a/bundle/schema/schema_test.go +++ b/bundle/schema/schema_test.go @@ -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))