@@ -210,12 +210,13 @@ func (g *Generator) addPathsToDoc(doc *openapi3.T, services []*protogen.Service)
210210 methodOptions .Status = http .StatusOK
211211 }
212212
213- inputFullName := string (method .Input .Desc .FullName ())
214- outputFullName := string (method .Output .Desc .FullName ())
215-
216213 requestContent := openapi3.Content {
217214 contentType : & openapi3.MediaType {
218- Schema : & openapi3.SchemaRef {},
215+ Schema : & openapi3.SchemaRef {
216+ Value : & openapi3.Schema {
217+ Properties : make (openapi3.Schemas ),
218+ },
219+ },
219220 },
220221 }
221222
@@ -226,9 +227,13 @@ func (g *Generator) addPathsToDoc(doc *openapi3.T, services []*protogen.Service)
226227 }
227228
228229 if methodName != http .MethodGet {
229- if inputFullName != "google.protobuf.Empty" {
230- message := allMessages .Get (inputFullName )
230+ inputFullName := string ( method . Input . Desc . FullName ())
231+ message := allMessages .Get (inputFullName )
231232
233+ // If another type is defined such as google.protobuf.Any, for now we'll just
234+ // exit.
235+ // TODO: support `Any` type for requests 🤔
236+ if message != nil {
232237 requestSchemaRef := & openapi3.SchemaRef {
233238 Value : & openapi3.Schema {
234239 Properties : make (openapi3.Schemas ),
@@ -240,9 +245,16 @@ func (g *Generator) addPathsToDoc(doc *openapi3.T, services []*protogen.Service)
240245 return err
241246 }
242247 requestContent .Get (contentType ).Schema = requestSchemaRef
248+
249+ op .RequestBody = & openapi3.RequestBodyRef {
250+ Value : & openapi3.RequestBody {
251+ Content : requestContent ,
252+ },
253+ }
243254 }
244255 }
245256
257+ outputFullName := string (method .Output .Desc .FullName ())
246258 message := allMessages .Get (outputFullName )
247259 responseSchema := & openapi3.Schema {
248260 Properties : make (openapi3.Schemas ),
@@ -253,12 +265,6 @@ func (g *Generator) addPathsToDoc(doc *openapi3.T, services []*protogen.Service)
253265 }
254266 responseContent .Get (contentType ).Schema = responseSchema .NewRef ()
255267
256- op .RequestBody = & openapi3.RequestBodyRef {
257- Value : & openapi3.RequestBody {
258- Content : requestContent ,
259- },
260- }
261-
262268 responseCode := fmt .Sprintf ("%d" , methodOptions .Status )
263269 var responseDescription string
264270 op .Responses [responseCode ] = & openapi3.ResponseRef {
0 commit comments