I have a model such as:
/// <summary>
/// Represents the properties required to support user authentication
/// </summary>
public class LoginInputModel
{
/// <summary>
/// The email address (used as username) for the user attempting to login
/// </summary>
[Required]
public string Email { get; set; }
/// <summary>
/// The password of the user attempting to login
/// </summary>
[Required]
public string Password { get; set; }
}
On my login action I have something like:
[HttpPost("[action]"), AllowAnonymous]
[Produces("application/json", Type = typeof(GenerateJwtResult))]
[SwaggerResponse(System.Net.HttpStatusCode.OK, Type = typeof(GenerateJwtResult))]
public async Task<IActionResult> Login([FromForm] LoginInputModel model)
{
...
}
I was hoping in the swagger UI it would show the properties email and password in camelCase but this doesn't seem to be the case. Is this possible to configure?
I've added this in my services method
AddMvc().AddJsonOptions(options =>
{
options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
});
and then
// Register Swagger
services.AddSwaggerGen();
services.ConfigureSwaggerGen(options =>
{
options.SingleApiVersion(new Info
{
Version = "v1",
Title = "API",
Description = "An API"
});
options.DescribeAllEnumsAsStrings();
});
Most things show as camelCase for the output models but the input one still seems to be pascal.

Well, you're using FromForm, which means the input is explicitly not JSON, so any JSON options you set will not (or at least should not) impact form input.
I am unsure how ASP.NET model binding for form input works but it's either case sensitive or not. If it is, the Swagger document created is correct and camelCase wouldn't work. If it is not the name ASP.NET provides to SwaggerGen will still be the original as ASP.NET does not know of your intention to camel-case the parameter names.
What you're asking for is basically either an option in SwaggerGen or ASP.NET to ensure camelCase for form input. I don't think there is such an option today (but I could be wrong).
As a side note, if you want the strings for your enums to be camelCase as well you should add options.DescribeStringEnumsInCamelCase(); after options.DescribeAllEnumsAsStrings();.
Related to issue #160, which basically asks for the same thing (camelCase support), but for FromQuery.
@SimonTouchtech - Many thanks for taking the time to reply. Your comment makes sense based on the FromForm usage. The link to issue 160 helped as I'm using the FromForm(Name="") attribute on my properties now which seems to work for my needs. Would still be nice if the properties could be camelCased automatically for the generated swagger.
See d8ba4d35c17afa3f1d06884b9653a89ea746fe3c
Available with latest pre-release. Note the package rename to "Swashbuckle.AspNetCore.1.0.0-rc1"
Is there a way to do this in .Net Core 2.2?
Is there a way to do this in .Net Core 2.2?
For everyone who might be looking, this does the trick:
services.AddSwaggerGen(c =>
{
c.DescribeAllParametersInCamelCase();
}
Most helpful comment
For everyone who might be looking, this does the trick: