First off, this worked fine in Swashbuckle.AspNetCore v4. So given this model & endpoint;
public class TestRequest
{
public string test1 { get; set; }
public string test2;
}
[HttpPost]
public void Post([FromBody] TestRequest value)
{
}
Swagger only shows;
{
"test1": "string"
}
as the example TestRequest value.
Is this behaviour intended now? Is there anyway to change this via setup or filters? I have a ton of imported services that only use fields. (generated by dotnet-svcutil, which is pretty common)
ok, taking @Flydog57 suggestion to figure it out myself, I found that the new Swashbuckle.AspNetCore is using the MS json.net over Newtonsoft.
So reading over the git readme a tenth time at https://github.com/domaindrivendev/Swashbuckle.AspNetCore
I found that there is a way to revert the json serializer back to Newtonsoft. First (as of the 5.0.0-rc5 release) install this package;
Install-Package Swashbuckle.AspNetCore.Newtonsoft -Version 5.0.0-rc5
Then in Start.ConfigureServices tell Swashbuckle to use by;
services.AddSwaggerGenNewtonsoftSupport();
Now you'll find all those public "Fields" have reappeared in your swagger page.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.