Skip to content

Commit 0891a99

Browse files
committed
Add OpenAPI services to Program.Main.cs
1 parent a442d80 commit 0891a99

File tree

1 file changed

+12
-0
lines changed
  • src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp

1 file changed

+12
-0
lines changed

src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp/Program.Main.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,20 @@ public static void Main(string[] args)
1515
options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default);
1616
});
1717

18+
#if (EnableOpenAPI)
19+
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
20+
builder.Services.AddOpenApi();
21+
#endif
22+
1823
var app = builder.Build();
1924

25+
#if (EnableOpenAPI)
26+
if (app.Environment.IsDevelopment())
27+
{
28+
app.MapOpenApi();
29+
}
30+
#endif
31+
2032
var sampleTodos = new Todo[] {
2133
new(1, "Walk the dog"),
2234
new(2, "Do the dishes", DateOnly.FromDateTime(DateTime.Now)),

0 commit comments

Comments
 (0)