File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
aspnetcore/fundamentals/openapi/samples/9.x/GetDocument.Insider Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 66 <ImplicitUsings >enable</ImplicitUsings >
77 </PropertyGroup >
88
9+ <ItemGroup >
10+ <PackageReference Include =" Microsoft.AspNetCore.OpenApi" Version =" 9.0.0" />
11+ </ItemGroup >
12+
913</Project >
Original file line number Diff line number Diff line change 22
33var builder = WebApplication . CreateBuilder ( args ) ;
44
5+ builder . Services . AddOpenApi ( ) ;
6+
57if ( 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}
1012var app = builder . Build ( ) ;
1113
14+ if ( app . Environment . IsDevelopment ( ) )
15+ {
16+ app . MapOpenApi ( ) ;
17+ }
18+
1219var 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 ( ) ;
You can’t perform that action at this time.
0 commit comments