SwaggerProvider icon indicating copy to clipboard operation
SwaggerProvider copied to clipboard

Support for POST endpoints with text/plain inputs?

Open Numpsy opened this issue 3 months ago • 2 comments

Hi,

I see that some work for text outputs was done for https://github.com/fsprojects/SwaggerProvider/issues/268, but I wonder if text inputs are supported or have similar issues?

As an example, if I have an ASP.Net Core minimal api of this sort:

app.MapPost("/weatherforecast", ([FromBody] string body) =>
{
    return "Wet";
}).Accepts<string>("text/plain");

Then the generated schema is like this

 "requestBody": {
          "content": {
            "text/plain": {
              "schema": {
                "type": "string"
              }
            }
          },
          "required": true
        },

And the type provider gives errors like

The type provider 'SwaggerProvider.OpenApiClientTypeProvider' reported an error: Operation '' does not contain supported media types ["text/plain"]

So is this something that needs more work in the provider to support?

Thanks.

Numpsy avatar Dec 14 '25 13:12 Numpsy

What version of TP do you use? Would you like to contribute failing test case for this scenario?

sergey-tihon avatar Dec 14 '25 19:12 sergey-tihon

I had the same error using both the latest release version and the version 3 preview version.

Would you like to contribute failing test case for this scenario?

The change in https://github.com/fsprojects/SwaggerProvider/pull/276 causes this error locally

Image

Actually that's also a repro for https://github.com/fsprojects/SwaggerProvider/issues/274 so I'll see if I can do something with that.

Numpsy avatar Dec 15 '25 12:12 Numpsy

Fixed in https://www.nuget.org/packages/SwaggerProvider/3.0.0-beta02

sergey-tihon avatar Dec 22 '25 13:12 sergey-tihon