OpenApi 3 custom setup in Spring Boot using springdoc-openapi-ui
by Keith Miller on
So I was migrating over our Spring Boot REST API project from Swagger 2 to OpenApi 3. So far it’s been pretty painless. I found a helper library called springdoc-openapi-ui that is for OpenApi 3 what SwaggerFox is for Swagger 2. That said, there are a few changes to the default setup we needed to support:
Keycloak OAuth2 authentication
API key authenication
A Version: header enabled for every API endpoint
I clearly didn’t want to have to add the Version: header manually to every endpoint manually. I found the following solution that does what I need it to do:
This will get you set up will all three of the requirements, including the Version: header:
Keith Miller's Picture
About Keith Miller
Keith is currently the Vice President of Engineering at Mythical Games.