From ab3dd7ab96225cd7843144fd9c5938d9c272d79b Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Mon, 9 Sep 2024 11:21:09 +0200 Subject: [PATCH] add comment --- libs/jsonschema/from_type.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/jsonschema/from_type.go b/libs/jsonschema/from_type.go index 7a001246..18a2b3ba 100644 --- a/libs/jsonschema/from_type.go +++ b/libs/jsonschema/from_type.go @@ -203,6 +203,10 @@ func (c *constructor) walk(typ reflect.Type) (string, error) { // This function returns all member fields of the provided type. // If the type has embedded (aka anonymous) fields, this function traverses // those in a breadth first manner +// +// BFS is important because we want the a field defined at a higher level embedded +// struct to be given preference over a field with the same name defined at a lower +// level embedded struct. For example see: TestHigherLevelEmbeddedFieldIsInSchema func getStructFields(typ reflect.Type) []reflect.StructField { fields := []reflect.StructField{} bfsQueue := list.New()