Closed PBonvang closed 3 years ago
Hello, Thank you for your comment :)
Actually, AutoWrapper provides a few Models for you to use as the response shape. You can see them here: https://github.com/proudmonkey/AutoWrapper/tree/master/src/AutoWrapper/Models
In your example, you could do:
[ProducesResponseType(typeof(ApiResultResponse<MyModel>), StatusCodes.Status200OK)]
Note that it was my intent to just expose the Message
and the Result
metadata for the response as others are kind of redundant to show.
Hi again :)
Thank you for the fast response. That seems like what I was looking for :) 👍 It might have been nice to have the status code as well, but as it can be gotten from context I don't see it as a necessity.
What is the easiest way to tell swagger that ALL responses are wrapped by ResponseWrapper ?
Currently ALL Api endpoints have to be annotated with
[ProducesResponseType(typeof(ApiResultResponse<MyModel>), StatusCodes.Status200OK)]
Hi :)
After implementing AutoWrapper I still wish to show the result type in the Swagger doc, so my consumers know what to expect. Currently it's only showing the ApiResponse model.
I might have overlooked something, is there an easy way to do so? Else my suggestion is to create a ApiResponse with a type input, my current workaround:
Then in my controller I can use:
[ProducesResponseType(typeof(ApiResponse<MyModel>), StatusCodes.Status200OK)]
Resulting in:
As this seems super easy to implement from my very inexperienced POV, I thought why not have it in the package it self instead of having to share this between my services.
Please let me know if I'm wrong. I'm here to learn :)