Swagger does not attempt to analyze your code to determine every possible response code. You need to tell it which response codes your action can return:
Get started with Swashbuckle and ASP.NET Core | Microsoft Learn[
^]
Eg:
[HttpGet]
[ProducesResponseType(StatusCodes.Status407ProxyAuthenticationRequired)]
public IActionResult Get()
You can edit your project file to get Visual Studio to analyze your code and issue a warning if your action returns a response code which you haven't documented:
Use web API analyzers | Microsoft Learn[
^]
<PropertyGroup>
<IncludeOpenAPIAnalyzers>true</IncludeOpenAPIAnalyzers>
</PropertyGroup>
You can also use API conventions if your actions almost always return the same set of responses:
Use web API conventions | Microsoft Learn[
^]