fix required struct tag when anonymous nested struct

when use anonymous nested structures at @Param body,required stuct tag is invalid.
struct define like follow:
type StructA struct {
   Name string `json:"name" required:"true"`
}

type StructB struct {
  StructA 
}

error:
when use StructB  in @Param,required struct tag is not generated in swagger.json.
This commit is contained in:
RedBoneZhang 2021-04-28 10:26:32 +08:00 committed by GitHub
parent cbb523325d
commit 3f35efce96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 0 deletions

View File

@ -1232,6 +1232,7 @@ func parseStruct(imports []*ast.ImportSpec, st *ast.StructType, k string, m *swa
for name, p := range nm.Properties {
m.Properties[name] = p
}
m.Required = append(m.Required, nm.Required...)
continue
}
}