Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要定义一个需要接受媒体类型 text 和 zip 的 swagger 端点。我可以让 io.Readcloser 直接通过,而不是让生成的包使用它并将其重新分配为单独的类型(例如字符串)吗?
招摇规格:
"parameters": [ { "name": "foo", "in": "body", "schema": { "type": string, "format": "binary" } } ]
生成的参数:
type SomeParams struct { Foo io.ReadCloser }
并且在生成的BindRequest方法中,请求体 ReadCloser 被赋给了该Foo字段:
BindRequest
Foo
if runtime.HasBody(r) { o.Foo = r.Body }