support field comment if not defined description

swaggergen support field comment if not defined description tag
This commit is contained in:
RuanSong 2021-04-02 19:14:18 +08:00 committed by GitHub
parent cbb523325d
commit 99a25a316a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -1187,6 +1187,8 @@ func parseStruct(imports []*ast.ImportSpec, st *ast.StructType, k string, m *swa
}
if desc := stag.Get("description"); desc != "" {
mp.Description = desc
} else {
mp.Description = strings.ReplaceAll(field.Comment.Text(), "\n", "")
}
if example := stag.Get("example"); example != "" && !isObject && !isSlice {