【问题标题】:Spring Rest docs attributesSpring Rest 文档属性
【发布时间】:2016-04-28 23:33:12
【问题描述】:

我尝试使用here, 中描述的属性方法 但它不被认可。也无法识别方法键。

我是否缺少静态导入?

我的代码:

MvcResult result = mockMvc.perform(post(URL_PREFIX + "/scripts/")
     .contentType(MediaType.APPLICATION_JSON)
     .content(asJsonString(script)))
     .andExpect(status().is(HttpStatus.CREATED.value()))
     .andExpect(content().contentTypeCompatibleWith(MediaTypes.HAL_JSON))
     .andDo(document("create-script-example"
     , links(
        linkWithRel("self").description("Link self"),
        linkWithRel("script").description("Link to the created script resource")),
     responseFields(
        attributes(
           key("title").value("Fields for user creation")),
        fieldWithPath("_links").description("The available links"),
        fieldWithPath("name").description("the name of the created script"),
        fieldWithPath("domain").description("the domain of created the script").optional(),
        fieldWithPath("script").description("the code in Groovy format of the created script"))
     , requestFields(
       fieldWithPath("id").description("the id of the script to create, should be null"),
       fieldWithPath("name").description("the name of the script to create"),
       fieldWithPath("domain").description("the domain of the script to create"),
       fieldWithPath("script").description("the code in Groovy format of the script to create")
)))
.andReturn();

【问题讨论】:

    标签: spring-restdocs


    【解决方案1】:

    我找到了答案: 导入静态 org.springframework.restdocs.sn-p.Attributes.attributes; 导入静态 org.springframework.restdocs.sn-p.Attributes.key;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-12-01
      • 1970-01-01
      • 2014-01-29
      • 2021-07-29
      • 1970-01-01
      • 2019-12-28
      • 2012-08-01
      相关资源
      最近更新 更多