corrected add to get in getStructFields

This commit is contained in:
Shreyas Goenka 2023-01-18 17:45:53 +01:00
parent 5da5ea0c7a
commit 35c3793579
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
1 changed files with 3 additions and 3 deletions

View File

@ -165,7 +165,8 @@ func safeToSchema(golangType reflect.Type, docs *Docs, debugTraceId string, seen
//
// params:
// fields: slice to which member fields of golangType will be added to
func addStructFields(fields []reflect.StructField, golangType reflect.Type) []reflect.StructField {
func getStructFields(golangType reflect.Type) []reflect.StructField {
fields := []reflect.StructField{}
bfsQueue := list.New()
for i := 0; i < golangType.NumField(); i++ {
@ -256,8 +257,7 @@ func toSchema(golangType reflect.Type, docs *Docs, seenTypes map[reflect.Type]st
properties := map[string]*Schema{}
required := []string{}
if golangType.Kind() == reflect.Struct {
children := []reflect.StructField{}
children = addStructFields(children, golangType)
children := getStructFields(golangType)
for _, child := range children {
// get child json tags
childJsonTag := strings.Split(child.Tag.Get("json"), ",")