Skip to content

Commit

Permalink
feat(pr: task-327): include Swashbuckle.AspNetCore v1.1.0 to o2 e-sen…
Browse files Browse the repository at this point in the history
…der api

Merge pull request #328 from live-dev999/live-dev999/issue327
  • Loading branch information
live-dev999 committed Apr 22, 2022
2 parents ce6f86d + 0b7d04b commit 51d52fb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public static IServiceCollection AddRequiredMvcComponents(this IServiceCollectio
options.Filters.Add<ApiExceptionFilter>();
});
mvcBuilder.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

//var mvcBuilder = services.AddMvcCore(options =>
//{
// options.Filters.Add<ApiExceptionFilter>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
</PackageReference>
<PackageReference Include="Serilog.Sinks.File" Version="2.2.0">
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"O2NextGen.ESender.Api": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/values",
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
Expand Down
17 changes: 17 additions & 0 deletions src/Services/e-sender/O2NextGen.ESender.Api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.Extensions.DependencyInjection;
using O2NextGen.ESender.Api.IoC;
using O2NextGen.ESender.Api.Setup;
using Swashbuckle.AspNetCore.Swagger;

namespace O2NextGen.ESender.Api
{
Expand All @@ -21,6 +22,17 @@ public void ConfigureServices(IServiceCollection services)
{
services.AddRequiredMvcComponents();
services.AddBusiness();
services.AddSwaggerGen(options =>
{
options.DescribeAllEnumsAsStrings();
options.SwaggerDoc("v1",new Info()
{
Title = "O2NextGen Platform. E-Sender HTTP API",
Version = "v1",
Description = "E-Sender API Service. The service allows you to send e-mail",
TermsOfService = "Terms of Service"
});
});
services.AddConfigEf(AppConfiguration);
services.ConfigurePOCO<SenderConfig>(AppConfiguration.GetSection("Sender"));
}
Expand All @@ -45,6 +57,11 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
await next.Invoke();
});
app.UseSwagger()
.UseSwaggerUI(c =>
{
c.SwaggerEndpoint($"/swagger/v1/swagger.json", "E-Sender API V1");
});
app.UseAuthentication();
app.UseHttpsRedirection();
app.UseMvc();
Expand Down

0 comments on commit 51d52fb

Please sign in to comment.