diff --git a/openapi/middleware.go b/openapi/middleware.go index f61eb45e..be41de1a 100644 --- a/openapi/middleware.go +++ b/openapi/middleware.go @@ -268,10 +268,12 @@ func (o *Operation) BodyRef(ref string, summary, description web.LocaleStringer) // // f 如果不为空,则要以对根据 resp 生成的对象做二次修改。 func (o *Operation) Response(status string, resp any, desc web.LocaleStringer, f func(*Response)) *Operation { - r := &Response{ - Description: desc, - Body: o.d.newSchema(reflect.TypeOf(resp)), + r := &Response{Description: desc} + + if resp != nil { + r.Body = o.d.newSchema(reflect.TypeOf(resp)) } + if f != nil { f(r) } diff --git a/openapi/openapi.go b/openapi/openapi.go index 993e3922..c787e159 100644 --- a/openapi/openapi.go +++ b/openapi/openapi.go @@ -45,6 +45,8 @@ const ( ) const ( + FormatBinary = "binary" + FormatByte = "byte" FormatInt32 = "int32" FormatInt64 = "int64" FormatFloat = "float"