Parameters used by response formatter

There are cases were I would like to send parameters that are used by a custom formatter in order to adjust how to generate that format. For example, say you want to tell the csv formatter to use \t instead of , as a field separator.

What’s the best way to pass that in a GET/POST request? Sure you can add any querystring params and have the formatter extract those, but that will trigger warnings (that, granted, can be muted) about mismatched request params. Is there another trick or convention preferred?

I’d just have an explicit property for it, the feature isn’t going to be discoverable otherwise. Other than that you can have a magic property convention like you suggest and add it to Config.IgnoreWarningsOnPropertyNames.

ok thanks.

On a vaguely related topic, while using csv as a test case, I couldn’t seem to get the content-disposition header to kick-in with Chrome.

GlobalResponseFilters.Add((req, res, dto) =>
{
   if (req.ResponseContentType == MimeTypes.Csv)
   {
       res.AddHeader(HttpHeaders.ContentDisposition,"inline;");
   }
}

always triggers a download in Chrome/Edge. Did I miss something?

Sounds like you’re getting the default behavior of CSV Format:

//Add a response filter to add a 'Content-Disposition' header so browsers treat it natively as a .csv file
appHost.GlobalResponseFilters.Add((req, res, dto) =>
{
    if (req.ResponseContentType == MimeTypes.Csv)
    {
        res.AddHeader(HttpHeaders.ContentDisposition, $$"attachment;filename={req.OperationName}.csv");
    }
});

In which case you can remove the built-in CsvFormat and just register it yourself, e.g:

Plugins.RemoveAll(x => x is CsvFormat);

ContentTypes.Register(MimeTypes.Csv, 
    SerializeToStream, CsvSerializer.DeserializeFromStream);

Odd, that didn’t seem to do it. Guess I’m fighting more with Chrome than anything else.