Skip to content

Commit 0eb6ec7

Browse files
committed
Test openapi
1 parent 06167a6 commit 0eb6ec7

File tree

2 files changed

+3
-27
lines changed

2 files changed

+3
-27
lines changed

BervProject.WebApi.Boilerplate/BervProject.WebApi.Boilerplate.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<PackageReference Include="Hangfire.PostgreSql" Version="1.20.12" />
3232
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.23.0" />
3333
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
34+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
3435
<PackageReference Include="Microsoft.Azure.ServiceBus" Version="5.2.0" />
3536
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.0" />
3637
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.0">
@@ -42,7 +43,6 @@
4243
<PackageReference Include="NLog" Version="6.0.6" />
4344
<PackageReference Include="NLog.Web.AspNetCore" Version="6.1.0" />
4445
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.0" />
45-
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.0.1" />
4646
</ItemGroup>
4747

4848
<ItemGroup>

BervProject.WebApi.Boilerplate/Program.cs

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
using System;
2-
using System.IO;
3-
using System.Reflection;
41
using Autofac.Extensions.DependencyInjection;
52
using BervProject.WebApi.Boilerplate.ConfigModel;
63
using BervProject.WebApi.Boilerplate.EntityFramework;
@@ -15,7 +12,6 @@
1512
using Microsoft.Extensions.DependencyInjection;
1613
using Microsoft.Extensions.Hosting;
1714
using Microsoft.Extensions.Logging;
18-
using Microsoft.OpenApi.Models;
1915
using NLog.Web;
2016

2117
var builder = WebApplication.CreateBuilder(args);
@@ -56,17 +52,7 @@
5652

5753
builder.Services.AddControllers();
5854
builder.Services.AddApiVersioning();
59-
builder.Services.AddSwaggerGen(options =>
60-
{
61-
var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
62-
options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
63-
options.SwaggerDoc("v1", new OpenApiInfo
64-
{
65-
Version = "v1",
66-
Title = "Boilerplate API",
67-
Description = "An ASP.NET Core Web API"
68-
});
69-
});
55+
builder.Services.AddOpenApi();
7056

7157
var app = builder.Build();
7258

@@ -89,6 +75,7 @@
8975
if (app.Environment.IsDevelopment())
9076
{
9177
app.UseDeveloperExceptionPage();
78+
app.MapOpenApi();
9279
}
9380
else
9481
{
@@ -100,17 +87,6 @@
10087

10188
app.UseAuthorization();
10289

103-
app.UseSwagger(c =>
104-
{
105-
c.RouteTemplate = "api/docs/{documentName}/swagger.json";
106-
});
107-
108-
app.UseSwaggerUI(c =>
109-
{
110-
c.SwaggerEndpoint("/api/docs/v1/swagger.json", "My API V1");
111-
c.RoutePrefix = "api/docs";
112-
});
113-
11490
app.MapDefaultEndpoints();
11591

11692
app.MapControllers();

0 commit comments

Comments
 (0)