From ca77773fbf453ea3017b946ffd0f8de7bc9b5a5f Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Tue, 19 Mar 2019 00:21:25 +0000 Subject: [PATCH] fix json tag parsing --- server/extractor.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/server/extractor.go b/server/extractor.go index f33348ed..0a4297e4 100644 --- a/server/extractor.go +++ b/server/extractor.go @@ -20,6 +20,10 @@ func extractValue(v reflect.Type, d int) *registry.Value { v = v.Elem() } + if len(v.Name()) == 0 { + return nil + } + arg := ®istry.Value{ Name: v.Name(), Type: v.Name(), @@ -37,6 +41,9 @@ func extractValue(v reflect.Type, d int) *registry.Value { // if we can find a json tag use it if tags := f.Tag.Get("json"); len(tags) > 0 { parts := strings.Split(tags, ",") + if parts[0] == "-" || parts[0] == "omitempty" { + continue + } val.Name = parts[0] } @@ -45,6 +52,11 @@ func extractValue(v reflect.Type, d int) *registry.Value { val.Name = v.Field(i).Name } + // still no name then continue + if len(val.Name) == 0 { + continue + } + arg.Values = append(arg.Values, val) } case reflect.Slice: