0

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.

tjb
  • 98
  • 8
  • The first two warnings are saying that there is no Javadoc for the two classes in your project. This is expected as those classes are part of the standard library and not of your project. The last warning says that there is no description of the constraint CLASS. None of this hints at any issues with the ObjectMapper. How are your tests looking? Did you follow the steps in https://scacap.github.io/spring-auto-restdocs/#gettingstarted-usage ? – Florian Benz Jun 13 '19 at 12:22
  • 1
    Correct I followed these steps and all my classes / controllers have Javadocs on them. I have also noticed that from 2.0.5 -> 2.0.3 the "No description for constraint message" disappears for _some_ classes...I will try and make a demo project today and reply with it here. – tjb Jun 13 '19 at 14:58
  • 1
    I have seen the same behaviour today after upgrading auto-restdocs in a project from 1.0.10 to 2.0.5. I noticed that the classes which are contained in the warnings are not constraint (annotation) classes. Instead they are model classes. At first glance, this looks like a small bug in spring-auto-restdocs or did I miss something? – Josef Reichardt Jun 18 '19 at 09:41
  • 1
    @FlorianBenz you can find these warnings also in your travis log: https://travis-ci.org/ScaCap/spring-auto-restdocs/jobs/544592362#L2367 – Josef Reichardt Jun 19 '19 at 09:29
  • I am glad I am not the only one seeing this! It makes my tests take forever. @FlorianBenz any updates on this? – tjb Jun 19 '19 at 19:00
  • I will take a look and see if we are printing unnecessary warnings. We always had warnings in there for missing Javadoc. The warnings either mean no Javadoc was found or that there is something broken in the setup. In a lot of cases, Javadoc is either missing intentionally or is not extracted because it is third-party code. I understand that this can be misleading and annoying. Possible solutions are: 1) changing the log level to info or 2) not logging this at all. @TylerBobella Are you really sure that printing the warnings slows down your test? – Florian Benz Jun 22 '19 at 17:39
  • 2
    It is indeed that case that there are more "No description found for constraint " warnings in the latest release. I have created an issue and started a PR https://github.com/ScaCap/spring-auto-restdocs/issues/336 – Florian Benz Jun 23 '19 at 09:03

1 Answers1

0

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!

tjb
  • 98
  • 8