1515using Microsoft . Extensions . Configuration ;
1616using Microsoft . Extensions . DependencyInjection ;
1717using Microsoft . IdentityModel . Tokens ;
18+ using Swashbuckle . AspNetCore . Swagger ;
1819using WebGYM . Common ;
1920using WebGYM . Concrete ;
2021using WebGYM . Interface ;
@@ -114,6 +115,12 @@ public void ConfigureServices(IServiceCollection services)
114115 . AllowCredentials ( )
115116 . WithExposedHeaders ( "X-Pagination" ) ) ;
116117 } ) ;
118+
119+ // Register the Swagger generator, defining 1 or more Swagger documents
120+ services . AddSwaggerGen ( c =>
121+ {
122+ c . SwaggerDoc ( "v1" , new Info { Title = "WebGym API" , Version = "v1" } ) ;
123+ } ) ;
117124 }
118125
119126 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@@ -133,6 +140,18 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
133140 app . UseAuthentication ( ) ;
134141
135142 app . UseCors ( "CorsPolicy" ) ;
143+ // Enable middleware to serve generated Swagger as a JSON endpoint.
144+ app . UseSwagger ( ) ;
145+
146+ // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
147+ // specifying the Swagger JSON endpoint.
148+ app . UseSwaggerUI ( c =>
149+ {
150+ c . SwaggerEndpoint ( "/swagger/v1/swagger.json" , "WebGym API V1" ) ;
151+ //Reference document: https://docs.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-2.2&tabs=visual-studio
152+ //To serve the Swagger UI at the app's root (http://localhost:<port>/), set the RoutePrefix property to an empty string:
153+ c . RoutePrefix = string . Empty ;
154+ } ) ;
136155 app . UseMvc ( routes =>
137156 {
138157 routes . MapRoute (
0 commit comments