diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json index a56113a..98548b6 100644 --- a/Properties/launchSettings.json +++ b/Properties/launchSettings.json @@ -12,7 +12,7 @@ "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, - "launchUrl": "weatherforecast", + "launchUrl": "swagger", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -20,7 +20,7 @@ "TestApplication": { "commandName": "Project", "launchBrowser": true, - "launchUrl": "weatherforecast", + "launchUrl": "swagger", "applicationUrl": "https://localhost:5001;http://localhost:5000", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" diff --git a/Startup.cs b/Startup.cs index a95811d..c48f3f1 100644 --- a/Startup.cs +++ b/Startup.cs @@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using Microsoft.OpenApi.Models; using TestApplication.Data; namespace TestApplication @@ -25,6 +26,17 @@ namespace TestApplication { opt.UseMySql(Configuration.GetConnectionString("DefaultConnection")); }); + + services.AddSwaggerGen(swagger => + { + //This is to generate the Default UI of Swagger Documentation + swagger.SwaggerDoc("v1", new OpenApiInfo + { + Version= "v1", + Title = "ICDL Ireland Shop", + Description="ASP.NET Core 3.1 Web API Documentaion" + }); + }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -33,6 +45,8 @@ namespace TestApplication if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); + app.UseSwagger(); + app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "API v1")); } app.UseHttpsRedirection(); diff --git a/TestApplication.csproj b/TestApplication.csproj index 5f0d390..dbae294 100644 --- a/TestApplication.csproj +++ b/TestApplication.csproj @@ -5,5 +5,6 @@ + \ No newline at end of file