You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, I seem to hit a roadblock. When I start my app, my configuration class, annotated with @EnableSwagger2, kicks in. After my Docket instance is created in this class, DocumentationPluginsBootstrapper.onApplicationEvent.(ContextRefreshedEvent contextRefreshedEvent) kicks in to fire off a scanDocumentation call. Eventually, FieldModelPropertyProvider.beanDescription is called, but beforeFieldModelPropertyProvider.onApplicationEvent, which means FieldModelPropertyProvider.objectMapper is still null. When FieldModelPropertyProvider.beanDescription tries to invoke objectMapper.getSerializationConfig(), the NullPointerException is triggered.
The text was updated successfully, but these errors were encountered:
Unfortunately the codebase I'm working on isn't shareable at the moment.
However, your suspicion seems to be correct - I had a separate @Configuration class that was setting up my ObjectMapper, and it did not have the @EnableWebMvc annotation. After adding it, the application event is successfully fired with the ObjectMapper config, and I no longer see a NullPointerException in FieldModelPropertyProvider.beanDescription!
Are there any guidelines as to which @Configuration classes need the @EnableWebMvc in order to work with the new Swagger 2.0 strategy of Springfox?
@who Its also on my list to document. However, just to help people with the similar issues like you've had, could I ask you to provide a little bit of background, albeit with a contrived example to demonstrate your configuration setup?
Setting up the ObjectMapper has been one of the most contentious issues we've faced in the past. Since this is a different approach, we'd like to document gotchas.