diff --git a/docparser/model.go b/docparser/model.go index 4350862..dfcbd6c 100644 --- a/docparser/model.go +++ b/docparser/model.go @@ -7,6 +7,7 @@ import ( "io/ioutil" "os" "path/filepath" + "reflect" "regexp" "strings" @@ -476,6 +477,17 @@ func (spec *openAPI) parseStructs(f *ast.File, tpe *ast.StructType) (interface{} p.Enum = j.enum } + // Only set nullable if the openapi:"nullable" tag is present + if p.Nullable != nil { + nullable := false + if fld.Tag != nil { + nullable = reflect.StructTag(fld.Tag.Value).Get("openapi") == "nullable" + } + if !nullable { + p.Nullable = nil + } + } + if p != nil { e.Properties[j.name] = p }