|
|
@@ -752,41 +752,45 @@ func (g *OpenAPIv3Generator) addPathsToDocumentV3(d *v3.Document, services []*pr
|
|
|
if extOperation == nil || extOperation == v3.E_Operation.InterfaceOf(v3.E_Operation.Zero()) {
|
|
|
continue
|
|
|
}
|
|
|
- httpOperation := proto.GetExtension(method.Desc.Options(), annotations.E_Http)
|
|
|
- if httpOperation == nil || httpOperation == annotations.E_Http.InterfaceOf(annotations.E_Http.Zero()) {
|
|
|
- continue
|
|
|
- }
|
|
|
- annotationsCount++
|
|
|
- _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()
|
|
|
+
|
|
|
+ httpOperation := proto.GetExtension(method.Desc.Options(), annotations.E_Http)
|
|
|
+ if httpOperation != nil && httpOperation != annotations.E_Http.InterfaceOf(annotations.E_Http.Zero()) {
|
|
|
+ _httpOperation := httpOperation.(*annotations.HttpRule)
|
|
|
+
|
|
|
+ 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()
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ annotationsCount++
|
|
|
+
|
|
|
if path == "" {
|
|
|
path = fmt.Sprintf("/api/%s/%s", service.Desc.FullName(), method.GoName)
|
|
|
}
|