protoc-gen-go-micro/openapiv3_util.go
Vasiliy Tolstov 543132594b update to micro v4
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
2023-05-04 00:22:05 +03:00

40 lines
675 B
Go

package main
import v3 "go.unistack.org/micro-proto/v4/openapiv3"
func getMediaType(eopt interface{}) string {
ctype := "application/json"
if eopt == nil {
return ctype
}
if eopt == v3.E_Openapiv3Operation.InterfaceOf(v3.E_Openapiv3Operation.Zero()) {
return ctype
}
opt, ok := eopt.(*v3.Operation)
if !ok || opt.RequestBody == nil {
return ctype
}
if opt.GetRequestBody() == nil {
return ctype
}
if opt.GetRequestBody().GetRequestBody() == nil {
return ctype
}
c := opt.GetRequestBody().GetRequestBody().GetContent()
if c == nil {
return ctype
}
for _, prop := range c.GetAdditionalProperties() {
ctype = prop.Name
}
return ctype
}