|
|
@@ -760,25 +760,32 @@ func (g *OpenAPIv3Generator) addPathsToDocumentV3(d *v3.Document, services []*pr
|
|
|
_httpOperation := httpOperation.(*annotations.HttpRule)
|
|
|
var path string
|
|
|
var httpMethod string
|
|
|
+ var bodyField string
|
|
|
switch httpRule := _httpOperation.GetPattern().(type) {
|
|
|
case *annotations.HttpRule_Post:
|
|
|
path = httpRule.Post
|
|
|
httpMethod = http2.MethodPost
|
|
|
+ bodyField = _httpOperation.GetBody()
|
|
|
case *annotations.HttpRule_Get:
|
|
|
path = httpRule.Get
|
|
|
httpMethod = http2.MethodGet
|
|
|
+ bodyField = ""
|
|
|
case *annotations.HttpRule_Delete:
|
|
|
path = httpRule.Delete
|
|
|
httpMethod = http2.MethodDelete
|
|
|
+ bodyField = ""
|
|
|
case *annotations.HttpRule_Put:
|
|
|
path = httpRule.Put
|
|
|
httpMethod = http2.MethodPut
|
|
|
+ bodyField = _httpOperation.GetBody()
|
|
|
case *annotations.HttpRule_Patch:
|
|
|
path = httpRule.Patch
|
|
|
httpMethod = http2.MethodPatch
|
|
|
+ bodyField = _httpOperation.GetBody()
|
|
|
case *annotations.HttpRule_Custom:
|
|
|
path = httpRule.Custom.Path
|
|
|
httpMethod = httpRule.Custom.Kind
|
|
|
+ bodyField = _httpOperation.GetBody()
|
|
|
}
|
|
|
if path == "" {
|
|
|
path = fmt.Sprintf("/api/%s/%s", service.Desc.FullName(), method.GoName)
|
|
|
@@ -788,10 +795,14 @@ func (g *OpenAPIv3Generator) addPathsToDocumentV3(d *v3.Document, services []*pr
|
|
|
httpMethod = http2.MethodPost
|
|
|
}
|
|
|
|
|
|
+ if bodyField == "" && (httpMethod == http2.MethodPost || httpMethod == http2.MethodPut || httpMethod == http2.MethodPatch) {
|
|
|
+ bodyField = "*"
|
|
|
+ }
|
|
|
+
|
|
|
defaultHost := proto.GetExtension(service.Desc.Options(), annotations.E_DefaultHost).(string)
|
|
|
|
|
|
op, path2 := g.buildOperationV3(
|
|
|
- d, operationID, service.GoName, comment, defaultHost, path, "*", inputMessage, outputMessage)
|
|
|
+ d, operationID, service.GoName, comment, defaultHost, path, bodyField, inputMessage, outputMessage)
|
|
|
|
|
|
// Merge any `Operation` annotations with the current
|
|
|
proto.Merge(op, extOperation.(*v3.Operation))
|