You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.9 KiB
C#
95 lines
2.9 KiB
C#
3 years ago
|
using System;
|
||
|
using System.IO;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Threading.Tasks;
|
||
|
using System.Reflection;
|
||
|
|
||
3 years ago
|
using Microsoft.AspNetCore.Builder;
|
||
|
using Microsoft.AspNetCore.Hosting;
|
||
|
using Microsoft.AspNetCore.Mvc;
|
||
|
using Microsoft.Extensions.Configuration;
|
||
|
using Microsoft.Extensions.DependencyInjection;
|
||
|
using Microsoft.Extensions.Hosting;
|
||
|
using Microsoft.Extensions.Logging;
|
||
|
using Microsoft.OpenApi.Models;
|
||
|
|
||
|
using Newtonsoft.Json;
|
||
|
using Newtonsoft.Json.Linq;
|
||
|
using Newtonsoft.Json.Schema;
|
||
|
using Newtonsoft.Json.Converters;
|
||
|
using Newtonsoft.Json.Serialization;
|
||
|
|
||
3 years ago
|
|
||
|
|
||
3 years ago
|
namespace DockerStudyApi
|
||
|
{
|
||
|
public class Startup
|
||
|
{
|
||
|
public Startup(IConfiguration configuration)
|
||
|
{
|
||
|
Configuration = configuration;
|
||
|
}
|
||
|
|
||
|
public IConfiguration Configuration { get; }
|
||
|
|
||
|
// This method gets called by the runtime. Use this method to add services to the container.
|
||
|
public void ConfigureServices(IServiceCollection services)
|
||
|
{
|
||
|
services.AddOptions();
|
||
|
services.Configure<TestOption>(Configuration.GetSection("TestOption"));
|
||
|
|
||
|
services.AddControllersWithViews()
|
||
|
.AddNewtonsoftJson(options =>
|
||
|
{
|
||
|
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
|
||
|
options.SerializerSettings.Formatting = Formatting.Indented;
|
||
|
})
|
||
|
//.AddJsonOptions(config=>
|
||
|
//{
|
||
|
// config.JsonSerializerOptions.Encoder = System.Text.Encodings.Web.JavaScriptEncoder.Create(System.Text.Unicode.UnicodeRanges.All);
|
||
|
//})
|
||
|
;
|
||
|
services.AddSwaggerGen(c =>
|
||
|
{
|
||
|
c.SwaggerDoc("v1", new OpenApiInfo { Title = "DockerStudyApi", Version = "v1" });
|
||
3 years ago
|
|
||
|
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
||
|
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
|
||
|
c.IncludeXmlComments(xmlPath,true);
|
||
|
|
||
|
}).AddSwaggerGenNewtonsoftSupport();
|
||
|
|
||
3 years ago
|
}
|
||
|
|
||
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||
|
{
|
||
|
if (env.IsDevelopment())
|
||
|
{
|
||
|
app.UseDeveloperExceptionPage();
|
||
|
}
|
||
|
|
||
3 years ago
|
app.UseSwagger(setup =>
|
||
|
{
|
||
|
|
||
|
});
|
||
|
app.UseSwaggerUI(c =>
|
||
|
{
|
||
|
c.SwaggerEndpoint("/swagger/v1/swagger.json", "DockerStudyApi v1");
|
||
|
c.EnableFilter();
|
||
|
//c.ShowCommonExtensions();
|
||
|
});
|
||
|
|
||
3 years ago
|
app.UseRouting();
|
||
|
|
||
|
app.UseAuthorization();
|
||
|
|
||
|
app.UseEndpoints(endpoints =>
|
||
|
{
|
||
|
endpoints.MapControllers();
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
}
|