想象我有下一个类
public class MyDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String id;
private Map<String, String> names;
// public Getters and Setters
}
当我使用下一个代码用 Spring 记录它时
private static FieldDescriptor[] myDTOFields() {
return new FieldDescriptor[] {
fieldWithPath("id").description("id description"),
fieldWithPath("names").description("Names description") };
}
它不起作用,我收到一个错误。
org.springframework.restdocs.snippet.SnippetException: The following parts of the payload were not documented:
{ "names" : { "en" : "test" } }
那么我如何用 spring 文档记录 java.util.Map 呢?
谢谢 :)
最佳答案
作为 described in the documentation ,您可以为此使用 PayloadDocumentation.subsectionWithPath(“names”)
。这意味着 REST Docs 认为 names
及其包含的所有内容都已记录在案。
关于spring - 我如何使用 spring 文档记录 java.util.Map,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47401195/