mirror of
https://github.com/beego/bee.git
synced 2024-10-31 18:50:54 +00:00
Skip unexported struct fields in swaggergen
Go JSON serialization only handles exported struct fields.
This commit is contained in:
parent
ebb8c0ad31
commit
06eb48f6b9
@ -37,9 +37,10 @@ import (
|
|||||||
|
|
||||||
bu "github.com/beego/bee/v2/utils"
|
bu "github.com/beego/bee/v2/utils"
|
||||||
|
|
||||||
beeLogger "github.com/beego/bee/v2/logger"
|
|
||||||
"github.com/beego/beego/v2/core/utils"
|
"github.com/beego/beego/v2/core/utils"
|
||||||
"github.com/beego/beego/v2/server/web/swagger"
|
"github.com/beego/beego/v2/server/web/swagger"
|
||||||
|
|
||||||
|
beeLogger "github.com/beego/bee/v2/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -1092,6 +1093,17 @@ func parseStruct(imports []*ast.ImportSpec, st *ast.StructType, k string, m *swa
|
|||||||
if st.Fields.List != nil {
|
if st.Fields.List != nil {
|
||||||
m.Properties = make(map[string]swagger.Propertie)
|
m.Properties = make(map[string]swagger.Propertie)
|
||||||
for _, field := range st.Fields.List {
|
for _, field := range st.Fields.List {
|
||||||
|
// skip processing if field is not exported
|
||||||
|
var exported = field.Names == nil
|
||||||
|
for _, ident := range field.Names {
|
||||||
|
if ident.IsExported() {
|
||||||
|
exported = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !exported {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
isSlice, realType, sType := typeAnalyser(field)
|
isSlice, realType, sType := typeAnalyser(field)
|
||||||
if (isSlice && isBasicType(realType)) || sType == astTypeObject {
|
if (isSlice && isBasicType(realType)) || sType == astTypeObject {
|
||||||
if len(strings.Split(realType, " ")) > 1 {
|
if len(strings.Split(realType, " ")) > 1 {
|
||||||
|
Loading…
Reference in New Issue
Block a user