1

Spring Auto REST Docs は Spring REST Docs の拡張機能であり、API ドキュメントを生成しています。ドキュメントのように MockMvc をセットアップしています。

同様に、同時に「http://cloud.spring.io/spring-cloud-contract/1.0.x/#_generating_stubs_using_restdocs」で WireMock Stub を生成したい

私はこの例に従っています: https://github.com/spring-cloud-samples/spring-cloud-contract-samples

私の問題は、カスタム設定を作成するとWireMock Stubが作成されず、デフォルトのMockMvc構成を使用すると機能しますが、カスタム構成も必要です。

 @Before
 public void setUp() {
        this.mockMvc = MockMvcBuilders
                .webAppContextSetup(context)
                .alwaysDo(prepareJackson(objectMapper))
                .alwaysDo(document("{class-name}/{method-name}",
                                   preprocessRequest(), commonResponsePreprocessor()))
                .apply(documentationConfiguration(restDocumentation)
                               .uris()
                               .and().snippets()
                               .withDefaults(curlRequest(), httpRequest(), httpResponse(),
                                             requestFields(), responseFields(), pathParameters(),
                                             requestParameters(), description(), methodAndPath(),
                                             section()))
                .build();
}


 @Test
  public void getTemplate() throws Exception {
    this.mockMvc.perform(get("/")
                                 .contentType(MediaType.APPLICATION_JSON)
                                 .accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk())
            .andExpect(jsonPath("result", is("success")))
            .andExpect(jsonPath("version", is("0.0.1")))
            .andDo(WireMockRestDocs.verify().stub("getFlapTemplate"))
            .andDo(MockMvcRestDocumentation.document("getFlapTemplate", SpringCloudContractRestDocs.dslContract()));
}

カスタムの構成で WireMock スタブを生成することは可能ですか?

4

1 に答える 1