Search code examples
c#asp.net-web-apidocumentationasp.net-mvc-apiexplorer

How to tell web api ApiExplorer that the endpoint will return binary data (like a zip file)?


For endpoints returning models, we can use the ResponseTypeAttribute to tell the help page documentation what the return data will look like:

/// <summary>
/// returns the specified Foo.
/// </summary>
[ResponseType(typeof(FooModel))]
[HttpGet]
[Route("~/api/foos/{fooId}")]
public async Task<IHttpActionResult> GetFoo(int fooId)
{
    ...
}

This will make a nice entry on the Api Help page, describing how this endpoint will behave.

I want to document that a certain endpoint will return an application/zip binary stream. How can I do that?


Solution

  • Well if you already know that your api endpoint going to return zip file then you can set it hard-coded to application/octet-stream.

    content-type = "application/octet-stream"