C# Swagger HttpPost raw urlencoded body

I am building an API in C#.Net using Controllers and utilising Swagger but I have the need for accepting an arbitrary set of key-values and cant find out how to get swagger to show an input box (and if possible, for the HttpPost method to split the body into an IFormCollection).

The POST content looks like the following:

key1=val1&key2=val2&key3=val3a&key3=val3b&.....

and so on to any number of key-values.

The handler looks like the following which works but SwaggerUI doesnt offer any input box to pass in the body:

[HttpPost]
[Consumes(MediaTypeNames.Application.FormUrlEncoded)]
[ProducesResponseType(StatusCodes.Status204NoContent)]
public async Task<IActionResult> SetKeys()
{
    var keyvals = await Request.Body.ToDictionary();  // Uses Stream extension
    if (keyvals.Count == 0)
        return BadRequest("No data received");

    // update database

    return NoContent(); //204
}

I’ve tried different signatures all to no avail

public async Task<IActionResult> SetKeys([FromBody] string content)
public async Task<IActionResult> SetKeys([FromForm] string content)
public async Task<IActionResult> SetKeys([FromBody] string content)
public async Task<IActionResult> SetKeys([FromForm] IFormCollection content)
public async Task<IActionResult> SetKeys([FromBody] IFormCollection content)
public async Task<IActionResult> SetKeys([FromBody] List<KeyValuePair<string, string>> content)

Setting the content type to text/plain works, then reading [FromBody], but I still have to extract the body to key-value pairs and im loosing a validation check on content-type:

[HttpPost]
[Consumes(MediaTypeNames.Text.Plain)]
[ProducesResponseType(typeof(string), StatusCodes.Status200OK, MediaTypeNames.Application.FormUrlEncoded)]
public async Task<IActionResult> SetKeys([FromBody] string content)
{
    var keyvals = await content.ToDictionary();  // Uses String extension
    if (keyvals.Count == 0)
        return BadRequest("No data received");

    // update database

    return NoContent(); //204
}

I even tried an InputFormatter which allows me to at least chose the Content-Type in swagger but it splits the content per character into a key:

using System.Net.Mime;
using Microsoft.AspNetCore.Mvc.Formatters;

namespace RequestRouter.Utilities;

public class RawBodyInputFormatter : InputFormatter
{
    public RawBodyInputFormatter()
    {
        this.SupportedMediaTypes.Add(MediaTypeNames.Application.FormUrlEncoded);
        //this.SupportedMediaTypes.Add(MediaTypeNames.Text.Plain);
    }

    public override async Task<InputFormatterResult> ReadRequestBodyAsync(InputFormatterContext context)
    {
        var request = context.HttpContext.Request;
        using var reader = new StreamReader(request.Body);
        var content = await reader.ReadToEndAsync();
        return await InputFormatterResult.SuccessAsync(content);
    }

    protected override bool CanReadType(Type type)
    {
        return type == typeof(string);
    }
}

How Swagger formats the curl when application/x-www-form-urlencoded is selected:

curl -X 'POST' 
  'http://localhost:8001/config' 
  -H 'accept: */*' 
  -H 'Content-Type: application/x-www-form-urlencoded' 
  -d '0=k&1=e&2=y&3=1&4=%3D&5=v&6=a&7=l&8=1'

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật