Add project files.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user