diff --git a/oas.go b/oas.go index 94e1d34..c59226a 100644 --- a/oas.go +++ b/oas.go @@ -144,6 +144,7 @@ type SchemaObject struct { Items *SchemaObject `json:"items,omitempty"` // use ptr to prevent recursive error Example interface{} `json:"example,omitempty"` Deprecated bool `json:"deprecated,omitempty"` + Nullable bool `json:"nullable,omitempty"` // Ref is used when SchemaObject is as a ReferenceObject Ref string `json:"$ref,omitempty"` @@ -170,7 +171,6 @@ type SchemaObject struct { // AdditionalProperties // Description // Default - // Nullable // ReadOnly // WriteOnly // XML diff --git a/parser.go b/parser.go index 402eb57..ad6ad0c 100644 --- a/parser.go +++ b/parser.go @@ -1150,6 +1150,19 @@ astFieldsLoop: fieldSchema.Deprecated = true continue astFieldsLoop } + if kv := strings.Split(v, "="); len(kv) == 2 { + switch kv[0] { + case "type": + fieldSchema.Type = kv[1] + fieldSchema.Ref = "" + + case "format": + fieldSchema.Format = kv[1] + + case "nullable": + fieldSchema.Nullable, _ = strconv.ParseBool(kv[1]) + } + } } if tag := astFieldTag.Get("json"); tag != "" {