Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ApiExplorer not aware of HttpNoContentOutputFormatter #28060

Open
jeremyVignelles opened this issue Nov 22, 2020 · 3 comments
Open

ApiExplorer not aware of HttpNoContentOutputFormatter #28060

jeremyVignelles opened this issue Nov 22, 2020 · 3 comments
Labels
affected-few This issue impacts only small number of customers area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-openapi severity-minor This label is used by an internal tool
Milestone

Comments

@jeremyVignelles
Copy link
Contributor

Describe the bug

When a controller method returns null, the HttpNoContentOutputFormatter transforms the status code into a 204 - No Content instead of a 200 - Ok.

However, API explorer does not document this possibility of 204.

To Reproduce

Create a MVC project with a controller.

Create a method that can return a nullable reference type, for example:

public string? Index()

If that method returns null, the status code will be 204, which I assume is expected.

Inspect ApiExplorer's metadata : The 204 status code is not documented.

Minimal diff
Full code

Expected result: 200 and 204 should show up
Actual result : Only 200 is displayed.

Further technical details

  • ASP.NET Core version tested on 2.2 through 5.0
  • Include the output of dotnet --info
$ dotnet --info
SDK .NET (reflétant tous les fichiers global.json) :
 Version:   5.0.100
 Commit:    5044b93829

Environnement d'exécution :
 OS Name:     Windows
 OS Version:  10.0.19042
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.100\

Host (useful for support):
  Version: 5.0.0
  Commit:  cf258a14b7

.NET SDKs installed:
  2.1.802 [C:\Program Files\dotnet\sdk]
  3.1.302 [C:\Program Files\dotnet\sdk]
  5.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and it's version : VS community 2019 version 16.8.2
@mkArtakMSFT mkArtakMSFT added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-API-Explorer enhancement This issue represents an ask for new feature or an enhancement to an existing one labels Nov 23, 2020
@mkArtakMSFT mkArtakMSFT added this to the Backlog milestone Nov 23, 2020
@ghost
Copy link

ghost commented Nov 23, 2020

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@captainsafia captainsafia added affected-few This issue impacts only small number of customers severity-minor This label is used by an internal tool labels Mar 15, 2021 — with ASP.NET Core Issue Ranking
@jeremyVignelles
Copy link
Contributor Author

I think it is very similar to #32375 in the fact that nullability should be used to infer things, and as such, I think it is a good fit for this project : https://github.com/dotnet/aspnetcore/projects/18#card-64653068 as it simplifies the usage of MVC (don't need to declare the 204 type above the method)

What do you think ?

@pranavkm pranavkm added area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Oct 19, 2021
@cremor
Copy link
Contributor

cremor commented Dec 22, 2021

Related:
#4950
#8847
#8855
#9375

@captainsafia captainsafia added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates and removed area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels labels Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affected-few This issue impacts only small number of customers area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-openapi severity-minor This label is used by an internal tool
Projects
None yet
Development

No branches or pull requests

5 participants