Skip to content

Commit

Permalink
feat(pr: issue-320): include Swashbuckle.AspNetCore v1.1.0 to o2-cgen…
Browse files Browse the repository at this point in the history
… api

Merge pull request #321 from live-dev999/live-dev999/issue320
  • Loading branch information
live-dev999 committed Apr 22, 2022
2 parents 106becc + 9792182 commit ce6f86d
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 @@ -33,6 +33,7 @@ public static IServiceCollection AddRequiredMvcComponents(this IServiceCollectio
services.AddTransient<ApiExceptionFilter>();

var mvcBuilder = services.AddMvcCore(options => { options.Filters.Add<ApiExceptionFilter>(); });
mvcBuilder.AddApiExplorer(); //for swagger
mvcBuilder.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
mvcBuilder.AddJsonFormatters();
return services;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,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 @@ -3,6 +3,7 @@
"O2NextGen.CertificateManagement.Web": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using O2NextGen.CertificateManagement.Api.Setup;
using O2NextGen.CertificateManagement.Api.Helpers;
using O2NextGen.CertificateManagement.Api.IoC;
using Swashbuckle.AspNetCore.Swagger;

[assembly: ApiController]
namespace O2NextGen.CertificateManagement.Api
Expand All @@ -28,6 +29,17 @@ public void ConfigureServices(IServiceCollection services)
{
services.AddRequiredMvcComponents();
services.AddBusiness();
services.AddSwaggerGen(options =>
{
options.DescribeAllEnumsAsStrings();
options.SwaggerDoc("v1",new Info()
{
Title = "O2NextGen Platform. C-Gen HTTP API",
Version = "v1",
Description = "C-Gen API Service. The service allows you to create certificates",
TermsOfService = "Terms of Service"
});
});
services.AddConfigEf(AppConfiguration);
services.ConfigurePOCO<UrlsConfig>(AppConfiguration.GetSection("Urls"));
}
Expand Down Expand Up @@ -58,7 +70,11 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
}

app.UseStaticFiles();

app.UseSwagger()
.UseSwaggerUI(c =>
{
c.SwaggerEndpoint($"/swagger/v1/swagger.json", "C-Gen API V1");
});
app.Use(async (context, next) =>
{
context.Response.OnStarting(() =>
Expand Down

0 comments on commit ce6f86d

Please sign in to comment.