unchase / Unchase.Swashbuckle.AspNetCore.Extensions

:hammer: A library contains a bunch of extensions (filters) for Swashbuckle.AspNetCore.
https://www.nuget.org/packages/Unchase.Swashbuckle.AspNetCore.Extensions
Apache License 2.0
115 stars 16 forks source link

ChangeAllResponsesByHttpStatusCode just for description doesn't work. #37

Open NArnott opened 2 months ago

NArnott commented 2 months ago

I would like to be able to just enforce descriptions for status codes. e.g.:

ChangeAllResponsesByHttpStatusCode(StatusCodes.Status404NotFound, "BadRequest. One or more inputs are invalid.");

I'd assume this should be supported because responseExampleOption and responseExample default to none/null. However, this doesn't work.

First, it requires a generic argument even when no responseExample is passed, which makes no sense. But ok, I tried

ChangeAllResponsesByHttpStatusCode<object>(StatusCodes.Status404NotFound, "BadRequest. One or more inputs are invalid.");

But then I get this error:

InvalidOperationException: A suitable constructor for type 'Unchase.Swashbuckle.AspNetCore.Extensions.Filters.ChangeResponseByHttpStatusCodeDocumentFilter`1[System.Object]' could not be located. Ensure the type is concrete and all parameters of a public constructor are either registered as services or passed as arguments. Also ensure no extraneous arguments are provided.

A new overload for ChangeAllResponsesByHttpStatusCode that just handles descriptions would be nice.