Skip to content

Commit 9674e32

Browse files
committed
Revert "TEMP COMMIT - Removing EnableOpenAPI flags to find out why tests fail"
This reverts commit 63cf302.
1 parent 63cf302 commit 9674e32

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@ public static void Main(string[] args)
1414
options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default);
1515
});
1616

17+
#if (EnableOpenAPI)
1718
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
1819
builder.Services.AddOpenApi();
20+
#endif
1921

2022
var app = builder.Build();
2123

24+
#if (EnableOpenAPI)
2225
if (app.Environment.IsDevelopment())
2326
{
2427
app.MapOpenApi();
2528
}
29+
#endif
2630

2731
var sampleTodos = new Todo[] {
2832
new(1, "Walk the dog"),
@@ -33,7 +37,7 @@ public static void Main(string[] args)
3337
};
3438

3539
var todosApi = app.MapGroup("/todos");
36-
40+
#if (EnableOpenAPI)
3741
todosApi.MapGet("/", () => sampleTodos)
3842
.WithName("GetTodos");
3943

@@ -42,6 +46,14 @@ public static void Main(string[] args)
4246
? TypedResults.Ok(todo)
4347
: TypedResults.NotFound())
4448
.WithName("GetTodoById");
49+
#else
50+
todosApi.MapGet("/", () => sampleTodos);
51+
52+
todosApi.MapGet("/{id}", Results<Ok<Todo>, NotFound> (int id) =>
53+
sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo
54+
? TypedResults.Ok(todo)
55+
: TypedResults.NotFound());
56+
#endif
4557

4658
app.Run();
4759
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@
88
options.SerializerOptions.TypeInfoResolverChain.Insert(0, AppJsonSerializerContext.Default);
99
});
1010

11+
#if (EnableOpenAPI)
1112
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
1213
builder.Services.AddOpenApi();
14+
#endif
1315

1416
var app = builder.Build();
1517

18+
#if (EnableOpenAPI)
1619
if (app.Environment.IsDevelopment())
1720
{
1821
app.MapOpenApi();
1922
}
23+
#endif
2024

2125
var sampleTodos = new Todo[] {
2226
new(1, "Walk the dog"),
@@ -27,6 +31,7 @@
2731
};
2832

2933
var todosApi = app.MapGroup("/todos");
34+
#if (EnableOpenAPI)
3035
todosApi.MapGet("/", () => sampleTodos)
3136
.WithName("GetTodos");
3237

@@ -35,6 +40,14 @@
3540
? TypedResults.Ok(todo)
3641
: TypedResults.NotFound())
3742
.WithName("GetTodoById");
43+
#else
44+
todosApi.MapGet("/", () => sampleTodos);
45+
46+
todosApi.MapGet("/{id}", Results<Ok<Todo>, NotFound> (int id) =>
47+
sampleTodos.FirstOrDefault(a => a.Id == id) is { } todo
48+
? TypedResults.Ok(todo)
49+
: TypedResults.NotFound());
50+
#endif
3851

3952
app.Run();
4053

0 commit comments

Comments
 (0)