From b89928513e81cdee5575045e5f0918fc8fb7a9fa Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Tue, 20 Aug 2024 19:10:50 +0200 Subject: [PATCH] - --- bundle/schema/schema_test.go | 135 ----------------------------------- 1 file changed, 135 deletions(-) diff --git a/bundle/schema/schema_test.go b/bundle/schema/schema_test.go index 1955dce1a4..bf15002070 100644 --- a/bundle/schema/schema_test.go +++ b/bundle/schema/schema_test.go @@ -388,141 +388,6 @@ func TestSliceOfStructSchema(t *testing.T) { assert.Equal(t, expected, string(jsonSchema)) } -func TestEmbeddedStructSchema(t *testing.T) { - 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"` - } - - type Story struct { - Plot Plot `json:"plot"` - *Person - Location - } - - elem := Story{} - - schema, err := New(reflect.TypeOf(elem), nil) - assert.NoError(t, err) - - jsonSchema, err := json.MarshalIndent(schema, " ", " ") - assert.NoError(t, err) - - expected := - `{ - "type": "object", - "properties": { - "age": { - "anyOf": [ - { - "type": "number" - }, - { - "type": "string", - "pattern": "\\$\\{([a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)*(\\[[0-9]+\\])*)\\}" - } - ] - }, - "country": { - "type": "string" - }, - "home": { - "type": "object", - "properties": { - "country": { - "type": "string" - }, - "state": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "country" - ] - }, - "name": { - "type": "string" - }, - "plot": { - "type": "object", - "properties": { - "events": { - "type": "object", - "additionalProperties": { - "type": "object", - "properties": { - "age": { - "anyOf": [ - { - "type": "number" - }, - { - "type": "string", - "pattern": "\\$\\{([a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\.[a-zA-Z]+([-_]?[a-zA-Z0-9]+)*(\\[[0-9]+\\])*)*(\\[[0-9]+\\])*)\\}" - } - ] - }, - "home": { - "type": "object", - "properties": { - "country": { - "type": "string" - }, - "state": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "country" - ] - }, - "name": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "name", - "home" - ] - } - } - }, - "additionalProperties": false, - "required": [ - "events" - ] - }, - "state": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "plot", - "name", - "home", - "country" - ] - }` - - t.Log("[DEBUG] actual: ", string(jsonSchema)) - t.Log("[DEBUG] expected: ", expected) - assert.Equal(t, expected, string(jsonSchema)) -} - func TestErrorWithTrace(t *testing.T) { tracker := newTracker() dummyType := reflect.TypeOf(struct{}{})