From b870643938460fcb402eae219179b95bd9e0357e Mon Sep 17 00:00:00 2001 From: Denis Prokhorchik Date: Sat, 23 Apr 2022 00:43:18 +0300 Subject: [PATCH] feat(task-326): include Swashbuckle.AspNetCore v1.1.0 to o2 go-event api --- .../O2NextGen.GoEvent.Api.csproj | 3 ++- .../Properties/launchSettings.json | 4 ++-- .../go-event/O2NextGen.GoEvent.Api/Startup.cs | 16 +++++++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/Services/go-event/O2NextGen.GoEvent.Api/O2NextGen.GoEvent.Api.csproj b/src/Services/go-event/O2NextGen.GoEvent.Api/O2NextGen.GoEvent.Api.csproj index 79f1734c..70c8dc8e 100644 --- a/src/Services/go-event/O2NextGen.GoEvent.Api/O2NextGen.GoEvent.Api.csproj +++ b/src/Services/go-event/O2NextGen.GoEvent.Api/O2NextGen.GoEvent.Api.csproj @@ -10,7 +10,8 @@ - + + diff --git a/src/Services/go-event/O2NextGen.GoEvent.Api/Properties/launchSettings.json b/src/Services/go-event/O2NextGen.GoEvent.Api/Properties/launchSettings.json index 7c253baf..51de27a1 100644 --- a/src/Services/go-event/O2NextGen.GoEvent.Api/Properties/launchSettings.json +++ b/src/Services/go-event/O2NextGen.GoEvent.Api/Properties/launchSettings.json @@ -12,7 +12,7 @@ "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, - "launchUrl": "api/values", + "launchUrl": "swagger", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -20,7 +20,7 @@ "O2NextGen.GoEvent.Api": { "commandName": "Project", "launchBrowser": true, - "launchUrl": "api/values", + "launchUrl": "swagger", "applicationUrl": "https://localhost:5001;http://localhost:5000", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" diff --git a/src/Services/go-event/O2NextGen.GoEvent.Api/Startup.cs b/src/Services/go-event/O2NextGen.GoEvent.Api/Startup.cs index 0a9aeedc..547eadcc 100644 --- a/src/Services/go-event/O2NextGen.GoEvent.Api/Startup.cs +++ b/src/Services/go-event/O2NextGen.GoEvent.Api/Startup.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Swashbuckle.AspNetCore.Swagger; namespace O2NextGen.GoEvent.Api { @@ -19,6 +20,17 @@ public Startup(IConfiguration configuration) public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddSwaggerGen(options => + { + options.DescribeAllEnumsAsStrings(); + options.SwaggerDoc("v1", new Info() + { + Title = "O2NextGen Platform. Go-Event HTTP API", + Version = "v1", + Description = "Go-Event API Service. The service allows you to create events", + TermsOfService = "Terms of Service" + }); + }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -33,8 +45,10 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) app.UseHsts(); } + app.UseSwagger() + .UseSwaggerUI(c => { c.SwaggerEndpoint($"/swagger/v1/swagger.json", "Go-Event API V1"); }); app.UseHttpsRedirection(); app.UseMvc(); } } -} +} \ No newline at end of file