diff --git a/field_parser.go b/field_parser.go index beee28ac3..b040caafd 100644 --- a/field_parser.go +++ b/field_parser.go @@ -67,6 +67,7 @@ func (ps *tagBaseFieldParser) ShouldSkip() bool { func (ps *tagBaseFieldParser) FieldName() (string, error) { var name string + if ps.field.Tag != nil { // json:"tag,hoge" name = strings.TrimSpace(strings.Split(ps.tag.Get(jsonTag), ",")[0]) @@ -74,6 +75,12 @@ func (ps *tagBaseFieldParser) FieldName() (string, error) { if name != "" { return name, nil } + + // use "form" tag over json tag + name = strings.TrimSpace(strings.Split(ps.tag.Get(formTag), ",")[0]) + if name != "" { + return name, nil + } } if ps.field.Names == nil { diff --git a/operation.go b/operation.go index 8cadc6216..297de8e7a 100644 --- a/operation.go +++ b/operation.go @@ -372,6 +372,7 @@ func (operation *Operation) ParseParamComment(commentLine string, astFile *ast.F } const ( + formTag = "form" jsonTag = "json" bindingTag = "binding" defaultTag = "default"