1212 using Microsoft . Extensions . Configuration ;
1313 using Microsoft . Extensions . DependencyInjection ;
1414 using Microsoft . IdentityModel . Tokens ;
15+ using Microsoft . OpenApi . Models ;
1516 using Swashbuckle . AspNetCore . Swagger ;
1617
1718 public class Startup
@@ -46,10 +47,10 @@ public void ConfigureServices(IServiceCollection services)
4647 . AllowAnyHeader ( )
4748 . AllowAnyMethod ( ) . AllowCredentials ( )
4849 ) ) ;
49- services . AddMvc ( ) . SetCompatibilityVersion ( CompatibilityVersion . Version_2_1 ) ;
50+ services . AddControllers ( ) ;
5051 services . AddSwaggerGen ( c =>
5152 {
52- c . SwaggerDoc ( "v1" , new Info { Title = "APIJSON.NET" , Version = "v1" } ) ;
53+ c . SwaggerDoc ( "v1" , new OpenApiInfo { Title = "APIJSON.NET" , Version = "v1" } ) ;
5354 } ) ;
5455 services . AddSingleton < DbContext > ( ) ;
5556 services . AddSingleton < SelectTable > ( ) ;
@@ -61,17 +62,12 @@ public void ConfigureServices(IServiceCollection services)
6162 }
6263
6364 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
64- public void Configure ( IApplicationBuilder app , IHostingEnvironment env )
65+ public void Configure ( IApplicationBuilder app , IWebHostEnvironment env )
6566 {
6667
6768 app . UseAuthentication ( ) ;
6869
69- app . UseMvc ( routes =>
70- {
71- routes . MapRoute (
72- name : "default" ,
73- template : "{controller=Home}/{action=Index}/{id?}" ) ;
74- } ) ;
70+ app . UseRouting ( ) ;
7571 app . UseStaticFiles ( ) ;
7672 app . UseCors ( _defaultCorsPolicyName ) ;
7773 app . UseSwagger ( ) ;
@@ -80,7 +76,10 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
8076 c . SwaggerEndpoint ( "/swagger/v1/swagger.json" , "My API V1" ) ;
8177
8278 } ) ;
83-
79+ app . UseEndpoints ( endpoints =>
80+ {
81+ endpoints . MapControllers ( ) ;
82+ } ) ;
8483 app . UseJwtTokenMiddleware ( ) ;
8584 DbInit . Initialize ( app ) ;
8685 }
0 commit comments