Skip to content

Commit

Permalink
Merge pull request #41 from yiptsangkin/master
Browse files Browse the repository at this point in the history
Use the json tag as the swagger property key first
  • Loading branch information
andeya authored Sep 19, 2019
2 parents fbd11bf + f57ebdc commit 436c768
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ samples/demo/demo

ext/services
.DS_Store
.idea
7 changes: 6 additions & 1 deletion swagger/swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,12 @@ func CreateProperties(obj interface{}) map[string]*Property {
fv = reflect.New(ft).Elem()
}
p.Default = fv.Interface()
ps[field.Name] = p
n := field.Tag.Get("json")
if n == "" {
ps[field.Name] = p
} else {
ps[n] = p
}
}
return ps

Expand Down

0 comments on commit 436c768

Please sign in to comment.