Skip to content

Commit 3529e09

Browse files
Repro for 204 status code not being documented
1 parent a5edf9c commit 3529e09

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

Controllers/HomeController.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
using Microsoft.AspNetCore.Mvc;
1+
using System;
2+
using Microsoft.AspNetCore.Mvc;
23

34
namespace Repro.Controllers
45
{
6+
[ApiExplorerSettings(IgnoreApi = false, GroupName = nameof(HomeController))]
7+
[Route("Home")]
58
public class HomeController : Controller
69
{
7-
public string Index()
10+
[HttpGet]
11+
public string? Index()
812
{
9-
return "Hello !";
13+
if (new Random().Next(100) > 50)
14+
{
15+
return "Hello !";
16+
}
17+
18+
return null;
1019
}
1120
}
1221
}

Program.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
using System;
12
using Microsoft.AspNetCore.Hosting;
3+
using Microsoft.AspNetCore.Mvc.ApiExplorer;
4+
using Microsoft.Extensions.DependencyInjection;
25
using Microsoft.Extensions.Hosting;
36

47
namespace Repro
@@ -7,7 +10,19 @@ public class Program
710
{
811
public static void Main(string[] args)
912
{
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+
}
1126
}
1227

1328
public static IHostBuilder CreateHostBuilder(string[] args) =>

0 commit comments

Comments
 (0)