1

I am creating a swagger spec for a new endpoint that will be receiving a file as a binary data. How might you represent this in a swagger spec? I see object as a data type but that does not appear to be what I'm looking for. Has anyone done this in the past?

This question is not a duplicate as far as I can tell as it pertains specifically to a binary or "blob" object type.

Bert Alfred
  • 431
  • 2
  • 7
  • 20
  • Possible duplicate of [How to post files in swagger?](https://stackoverflow.com/questions/14455408/how-to-post-files-in-swagger) – Helen Oct 11 '17 at 21:48
  • I don't believe so. When I try to use that example I get "...allowedValues: array, boolean, integer, null, number, object, string" Probably missing something? – Bert Alfred Oct 11 '17 at 22:11
  • @BertAlfred it is - you can't send binary data via HTTP1.1, meaning you're base64 encoding it. – kolosy Oct 11 '17 at 22:52
  • @BertAlfred, which code did you use? As explained in [this answer](https://stackoverflow.com/a/37932354/113116), file uploads are defined as `in: formData` parameters with `type: file`, and the operation must consume `multipart/form-data`. – Helen Oct 12 '17 at 07:54

1 Answers1

6

Since swagger describes RESTful web services, any binary data will be base-64 encoded, turning it into a string. Therefore, the way to specify it is to just define it as such - a string.

kolosy
  • 3,029
  • 3
  • 29
  • 48