Swashbuckle adding 200 OK response automatically to generated Swagger file

As vampiire points out in their comment, SwaggerResponseRemoveDefaults is no longer in Swashbuckle. The way to achieve this now is to include both a <response> XML-doc and a [ProducesResponseType()] attribute to the method:

/// ...
/// <response code="201">Returns the newly reserved tickets</response>
/// <response code="400">If the input parameters are invalid</response>
/// ...
[HttpPost]
[Route("reservations")]
[ProducesResponseType(StatusCodes.Status201Created)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
...
public async Task<HttpResponseMessage> ReserveTickets([FromBody] ReserveTicketsRequest reserveTicketRequest)
{
    ...
}

This will remove the default 200 response. It's taken from Microsoft's Swashbuckle documentation on Swashbuckle 5.5.0 and ASP.NET Core 3.1


You can remove the default response (200 OK) by decorating the method with the SwaggerResponseRemoveDefaults attribute.