问题描述
我已经创建了一个端点并为它实现了一个 rest-doc。 https://scacap.github.io/spring-auto-restdocs/
@PostMapping("post-item")
public ResponseEntity<?> postItem(@RequestBody ItemDto dto)
{
...
}
class ItemDto {
String value;
@JsonIgnore
public String getother() {
...
}
}
@BeforeEach
public void setUp(WebApplicationContext webApplicationContext,RestDocumentationContextProvider restDocumentation,@Autowired ObjectMapper objectMapper,@Value("${documentation.test.domain}") String domainName)
{
this.mockmvc = mockmvcBuilders.webAppContextSetup(webApplicationContext)
.alwaysDo(JacksonResultHandlers.prepareJackson(objectMapper))
.apply(documentationConfiguration(restDocumentation)
.uris()
.withScheme("http")
.withHost(domainName)
.withPort(8080)
.and().snippets()...
}
@Test
public void postItem() throws Exception
{
this.mockmvc.perform(post("/post-item")
.contentType(MediaType.APPLICATION_JSON)
.content(gson.toJson(new ItemDto("value"))))
.andExpect(status().isOk());
}
因此,spring rest-docs 生成带有 @JsonIgnore 字段的文档。
Request fields
value
other
有没有办法忽略 spring rest-docs 中的这个 @JsonIgnore 字段?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)