File tree 2 files changed +28
-4
lines changed 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change 1
- using Microsoft . AspNetCore . Mvc ;
1
+ using System ;
2
+ using Microsoft . AspNetCore . Mvc ;
2
3
3
4
namespace Repro . Controllers
4
5
{
6
+ [ ApiExplorerSettings ( IgnoreApi = false , GroupName = nameof ( HomeController ) ) ]
7
+ [ Route ( "Home" ) ]
5
8
public class HomeController : Controller
6
9
{
7
- public string Index ( )
10
+ [ HttpGet ]
11
+ public string ? Index ( )
8
12
{
9
- return "Hello !" ;
13
+ if ( new Random ( ) . Next ( 100 ) > 50 )
14
+ {
15
+ return "Hello !" ;
16
+ }
17
+
18
+ return null ;
10
19
}
11
20
}
12
21
}
Original file line number Diff line number Diff line change
1
+ using System ;
1
2
using Microsoft . AspNetCore . Hosting ;
3
+ using Microsoft . AspNetCore . Mvc . ApiExplorer ;
4
+ using Microsoft . Extensions . DependencyInjection ;
2
5
using Microsoft . Extensions . Hosting ;
3
6
4
7
namespace Repro
@@ -7,7 +10,19 @@ public class Program
7
10
{
8
11
public static void Main ( string [ ] args )
9
12
{
10
- CreateHostBuilder ( args ) . Build ( ) . Run ( ) ;
13
+ var host = CreateHostBuilder ( args ) . Build ( ) ;
14
+ var provider = host . Services . GetRequiredService < IApiDescriptionGroupCollectionProvider > ( ) ;
15
+ foreach ( var group in provider . ApiDescriptionGroups . Items )
16
+ {
17
+ foreach ( var item in group . Items )
18
+ {
19
+ Console . WriteLine ( item . RelativePath ) ;
20
+ foreach ( var responseType in item . SupportedResponseTypes )
21
+ {
22
+ Console . WriteLine ( $ " -- { responseType . StatusCode } ") ;
23
+ }
24
+ }
25
+ }
11
26
}
12
27
13
28
public static IHostBuilder CreateHostBuilder ( string [ ] args ) =>
You can’t perform that action at this time.
0 commit comments