Skip to content

Commit 98abf2a

Browse files
committed
update openapi and use DisableHttpMetrics
1 parent f503956 commit 98abf2a

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

OpenReservation.Notification/OpenReservation.Notification.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0-*" />
13-
<PackageReference Include="SendGrid" Version="9.29.1" />
14-
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.8.0" />
15-
<PackageReference Include="WeihanLi.Common" Version="1.0.70-preview-20240911-003223" />
16-
<PackageReference Include="WeihanLi.Web.Extensions" Version="1.11.0" />
12+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
13+
<PackageReference Include="Scalar.AspNetCore" Version="1.2.42" />
14+
<PackageReference Include="SendGrid" Version="9.29.3" />
15+
<PackageReference Include="WeihanLi.Common" Version="1.0.72" />
16+
<PackageReference Include="WeihanLi.Web.Extensions" Version="2.0.0" />
1717
</ItemGroup>
1818

1919
<ItemGroup>

OpenReservation.Notification/Program.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
using OpenReservation.Notification;
2+
using Scalar.AspNetCore;
23
using SendGrid;
34
using WeihanLi.Web.Authentication;
45
using WeihanLi.Web.Extensions;
56

67
var builder = WebApplication.CreateSlimBuilder(args);
78

89
// Add services to the container.
9-
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
10-
builder.Services.AddEndpointsApiExplorer();
11-
builder.Services.AddSwaggerGen();
10+
// OpenApi https://learn.microsoft.com/en-us/aspnet/core/fundamentals/openapi/overview
11+
builder.Services.AddOpenApi();
1212

1313
builder.Services.AddMemoryCache();
1414

@@ -26,20 +26,17 @@
2626
var app = builder.Build();
2727

2828
// Configure the HTTP request pipeline.
29-
if (app.Environment.IsDevelopment())
30-
{
31-
app.UseSwagger();
32-
app.UseSwaggerUI();
33-
}
29+
app.MapOpenApi().ShortCircuit().DisableHttpMetrics();
30+
app.MapScalarApiReference().ShortCircuit().DisableHttpMetrics();
3431

3532
app.UseAuthentication()
3633
.UseAuthorization();
3734

3835
var healthChecks = app.MapGroup("/api/health");
39-
healthChecks.MapGet("/live", () => Results.Ok()).ShortCircuit();
40-
healthChecks.MapGet("/ready", () => Results.Ok()).ShortCircuit();
36+
healthChecks.MapGet("/live", () => Results.Ok()).ShortCircuit().DisableHttpMetrics();
37+
healthChecks.MapGet("/ready", () => Results.Ok()).ShortCircuit().DisableHttpMetrics();
4138

42-
app.MapRuntimeInfo().ShortCircuit();
39+
app.MapRuntimeInfo().ShortCircuit().DisableHttpMetrics();
4340
app.MapPost("/api/notification/{notificationType}", async (NotificationType notificationType, NotificationRequest request, HttpContext context) =>
4441
{
4542
var notification = context.RequestServices.GetRequiredKeyedService<INotification>(notificationType);

0 commit comments

Comments
 (0)