File tree Expand file tree Collapse file tree 2 files changed +18
-26
lines changed
src/ProjectTemplates/Web.ProjectTemplates/content/WebApiAot-CSharp Expand file tree Collapse file tree 2 files changed +18
-26
lines changed Original file line number Diff line number Diff line change @@ -27,23 +27,19 @@ public static void Main(string[] args)
2727 #if ( EnableOpenAPI )
2828 todosApi . MapGet ( "/" , ( ) => sampleTodos )
2929 . WithName ( "GetTodos" ) ;
30- #else
31- todosApi . MapGet ( "/" , ( ) => sampleTodos ) ;
32- #endif
3330
34- #if ( EnableOpenAPI )
35- todosApi . MapGet ( "/{id}" , ( int id ) =>
31+ todosApi . MapGet ( "/{id}" , Results < Ok < Todo > , NotFound > ( int id ) =>
3632 sampleTodos . FirstOrDefault ( a => a . Id == id ) is { } todo
37- ? Results . Ok ( todo )
38- : Results . NotFound ( ) )
39- . WithName ( "GetTodoById" )
40- . Produces < Todo > ( StatusCodes . Status200OK )
41- . Produces ( StatusCodes . Status404NotFound ) ;
33+ ? TypedResults . Ok ( todo )
34+ : TypedResults . NotFound ( ) )
35+ . WithName ( "GetTodoById" ) ;
4236 #else
43- todosApi . MapGet ( "/{id}" , ( int id ) =>
37+ todosApi . MapGet ( "/" , ( ) => sampleTodos ) ;
38+
39+ todosApi . MapGet ( "/{id}" , Results < Ok < Todo > , NotFound > ( int id ) =>
4440 sampleTodos . FirstOrDefault ( a => a . Id == id ) is { } todo
45- ? Results . Ok ( todo )
46- : Results . NotFound ( ) ) ;
41+ ? TypedResults . Ok ( todo )
42+ : TypedResults . NotFound ( ) ) ;
4743 #endif
4844
4945 app . Run ( ) ;
Original file line number Diff line number Diff line change 3333#if ( EnableOpenAPI )
3434todosApi . MapGet ( "/" , ( ) => sampleTodos )
3535 . WithName ( "GetTodos" ) ;
36- #else
37- todosApi . MapGet ( "/" , ( ) => sampleTodos ) ;
38- #endif
3936
40- #if ( EnableOpenAPI )
41- todosApi . MapGet ( "/{id}" , ( int id ) =>
37+ todosApi . MapGet ( "/{id}" , Results < Ok < Todo > , NotFound > ( int id ) =>
4238 sampleTodos . FirstOrDefault ( a => a . Id == id ) is { } todo
43- ? Results . Ok ( todo )
44- : Results . NotFound ( ) )
45- . WithName ( "GetTodoById" )
46- . Produces < Todo > ( StatusCodes . Status200OK )
47- . Produces ( StatusCodes . Status404NotFound ) ;
39+ ? TypedResults . Ok ( todo )
40+ : TypedResults . NotFound ( ) )
41+ . WithName ( "GetTodoById" ) ;
4842#else
49- todosApi . MapGet ( "/{id}" , ( int id ) =>
43+ todosApi . MapGet ( "/" , ( ) => sampleTodos ) ;
44+
45+ todosApi . MapGet ( "/{id}" , Results < Ok < Todo > , NotFound > ( int id ) =>
5046 sampleTodos . FirstOrDefault ( a => a . Id == id ) is { } todo
51- ? Results . Ok ( todo )
52- : Results . NotFound ( ) ) ;
47+ ? TypedResults . Ok ( todo )
48+ : TypedResults . NotFound ( ) ) ;
5349#endif
5450
5551app . Run ( ) ;
You can’t perform that action at this time.
0 commit comments