Search code examples
spring-bootjacksonspring-restdocsspring-auto-restdocs

No description found for classes with custom Jackson ObjectMapper


I am coming across an issue with Spring AutoRest Docs. It seems to stem from this code

.alwaysDo<DefaultMockMvcBuilder>(JacksonResultHandlers.prepareJackson(objectMapper))

Full configuration:

    mockMvc = MockMvcBuilders
        .webAppContextSetup(webApplicationContext)
        .alwaysDo<DefaultMockMvcBuilder>(JacksonResultHandlers.prepareJackson(objectMapper))
        .alwaysDo<DefaultMockMvcBuilder>(document("{class-name}/{method-name}",
            Preprocessors.preprocessRequest(Preprocessors.prettyPrint()),
            Preprocessors.preprocessResponse(Preprocessors.prettyPrint())))
        .apply<DefaultMockMvcBuilder>(documentationConfiguration(this.restDocumentation)
            .uris()
            .withScheme("https")
            .withHost("localhost")
            .and().snippets()
            .withDefaults(CliDocumentation.curlRequest(),
                HttpDocumentation.httpRequest(),
                HttpDocumentation.httpResponse(),
                AutoDocumentation.requestFields()
                    .failOnUndocumentedFields(true),
                AutoDocumentation.responseFields()
                    .failOnUndocumentedFields(true),
                AutoDocumentation.pathParameters(),
                AutoDocumentation.requestParameters(),
                AutoDocumentation.description(),
                AutoDocumentation.methodAndPath(),
                AutoDocumentation.section(),
                AutoDocumentation.links()))
        .build()

I have customized jackson a bit and autorest does not seem to like this. When I input my objectMapper I get the following warnings:

No Javadoc found for class java.lang.Object

No Javadoc found for class java.io.Serializable

No description found for constraint com.domain.CLASS: Can't find resource for bundle java.util.PropertyResourceBundle, key com.domain.CLASS.description

I have tried injecting other ways to get at the object mapper including

MappingJackson2HttpMessageConverter
ObjectMapperResolver

I have also tried spinning up a fresh Spring Boot application and came across no errors. If the prepareJackson is removed no more warnings, however, there is no data in the auto generated documents.

I have been stuck on this issue for quite awhile and am not sure how to solve it. Any guidance would be greatly appreciated.


Solution

  • A quick update on this.

    Florian made a GitHub issue about this and everything is fixed in 2.0.6. So just use 2.0.6 and you will be good to go.

    See https://github.com/ScaCap/spring-auto-restdocs/issues/336

    Thank you Florian and the Auto Rest Doc team!