File tree Expand file tree Collapse file tree 2 files changed +1
-26
lines changed
src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp Expand file tree Collapse file tree 2 files changed +1
-26
lines changed Original file line number Diff line number Diff line change @@ -14,19 +14,15 @@ public static void Main(string[] args)
1414 options . SerializerOptions . TypeInfoResolverChain . Insert ( 0 , AppJsonSerializerContext . Default ) ;
1515 } ) ;
1616
17- #if ( EnableOpenAPI )
1817 // Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
1918 builder . Services . AddOpenApi ( ) ;
20- #endif
2119
2220 var app = builder . Build ( ) ;
2321
24- #if ( EnableOpenAPI )
2522 if ( app . Environment . IsDevelopment ( ) )
2623 {
2724 app . MapOpenApi ( ) ;
2825 }
29- #endif
3026
3127 var sampleTodos = new Todo [ ] {
3228 new ( 1 , "Walk the dog" ) ,
@@ -37,7 +33,7 @@ public static void Main(string[] args)
3733 } ;
3834
3935 var todosApi = app . MapGroup ( "/todos" ) ;
40- #if ( EnableOpenAPI )
36+
4137 todosApi . MapGet ( "/" , ( ) => sampleTodos )
4238 . WithName ( "GetTodos" ) ;
4339
@@ -46,14 +42,6 @@ public static void Main(string[] args)
4642 ? TypedResults . Ok ( todo )
4743 : TypedResults . NotFound ( ) )
4844 . 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
5745
5846 app . Run ( ) ;
5947 }
Original file line number Diff line number Diff line change 88 options . SerializerOptions . TypeInfoResolverChain . Insert ( 0 , AppJsonSerializerContext . Default ) ;
99} ) ;
1010
11- #if ( EnableOpenAPI )
1211// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
1312builder . Services . AddOpenApi ( ) ;
14- #endif
1513
1614var app = builder . Build ( ) ;
1715
18- #if ( EnableOpenAPI )
1916if ( app . Environment . IsDevelopment ( ) )
2017{
2118 app . MapOpenApi ( ) ;
2219}
23- #endif
2420
2521var sampleTodos = new Todo [ ] {
2622 new ( 1 , "Walk the dog" ) ,
3127} ;
3228
3329var todosApi = app . MapGroup ( "/todos" ) ;
34- #if ( EnableOpenAPI )
3530todosApi . MapGet ( "/" , ( ) => sampleTodos )
3631 . WithName ( "GetTodos" ) ;
3732
4035 ? TypedResults . Ok ( todo )
4136 : TypedResults . NotFound ( ) )
4237 . 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
5138
5239app . Run ( ) ;
5340
You can’t perform that action at this time.
0 commit comments