@@ -279,6 +279,8 @@ func (r *Reflector) setupRequest(o *Operation, oc openapi.OperationContext) erro
279279 ); err != nil {
280280 return err
281281 }
282+
283+ r .parseRawRequestBody (o , cu )
282284 case mimeJSON :
283285 if err := joinErrors (
284286 r .parseParameters (o , oc , cu ),
@@ -314,6 +316,7 @@ const (
314316 tagFormData = "formData"
315317 tagForm = "form"
316318 tagHeader = "header"
319+ tagContentType = "contentType"
317320 mimeJSON = "application/json"
318321 mimeFormUrlencoded = "application/x-www-form-urlencoded"
319322 mimeMultipart = "multipart/form-data"
@@ -346,6 +349,16 @@ func (r *Reflector) stringRequestBody(
346349 o .RequestBodyEns ().RequestBodyEns ().WithContentItem (mime , mediaType (format ))
347350}
348351
352+ func (r * Reflector ) parseRawRequestBody (o * Operation , cu openapi.ContentUnit ) {
353+ if cu .Structure == nil {
354+ return
355+ }
356+
357+ refl .WalkTaggedFields (reflect .ValueOf (cu .Structure ), func (_ reflect.Value , _ reflect.StructField , tag string ) {
358+ r .stringRequestBody (o , tag , "" )
359+ }, tagContentType )
360+ }
361+
349362func (r * Reflector ) parseRequestBody (
350363 o * Operation ,
351364 oc openapi.OperationContext ,
@@ -617,6 +630,16 @@ func (r *Reflector) parseResponseHeader(resp *Response, oc openapi.OperationCont
617630 return nil
618631}
619632
633+ func (r * Reflector ) parseRawResponseBody (resp * Response , cu openapi.ContentUnit ) {
634+ if cu .Structure == nil {
635+ return
636+ }
637+
638+ refl .WalkTaggedFields (reflect .ValueOf (cu .Structure ), func (_ reflect.Value , _ reflect.StructField , tag string ) {
639+ r .ensureResponseContentType (resp , tag , "" )
640+ }, tagContentType )
641+ }
642+
620643func (r * Reflector ) setupResponse (o * Operation , oc openapi.OperationContext ) error {
621644 for _ , cu := range oc .Response () {
622645 if cu .HTTPStatus == 0 && ! cu .IsDefault {
@@ -654,6 +677,8 @@ func (r *Reflector) setupResponse(o *Operation, oc openapi.OperationContext) err
654677 return err
655678 }
656679
680+ r .parseRawResponseBody (resp , cu )
681+
657682 if cu .ContentType != "" {
658683 r .ensureResponseContentType (resp , cu .ContentType , cu .Format )
659684 }
0 commit comments