Documenting role based authentication with Swagger
In ASP.NET you can use the
AuthorizeAttribute to limit access to your controller endpoints, like so.
Personally, I like to have these documented as part of my API in swagger, but how is this achieved?
It’s elementary my dear watson. We just create an
And that is it, you have now auto documented every role required across your API.
The swagger docs will look like the following.