Documenting role based authentication with Swagger

Alexander Wichmann Carlsen
1 min readSep 4, 2019

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 IOperationFilter

And that is it, you have now auto documented every role required across your API.
The swagger docs will look like the following.

--

--

Alexander Wichmann Carlsen
Alexander Wichmann Carlsen

No responses yet