diff --git a/lokerpc/schema.go b/lokerpc/schema.go index 6a80844..cc42ac2 100644 --- a/lokerpc/schema.go +++ b/lokerpc/schema.go @@ -54,6 +54,11 @@ func TypeSchema(t reflect.Type, tdefs map[reflect.Type]*NamedSchema) *jtd.Schema for i := 0; i < t.NumField(); i++ { f := t.Field(i) + + if !f.IsExported() { + continue + } + name, omit := parseTag(f.Tag.Get("json")) if name == "" { name = f.Name diff --git a/lokerpc/schema_test.go b/lokerpc/schema_test.go index 81b44df..02c5f78 100644 --- a/lokerpc/schema_test.go +++ b/lokerpc/schema_test.go @@ -24,7 +24,8 @@ func (textMarshaler) MarshalText() ([]byte, error) { func TestTypeSchema(t *testing.T) { type NamedStruct struct { - Foo string `json:"foo"` + Foo string `json:"foo"` + nope string } // Name to conflict with flag.Flag