Sitemap

Customizing swagger-ui: Logout Action

Feb 14, 2021

With OpenAPI you can define so called security schemas. This section is used to define your authentication and authorization flows.

Maybe you have already noticed the Logout button within the authorize modal. If not you can find it at PetStore when clicking on the Authorize button and setting a value the logout button appears:

Press enter or click to view image in full size

This button is used to clear authentication values provided by the user. We can use this to hook into and run custom logic.
For example we could use this to call a logout endpoint.
To archive this the plugin system of swagger-ui can be used to wrap the logout redux action.
The action is called with the keys of the security schemas to log out of.

swagger-ui custom logout plugin

Happy Coding!

--

--

Mathis Michel
Mathis Michel

Written by Mathis Michel

22 year old software developer.

No responses yet

Morty Proxy This is a proxified and sanitized view of the page, visit original site.