You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
No matter which naming policy is set in general JSON serializer options when using minimal APIs, Swashbuckle applies camel casing. It therefore does not comply with the actual output of the endpoint.
Expected behavior
With the null naming policy, the property name should have been taken without modification, i.e. it should have been HelloWorld.
varbuilder= WebApplication.CreateSlimBuilder(args);
builder.Services.ConfigureHttpJsonOptions(options =>{ options.SerializerOptions.PropertyNamingPolicy =null;});
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();// This needs to be added because of some other open issue
builder.Services.Configure<RouteOptions>(options => options.SetParameterPolicy<RegexInlineRouteConstraint>("regex"));
builder.WebHost.UseKestrelHttpsConfiguration();varapp= builder.Build();if(app.Environment.IsDevelopment()){
app.UseSwagger();
app.UseSwaggerUI();}
app.MapGet("/hello",()=>new MyDto());
app.Run();internalsealedclassMyDto{publicstringHelloWorld=>"hello";}
Exception(s) (if any)
No response
Swashbuckle.AspNetCore version
6.8.1
.NET Version
8.0.400
Anything else?
NSwag correctly applies the configured property naming policy, using the same code (aside from the 3 Swashbuckle calls replaced with NSwag ones).
The text was updated successfully, but these errors were encountered:
Describe the bug
No matter which naming policy is set in general JSON serializer options when using minimal APIs, Swashbuckle applies camel casing. It therefore does not comply with the actual output of the endpoint.
Expected behavior
With the null naming policy, the property name should have been taken without modification, i.e. it should have been
HelloWorld
.Actual behavior
The property name was modified to camel case.
This is what I get in the document:
Steps to reproduce
Using this code in Program.cs:
Exception(s) (if any)
No response
Swashbuckle.AspNetCore version
6.8.1
.NET Version
8.0.400
Anything else?
NSwag correctly applies the configured property naming policy, using the same code (aside from the 3 Swashbuckle calls replaced with NSwag ones).
The text was updated successfully, but these errors were encountered: