Trying out some json converters

This commit is contained in:
2021-11-06 16:25:14 -04:00
parent 12c90a27b4
commit d1840fb164
8 changed files with 134 additions and 3 deletions

View File

@@ -12,8 +12,10 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.OpenApi.Models;
using Newtonsoft.Json;
using NLog.Extensions.Logging;
using TOOHUCardAPI.Data;
using TOOHUCardAPI.Data.JsonConverters;
using TOOHUCardAPI.Data.Repositories;
using TOOHUCardAPI.Data.Services;
@@ -32,7 +34,14 @@ namespace TOOHUCardAPI
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers().AddNewtonsoftJson();
services.AddControllers().AddNewtonsoftJson(opt =>
{
opt.SerializerSettings.Converters = new List<JsonConverter>
{
new RankEntryDTOConverter(),
new PlayerDataGetResponseObjectPlayerConverter()
};
});
services.AddDbContext<AppDbContext>(opt =>
{
opt.UseNpgsql(Configuration.GetConnectionString("postgres"));