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