我对 SpringRestDoc spring-restdocs-mockmvc 版本 2.0.0.RELEASE 有以下问题
org.springframework.restdocs.snippet.SnippetException:在有效负载中找不到具有以下路径的字段:[listName[].k1]
结果是 Body = {"listName":[{"k1":null},{"k1":"text"}]}
这是其余的服务
@EnableAutoConfiguration
@RestController
public class Docs
{
@GetMapping("/bug")
public ResponseEntity bug()
{
return ResponseEntity.ok(
new Object()
{
public List listName = Arrays.asList(
new Object(){
public String k1 = null;
}
, new Object(){
public String k1 = "text";
}
);
}
);
}
public static void main(String[] args) throws Exception
{
SpringApplication.run(Docs.class, args);
}
Run Code Online (Sandbox Code Playgroud)
这是生成文档的测试类
public class DocsTest
{
@Rule
public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
@Autowired
private …Run Code Online (Sandbox Code Playgroud)