I'm currently developing a web API in asp.net core 1.0+. The API is using versioning, so I have a version 1 and a version 2, where the first version is to support an old android application. The problem is that I want to return the JSON of version 1 in PascalCase and the version 2 as camelCase, how to achieve that?
I know you can put this in your startup file, but I don't want it to be global for all API Versions.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc()
.AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());
}
Example on how I use version on my api:
[ApiVersion("1")]
[Route("api/[controller]")]
[Route("v{version:apiVersion}/[controller]")]
public class CustomerController : Controller
{
...
}
Hope someone can help
I found that you can decorate it with the following.
Then the returned value for name will be PascalCase