52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
using System.Reflection;
|
|
using Microsoft.OpenApi.Models;
|
|
using Newtonsoft.Json.Converters;
|
|
|
|
namespace TURN.Services.Chess
|
|
{
|
|
public class Startup
|
|
{
|
|
public void ConfigureServices(IServiceCollection services)
|
|
{
|
|
ConfigureSwagger(services);
|
|
_ = services.AddControllers();
|
|
_ = services.AddControllers().AddNewtonsoftJson(jsonOptions =>
|
|
{
|
|
jsonOptions.SerializerSettings.Converters.Add(new StringEnumConverter());
|
|
});
|
|
//_ = services.AddDbContext<ModelBaseContext>(
|
|
// options => options.UseSqlServer(Environment.GetEnvironmentVariable("DB")));
|
|
}
|
|
|
|
public void Configure(IApplicationBuilder app)
|
|
{
|
|
_ = app.UseRouting();
|
|
_ = app.UseSwagger();
|
|
_ = app.UseSwaggerUI();
|
|
_ = app.UseEndpoints(endpoints =>
|
|
{
|
|
_ = endpoints.MapControllers();
|
|
_ = endpoints.MapControllerRoute(
|
|
name: "default",
|
|
pattern: "{controller}/{action}");
|
|
_ = endpoints.MapSwagger();
|
|
});
|
|
}
|
|
|
|
private void ConfigureSwagger(IServiceCollection services)
|
|
{
|
|
_ = services.AddSwaggerGen(options =>
|
|
{
|
|
options.SwaggerDoc("v1", new OpenApiInfo
|
|
{
|
|
Title = "TURN.Api.Swagger",
|
|
Version = "v1"
|
|
});
|
|
string xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
|
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
|
|
});
|
|
_ = services.AddSwaggerGenNewtonsoftSupport();
|
|
}
|
|
}
|
|
}
|