Skip to content

Commit

Permalink
Fix property mapping regression for untagged properties (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
vearutop authored Mar 29, 2022
1 parent c720c73 commit 1a4535e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ func (r *Reflector) walkProperties(v reflect.Value, parent *Schema, rc *ReflectC
)

if rc.PropertyNameMapping != nil {
tag, tagFound = rc.PropertyNameMapping[field.Name], true
tag, tagFound = rc.PropertyNameMapping[field.Name]
} else {
tag, tagFound = field.Tag.Lookup(rc.PropertyNameTag)
}
Expand Down
6 changes: 4 additions & 2 deletions reflect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,10 @@ func TestReflector_Reflect_propertyNameMapping(t *testing.T) {
reflector := jsonschema.Reflector{}

type Test struct {
ID int `minimum:"123" default:"200"`
Name string `minLength:"10"`
ID int `minimum:"123" default:"200"`
Name string `minLength:"10"`
UntaggedUnmapped int
unexported int
}

s, err := reflector.Reflect(new(Test),
Expand Down

0 comments on commit 1a4535e

Please sign in to comment.