@@ -16,6 +16,7 @@ namespace MessagingService
1616 using System . IO ;
1717 using System . Net . Http ;
1818 using System . Reflection ;
19+ using System . Runtime . Intrinsics ;
1920 using BusinessLogic . Common ;
2021 using BusinessLogic . EventHandling ;
2122 using BusinessLogic . RequestHandlers ;
@@ -33,14 +34,12 @@ namespace MessagingService
3334 using MediatR ;
3435 using Microsoft . AspNetCore . Authentication . JwtBearer ;
3536 using Microsoft . AspNetCore . Diagnostics . HealthChecks ;
36- using Microsoft . AspNetCore . Mvc . ApiExplorer ;
37- using Microsoft . AspNetCore . Mvc . Versioning ;
3837 using Microsoft . Extensions . Diagnostics . HealthChecks ;
3938 using Microsoft . Extensions . Options ;
39+ using Microsoft . OpenApi . Models ;
4040 using Newtonsoft . Json ;
4141 using Newtonsoft . Json . Serialization ;
4242 using NLog . Extensions . Logging ;
43- using NuGet . Versioning ;
4443 using Service . Services . Email . IntegrationTest ;
4544 using Service . Services . SMSServices . IntegrationTest ;
4645 using Shared . DomainDrivenDesign . EventSourcing ;
@@ -233,35 +232,20 @@ private void ConfigureMiddlewareServices(IServiceCollection services)
233232 name : "Eventstore" ,
234233 failureStatus : HealthStatus . Unhealthy ,
235234 tags : new string [ ] { "db" , "eventstore" } ) ;
236-
237- var version = ConfigurationReader . GetValue ( "AppSettings" , "ApiVersion" ) ;
238- var v = NuGetVersion . Parse ( version ) ;
239- services . AddApiVersioning (
240- options =>
241- {
242- // reporting api versions will return the headers "api-supported-versions" and "api-deprecated-versions"
243- options . ReportApiVersions = true ;
244- options . DefaultApiVersion = new ApiVersion ( v . Major , v . Minor , $ "Patch{ v . Patch } ") ;
245- options . AssumeDefaultVersionWhenUnspecified = true ;
246- options . ApiVersionReader = new HeaderApiVersionReader ( "api-version" ) ;
247- } ) ;
248-
249- services . AddVersionedApiExplorer (
250- options =>
251- {
252- // add the versioned api explorer, which also adds IApiVersionDescriptionProvider service
253- // note: the specified format code will format the version as "'v'major[.minor][-status]"
254- options . GroupNameFormat = "'v'VVV" ;
255-
256- // note: this option is only necessary when versioning by url segment. the SubstitutionFormat
257- // can also be used to control the format of the API version in route templates
258- options . SubstituteApiVersionInUrl = true ;
259- } ) ;
260-
261- services . AddTransient < IConfigureOptions < SwaggerGenOptions > , ConfigureSwaggerOptions > ( ) ;
262-
235+
263236 services . AddSwaggerGen ( c =>
264237 {
238+ c . SwaggerDoc ( "v1" , new OpenApiInfo
239+ {
240+ Title = "Messaging API" ,
241+ Version = "1.0" ,
242+ Description = "A REST Api to manage sending of various messages over different formats, currently only Email and SMS are supported." ,
243+ Contact = new OpenApiContact
244+ {
245+ Name = "Stuart Ferguson" ,
246+ 247+ }
248+ } ) ;
265249 // add a custom operation filter which sets default values
266250 c . OperationFilter < SwaggerDefaultValues > ( ) ;
267251 c . ExampleFilters ( ) ;
@@ -305,8 +289,7 @@ private void ConfigureMiddlewareServices(IServiceCollection services)
305289 }
306290
307291 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
308- public void Configure ( IApplicationBuilder app , IWebHostEnvironment env , ILoggerFactory loggerFactory ,
309- IApiVersionDescriptionProvider provider )
292+ public void Configure ( IApplicationBuilder app , IWebHostEnvironment env , ILoggerFactory loggerFactory )
310293 {
311294 String nlogConfigFilename = "nlog.config" ;
312295
@@ -350,15 +333,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerF
350333 } ) ;
351334 app . UseSwagger ( ) ;
352335
353- app . UseSwaggerUI (
354- options =>
355- {
356- // build a swagger endpoint for each discovered API version
357- foreach ( ApiVersionDescription description in provider . ApiVersionDescriptions )
358- {
359- options . SwaggerEndpoint ( $ "/swagger/{ description . GroupName } /swagger.json", description . GroupName . ToUpperInvariant ( ) ) ;
360- }
361- } ) ;
336+ app . UseSwaggerUI ( ) ;
362337 }
363338 }
364339}
0 commit comments