diff --git a/src/HelloShop.AppHost/Program.cs b/src/HelloShop.AppHost/Program.cs index 42e542a..058fc9e 100644 --- a/src/HelloShop.AppHost/Program.cs +++ b/src/HelloShop.AppHost/Program.cs @@ -1,15 +1,15 @@ var builder = DistributedApplication.CreateBuilder(args); -var apiservice = builder.AddProject("helloshop.apiservice"); +var apiservice = builder.AddProject("apiservice"); -builder.AddProject("helloshop.webfrontend").WithReference(apiservice); +builder.AddProject("identityservice"); -builder.AddProject("helloshop.identityservice"); +builder.AddProject("orderingservice"); -builder.AddProject("helloshop.orderingservice"); +builder.AddProject("productservice"); -builder.AddProject("helloshop.productservice"); +builder.AddProject("basketservice"); -builder.AddProject("helloshop.basketservice"); +builder.AddProject("webapp").WithReference(apiservice); builder.Build().Run(); diff --git a/src/HelloShop.IdentityService/HelloShop.IdentityService.csproj b/src/HelloShop.IdentityService/HelloShop.IdentityService.csproj index 9e3561c..43ed4c7 100644 --- a/src/HelloShop.IdentityService/HelloShop.IdentityService.csproj +++ b/src/HelloShop.IdentityService/HelloShop.IdentityService.csproj @@ -11,7 +11,6 @@ all - diff --git a/src/HelloShop.IdentityService/Program.cs b/src/HelloShop.IdentityService/Program.cs index 54e8ab7..57e6b7f 100644 --- a/src/HelloShop.IdentityService/Program.cs +++ b/src/HelloShop.IdentityService/Program.cs @@ -21,6 +21,7 @@ builder.Services.AddDbContext(options => }); builder.Services.AddDataSeedingProviders(); +builder.Services.AddOpenApi(); var app = builder.Build(); @@ -40,5 +41,6 @@ app.UseAuthorization(); app.MapControllers(); app.UseDataSeedingProviders(); +app.UseOpenApi(); app.Run(); diff --git a/src/HelloShop.ServiceDefaults/Extensions/OpenApiExtensions.cs b/src/HelloShop.ServiceDefaults/Extensions/OpenApiExtensions.cs new file mode 100644 index 0000000..531ed9a --- /dev/null +++ b/src/HelloShop.ServiceDefaults/Extensions/OpenApiExtensions.cs @@ -0,0 +1,36 @@ +// Copyright (c) HelloShop Corporation. All rights reserved. +// See the license file in the project root for more information. + +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Swashbuckle.AspNetCore.Swagger; +using Swashbuckle.AspNetCore.SwaggerGen; +using Swashbuckle.AspNetCore.SwaggerUI; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; + +namespace HelloShop.ServiceDefaults.Extensions +{ + public static class OpenApiExtensions + { + public static IServiceCollection AddOpenApi(this IServiceCollection services, Action? configureOptions = null) + { + services.AddEndpointsApiExplorer(); + services.AddSwaggerGen(configureOptions); + + return services; + } + + public static IApplicationBuilder UseOpenApi(this IApplicationBuilder app, Action? apiConfigureOptions = null, Action? uiConfigureOptions = null) + { + app.UseSwagger(apiConfigureOptions); + app.UseSwaggerUI(uiConfigureOptions); + + return app; + } + } +} diff --git a/src/HelloShop.ServiceDefaults/HelloShop.ServiceDefaults.csproj b/src/HelloShop.ServiceDefaults/HelloShop.ServiceDefaults.csproj index bea61d9..f9f2ed2 100644 --- a/src/HelloShop.ServiceDefaults/HelloShop.ServiceDefaults.csproj +++ b/src/HelloShop.ServiceDefaults/HelloShop.ServiceDefaults.csproj @@ -16,5 +16,6 @@ + \ No newline at end of file