RicoSuter/NSwag

typeof(void) still produces a response type of ProblemDetails

Open

#2.861 geöffnet am 30. Mai 2020

Auf GitHub ansehen
 (6 Kommentare) (9 Reaktionen) (0 zugewiesene Personen)C# (1.189 Forks)batch import
help wantedproject: NSwag.SwaggerGeneration.AspNetCore

Repository-Metriken

Stars
 (6.291 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

According to wiki "To define an operation without a response (i.e. HTTP 204 or 404), use the SwaggerResponseAttribute attribute and typeof(void)". Also according to wiki "SwaggerResponseAttribute(httpAction, type) (not recommended/deprecated, use ASP.NET Core's ProducesResponseTypeAttribute instead)".

So, I use this:

[ProducesResponseType(typeof(void), 404)]

Expected: 404 should have no response body.

Actual:

"404": {
            "description": "Blah blah.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }

Contributor Guide