我必须从 yaml 文件生成代码,在我放置的 swagger maven 插件中:
<configOptions>
<java8>true</java8>
<sourceFolder>src/main/java</sourceFolder>
<interfaceOnly>true</interfaceOnly>
<dateLibrary>java8</dateLibrary>
<singleContentTypes>true</singleContentTypes>
</configOptions>
即使它说 iinterfaceOnly>true 但是 codegen 生成一个接口(interface),默认实现如下:
@ApiOperation(value = "", nickname = "billetsFichiersHealthGet", notes = "Obtient l'état de santé de l'API. ", tags={ })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "OK"),
@ApiResponse(code = 200, message = "Erreur", response = Error.class) })
@RequestMapping(value = "/bills/health",
produces = "application/json",
consumes = "",
method = RequestMethod.GET)
default ResponseEntity<Void> billetsFichiersHealthGet() {
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
} else {
log.warn("ObjectMapper or HttpServletRequest not configured in default BilletsApi interface so no example is generated");
}
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
如何禁用默认接口(interface)方法的生成,只在接口(interface)中定义而不是默认实现。
当我删除以下两个标签时它会起作用
<java8>true</java8>
<dateLibrary>java8</dateLibrary>
但是我的模型正在使用 localdatetime,所以我应该在 java8 上并且不能真正删除这两个标签
有什么想法吗?
最佳答案
请尝试:
<configOptions>
<dateLibrary>java8</dateLibrary>
<java8>true</java8>
<defaultInterfaces>false</defaultInterfaces>
</configOptions>
关于java - 使用 swagger-codegen maven 插件生成代码时删除默认实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56081153/