feat(entities.go,parser.go): 添加了对form-data的支持
1.在swaggerOperationObject中添加Consumes参数 2.对请求的tag类型进行判断,添加对应的请求体类型。
This commit is contained in:
parent
11e374395b
commit
15afacbabe
@ -137,9 +137,9 @@ type swaggerOperationObject struct {
|
||||
RequestBody *struct {
|
||||
Content swaggerContentObject `json:"content,omitempty"`
|
||||
} `json:"requestBody,omitempty"`
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
Deprecated bool `json:"deprecated,omitempty"`
|
||||
|
||||
Tags []string `json:"tags,omitempty"`
|
||||
Deprecated bool `json:"deprecated,omitempty"`
|
||||
Consumes string `json:"consumes,omitempty"`
|
||||
Security *[]swaggerSecurityRequirementObject `json:"security,omitempty"`
|
||||
ExternalDocs *swaggerExternalDocumentationObject `json:"externalDocs,omitempty"`
|
||||
}
|
||||
|
@ -242,6 +242,14 @@ func renderServiceRoutes(service spec.Service, groups []spec.Group, paths swagge
|
||||
Required: true,
|
||||
Schema: &schema,
|
||||
}
|
||||
|
||||
for _, member := range defineStruct.Members {
|
||||
if strings.Contains(member.Tag, "form") {
|
||||
parameter.In = "formData"
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
doc := strings.Join(route.RequestType.Documents(), ",")
|
||||
doc = strings.Replace(doc, "//", "", -1)
|
||||
|
||||
@ -296,6 +304,15 @@ func renderServiceRoutes(service spec.Service, groups []spec.Group, paths swagge
|
||||
},
|
||||
}
|
||||
|
||||
if defineStruct, ok := route.RequestType.(spec.DefineStruct); ok {
|
||||
for _, member := range defineStruct.Members {
|
||||
if strings.Contains(member.Tag, "form") {
|
||||
operationObject.Consumes = "multipart/form-data"
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, v := range route.Doc {
|
||||
markerIndex := strings.Index(v, atRespDoc)
|
||||
if markerIndex >= 0 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user