Spring REST controllers and returning JSON strings

Spring REST controllers and returning JSON strings

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.

read more

OpenApi 3 custom setup in Spring Boot using springdoc-openapi-ui

OpenApi 3 custom setup in Spring Boot using springdoc-openapi-ui

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

read more