From b2d28218dca9601931c9a3f74280d807a0a6bdc7 Mon Sep 17 00:00:00 2001 From: igorsych Date: Thu, 18 May 2017 21:50:51 +0300 Subject: [PATCH] swagger update https://github.com/domaindrivendev/Swashbuckle.AspNetCore --- .../AuthorizationHeaderParameterOperationFilter.cs | 6 ++---- .../Auth/Server/IdentitySecurityScheme.cs | 5 +---- src/Services/Basket/Basket.API/Basket.API.csproj | 2 +- src/Services/Basket/Basket.API/Startup.cs | 13 ++++++------- src/Services/Catalog/Catalog.API/Catalog.API.csproj | 2 +- src/Services/Catalog/Catalog.API/Startup.cs | 10 ++++++---- .../AuthorizationHeaderParameterOperationFilter.cs | 4 ++-- .../Ordering/Ordering.API/Ordering.API.csproj | 2 +- src/Services/Ordering/Ordering.API/Startup.cs | 11 ++++++----- 9 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/Services/Basket/Basket.API/Auth/Server/AuthorizationHeaderParameterOperationFilter.cs b/src/Services/Basket/Basket.API/Auth/Server/AuthorizationHeaderParameterOperationFilter.cs index 15e285a28..90aa89322 100644 --- a/src/Services/Basket/Basket.API/Auth/Server/AuthorizationHeaderParameterOperationFilter.cs +++ b/src/Services/Basket/Basket.API/Auth/Server/AuthorizationHeaderParameterOperationFilter.cs @@ -1,10 +1,8 @@ using Microsoft.AspNetCore.Mvc.Authorization; -using Swashbuckle.Swagger.Model; -using Swashbuckle.SwaggerGen.Generator; -using System; +using Swashbuckle.AspNetCore.Swagger; +using Swashbuckle.AspNetCore.SwaggerGen; using System.Collections.Generic; using System.Linq; -using System.Threading.Tasks; namespace Microsoft.eShopOnContainers.Services.Basket.API.Auth.Server { diff --git a/src/Services/Basket/Basket.API/Auth/Server/IdentitySecurityScheme.cs b/src/Services/Basket/Basket.API/Auth/Server/IdentitySecurityScheme.cs index b58d880d2..397f66db4 100644 --- a/src/Services/Basket/Basket.API/Auth/Server/IdentitySecurityScheme.cs +++ b/src/Services/Basket/Basket.API/Auth/Server/IdentitySecurityScheme.cs @@ -1,8 +1,5 @@ -using Swashbuckle.Swagger.Model; -using System; +using Swashbuckle.AspNetCore.Swagger; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; namespace Microsoft.eShopOnContainers.Services.Basket.API.Auth.Server { diff --git a/src/Services/Basket/Basket.API/Basket.API.csproj b/src/Services/Basket/Basket.API/Basket.API.csproj index e172320e7..2670bfe72 100644 --- a/src/Services/Basket/Basket.API/Basket.API.csproj +++ b/src/Services/Basket/Basket.API/Basket.API.csproj @@ -22,6 +22,7 @@ + @@ -36,7 +37,6 @@ - diff --git a/src/Services/Basket/Basket.API/Startup.cs b/src/Services/Basket/Basket.API/Startup.cs index 855312a65..ce7c37749 100644 --- a/src/Services/Basket/Basket.API/Startup.cs +++ b/src/Services/Basket/Basket.API/Startup.cs @@ -82,13 +82,10 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API return new DefaultRabbitMQPersistentConnection(factory, logger); }); - services.AddSwaggerGen(); - - services.ConfigureSwaggerGen(options => + services.AddSwaggerGen(options => { - options.OperationFilter(); options.DescribeAllEnumsAsStrings(); - options.SingleApiVersion(new Swashbuckle.Swagger.Model.Info() + options.SwaggerDoc("eShopOnContainers - Basket HTTP API", new Swashbuckle.AspNetCore.Swagger.Info { Title = "Basket HTTP API", Version = "v1", @@ -97,7 +94,6 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API }); }); - services.AddCors(options => { options.AddPolicy("CorsPolicy", @@ -137,7 +133,10 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API app.UseMvcWithDefaultRoute(); app.UseSwagger() - .UseSwaggerUi(); + .UseSwaggerUI(c => + { + c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); + }); ConfigureEventBus(app); diff --git a/src/Services/Catalog/Catalog.API/Catalog.API.csproj b/src/Services/Catalog/Catalog.API/Catalog.API.csproj index fadf1b786..55affd7f8 100644 --- a/src/Services/Catalog/Catalog.API/Catalog.API.csproj +++ b/src/Services/Catalog/Catalog.API/Catalog.API.csproj @@ -48,7 +48,7 @@ - + diff --git a/src/Services/Catalog/Catalog.API/Startup.cs b/src/Services/Catalog/Catalog.API/Startup.cs index 65fb26515..2daa15a07 100644 --- a/src/Services/Catalog/Catalog.API/Startup.cs +++ b/src/Services/Catalog/Catalog.API/Startup.cs @@ -82,11 +82,10 @@ services.Configure(Configuration); // Add framework services. - services.AddSwaggerGen(); - services.ConfigureSwaggerGen(options => + services.AddSwaggerGen(options => { options.DescribeAllEnumsAsStrings(); - options.SingleApiVersion(new Swashbuckle.Swagger.Model.Info() + options.SwaggerDoc("eShopOnContainers - Catalog HTTP API",new Swashbuckle.AspNetCore.Swagger.Info { Title = "eShopOnContainers - Catalog HTTP API", Version = "v1", @@ -137,7 +136,10 @@ app.UseMvcWithDefaultRoute(); app.UseSwagger() - .UseSwaggerUi(); + .UseSwaggerUI(c => + { + c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); + }); var context = (CatalogContext)app .ApplicationServices.GetService(typeof(CatalogContext)); diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/Auth/AuthorizationHeaderParameterOperationFilter.cs b/src/Services/Ordering/Ordering.API/Infrastructure/Auth/AuthorizationHeaderParameterOperationFilter.cs index 2b5b33fd7..f780ff4a5 100644 --- a/src/Services/Ordering/Ordering.API/Infrastructure/Auth/AuthorizationHeaderParameterOperationFilter.cs +++ b/src/Services/Ordering/Ordering.API/Infrastructure/Auth/AuthorizationHeaderParameterOperationFilter.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Mvc.Authorization; -using Swashbuckle.Swagger.Model; -using Swashbuckle.SwaggerGen.Generator; +using Swashbuckle.AspNetCore.Swagger; +using Swashbuckle.AspNetCore.SwaggerGen; using System.Collections.Generic; using System.Linq; diff --git a/src/Services/Ordering/Ordering.API/Ordering.API.csproj b/src/Services/Ordering/Ordering.API/Ordering.API.csproj index c9d4296fa..676fd7b54 100644 --- a/src/Services/Ordering/Ordering.API/Ordering.API.csproj +++ b/src/Services/Ordering/Ordering.API/Ordering.API.csproj @@ -38,7 +38,6 @@ - @@ -58,6 +57,7 @@ + diff --git a/src/Services/Ordering/Ordering.API/Startup.cs b/src/Services/Ordering/Ordering.API/Startup.cs index 0cc8dbc0a..b20d82ad7 100644 --- a/src/Services/Ordering/Ordering.API/Startup.cs +++ b/src/Services/Ordering/Ordering.API/Startup.cs @@ -82,12 +82,10 @@ ServiceLifetime.Scoped //Showing explicitly that the DbContext is shared across the HTTP request scope (graph of objects started in the HTTP request) ); - services.AddSwaggerGen(); - services.ConfigureSwaggerGen(options => + services.AddSwaggerGen(options => { - options.OperationFilter(); options.DescribeAllEnumsAsStrings(); - options.SingleApiVersion(new Swashbuckle.Swagger.Model.Info() + options.SwaggerDoc("eShopOnContainers - Ordering HTTP API", new Swashbuckle.AspNetCore.Swagger.Info { Title = "Ordering HTTP API", Version = "v1", @@ -153,7 +151,10 @@ app.UseMvcWithDefaultRoute(); app.UseSwagger() - .UseSwaggerUi(); + .UseSwaggerUI(c => + { + c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); + }); OrderingContextSeed.SeedAsync(app).Wait();