0

I need to define a swagger endpoint that needs to take in media types text and zip. Instead of having the generated package consume it and reassign it into separate types such as string, can I get the io.Readcloser passed through directly?

Sammy Eang
  • 21
  • 4

1 Answers1

1

Swagger spec:

"parameters": [
  {
    "name": "foo",
    "in": "body",
    "schema": {
      "type": string,
      "format": "binary"
    }
  }
]

Generated parameter:

type SomeParams struct {
    Foo io.ReadCloser
}

And in the generated BindRequest method, the request body ReadCloser is assigned to the Foo field:

    if runtime.HasBody(r) {
        o.Foo = r.Body
    }
lencharest
  • 2,825
  • 2
  • 15
  • 22