0

我遇到了 Spring AutoRest Docs 的问题。似乎源于这段代码

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

完整配置:

    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()

我已经对杰克逊进行了一些定制,而 autorest 似乎不喜欢这样。当我输入 my 时objectMapper,我收到以下警告:

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

我尝试注入其他方法来获取对象映射器,包括

MappingJackson2HttpMessageConverter
ObjectMapperResolver

我也尝试过启动一个新的 Spring Boot 应用程序并且没有遇到任何错误。但是,如果prepareJackson删除没有更多警告,则自动生成的文档中没有数据。

我已经在这个问题上停留了很长一段时间,不知道如何解决它。任何指导将不胜感激。

4

1 回答 1

0

对此进行快速更新。

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!

于 2019-07-19T22:12:54.163 回答