We have decided to look into using websockets along with our RESTful API for streaming events to and from the game clients. Since we are already using Spring Security and Keycloak we wanted to be able to re-use the same accounts and roles that we already have.
So I noticed an issue with our Spring Boot REST API returning strings unquoted and with the wrong
Content-Type
, which will cause issues with clients looking for a JSON response. The underlining
issue is that when Spring sees a String
response, it calls StringHttpMessageConverter
for the
response and not MappingJackson2HttpMessageConverter
.
#PS4share pic.twitter.com/k8TZMyVnXg
— SgtJesusSaves (@sgtjesussaves) March 15, 2020
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