Is there anyway to represent a void return type using ProducesResponseType attribute with swagger?

Viewed 773

I'm trying to use the [ProducesResponseType] attribute to decorate my API endpoints in Swagger. However I have endpoints that return a status code and nothing else, and I want my Swagger docs to reflect this.

The problem is I can't find a way to make swagger represent the void return type.

Doing something like [ProducesResponseType(StatusCodes.Status400BadRequest)] with no type argument causes swagger to produce an example return type

{
  "type": "string",
  "title": "string",
  "status": 0,
  "detail": "string",
  "instance": "string",
  "additionalProp1": {},
  "additionalProp2": {},
  "additionalProp3": {}
}

I don't want this.

Some of the other things I've tried include:

[ProducesResponseType(typeof(void), StatusCodes.Status400BadRequest)] //Produces the same example return type
[ProducesResponseType(null, StatusCodes.Status400BadRequest)] //Runtime error, value can't be null
0 Answers
Related