mattfrear / Swashbuckle.AspNetCore.Filters

A bunch of useful filters for Swashbuckle.AspNetCore
MIT License
430 stars 80 forks source link

CSV Examples #235

Closed Bl4d3s closed 1 year ago

Bl4d3s commented 1 year ago

This commit enables the CSV media type for response as well as request and both a single example and multiple ones.

As a CSV converter has to be manually registered a try catch block is used to catch the formatter not found exception and display a corresponding message in swagger

mattfrear commented 1 year ago

Hello

I've had a look at your code and this PR looks good.

Just wondering, how do you register a CSV input formatter? In my WebApi3.1-Swashbuckle5 test project, I get this: image

Bl4d3s commented 1 year ago

Hi,

thanks for the quick review.

I use the following code:

builder.Services.AddControllers(options =>
{
    options.InputFormatters.Add(new CsvInputFormatter());
    options.OutputFormatters.Add(new CsvOutputFormatter());
});

and the formatters extend from TextInputFormatter and TextOutputFormatter respectively.

I'm using net7.0 so do not know if this applies directly to net3.1 as well.

mattfrear commented 1 year ago

Released https://www.nuget.org/packages/Swashbuckle.AspNetCore.Filters/7.0.12

Thanks for this PR :-)