Skip to content

Commit 8e5dbef

Browse files
committed
Add AOT /1
1 parent 333a47a commit 8e5dbef

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

aspnetcore/fundamentals/openapi/samples/9.x/GetDocument.Insider/GetDocument.Insider.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@
66
<ImplicitUsings>enable</ImplicitUsings>
77
</PropertyGroup>
88

9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0" />
11+
</ItemGroup>
12+
913
</Project>

aspnetcore/fundamentals/openapi/samples/9.x/GetDocument.Insider/Program.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,25 @@
22

33
var builder = WebApplication.CreateBuilder(args);
44

5+
builder.Services.AddOpenApi();
6+
57
if (Assembly.GetEntryAssembly()?.GetName().Name != "GetDocument.Insider")
68
{
79
// 'IServiceCollection' does not contain a definition for 'AddDefaults'
8-
// builder.Services.AddDefaults();
10+
builder.Services.AddDefaults();
911
}
1012
var app = builder.Build();
1113

14+
if (app.Environment.IsDevelopment())
15+
{
16+
app.MapOpenApi();
17+
}
18+
1219
var myKeyValue = app.Configuration["MyKey"];
1320

14-
app.MapGet("/", () => myKeyValue);
21+
app.MapGet("/", () => {
22+
return Results.Ok($"The value of MyKey is: {myKeyValue}");
23+
})
24+
.WithName("TestKey");
1525

16-
app.Run();
26+
app.Run();

0 commit comments

Comments
 (0)