diff --git a/protocol/goai/goai.go b/protocol/goai/goai.go index bcf130100..f4232676b 100644 --- a/protocol/goai/goai.go +++ b/protocol/goai/goai.go @@ -80,6 +80,7 @@ const ( TagNamePath = `path` TagNameMethod = `method` TagNameIn = `in` + TagNameMime = `mime` ) var ( diff --git a/protocol/goai/goai_path.go b/protocol/goai/goai_path.go index 0e209f0de..a7f749de6 100644 --- a/protocol/goai/goai_path.go +++ b/protocol/goai/goai_path.go @@ -136,7 +136,14 @@ func (oai *OpenApiV3) addPath(in addPathInput) error { } ) // Supported mime types of request. - for _, v := range oai.Config.ReadContentTypes { + var ( + contentTypes = oai.Config.ReadContentTypes + tagMimeValue = gmeta.Get(inputObject.Interface(), TagNameMime).String() + ) + if tagMimeValue != "" { + contentTypes = gstr.SplitAndTrim(tagMimeValue, ",") + } + for _, v := range contentTypes { requestBody.Content[v] = MediaType{ Schema: &SchemaRef{ Ref: inputStructTypeName, @@ -178,7 +185,14 @@ func (oai *OpenApiV3) addPath(in addPathInput) error { } } // Supported mime types of response. - for _, v := range oai.Config.WriteContentTypes { + var ( + contentTypes = oai.Config.ReadContentTypes + tagMimeValue = gmeta.Get(outputObject.Interface(), TagNameMime).String() + ) + if tagMimeValue != "" { + contentTypes = gstr.SplitAndTrim(tagMimeValue, ",") + } + for _, v := range contentTypes { response.Content[v] = MediaType{ Schema: &SchemaRef{ Ref: outputStructTypeName,