修复content_type问题
This commit is contained in:
parent
ec0d894d36
commit
dd04ad543a
16
generate.go
16
generate.go
@ -654,20 +654,22 @@ func (g *Generate) parseBaseUriConfig(uriPrefix string, paramType reflect.Type)
|
||||
res.OutputStrict = outputStrictModel == "1" || outputStrictModel == "true"
|
||||
deprecated := metaField.Tag.Get(define.TagDeprecated)
|
||||
res.Deprecated = deprecated == "1" || deprecated == "true"
|
||||
res.ContentType = strings.Split(metaField.Tag.Get(define.TagContentType), ",")
|
||||
if len(res.ContentType) == 0 {
|
||||
requestContentType := strings.TrimSpace(metaField.Tag.Get(define.TagContentType))
|
||||
if len(requestContentType) == 0 {
|
||||
if wrapper.ArrayType(g.readMethodList).Has(res.Method) >= 0 {
|
||||
// get类请求
|
||||
res.ContentType = []string{consts.MimeTypeXWWWFormUrlencoded}
|
||||
requestContentType = consts.MimeTypeXWWWFormUrlencoded
|
||||
} else {
|
||||
res.ContentType = []string{consts.MimeTypeJson}
|
||||
requestContentType = consts.MimeTypeJson
|
||||
}
|
||||
}
|
||||
res.OutputContentType = strings.Split(metaField.Tag.Get(define.TagOutputContentType), ",")
|
||||
if len(res.OutputContentType) == 0 {
|
||||
res.ContentType = strings.Split(requestContentType, ",")
|
||||
responseContentType := strings.TrimSpace(metaField.Tag.Get(define.TagOutputContentType))
|
||||
if len(responseContentType) == 0 {
|
||||
// 未设置响应类型默认JSON数据
|
||||
res.OutputContentType = []string{consts.MimeTypeJson}
|
||||
responseContentType = consts.MimeTypeJson
|
||||
}
|
||||
res.OutputContentType = strings.Split(responseContentType, ",")
|
||||
res.Summary = ParseStructField.Summary(metaField)
|
||||
if res.Method == "" {
|
||||
return nil, errors.New("baseCfg.Method is empty")
|
||||
|
Loading…
x
Reference in New Issue
Block a user