我想为一组现有的RESTful API构建Swagger文档,并有以下要求:
- 离线生成Swagger文档(我使用了http://kongchen.github.io/swagger-maven-plugin/插件)。该插件帮助我在编译时生成Swagger文档。
- 阅读现有的Javadoc,以便它们可以用于Swagger文档。
到目前为止,使用上述插件,我已经能够实现第1点。因此,对于现有的REST方法:
/**
* <p>
* Gets the {@link DisplayPreferenceModel} with the name as provided in the parameter. The preference with the given name defined at the tenant or master level is returned.
* This API gives us the preference if it is eligible for unauthorized access If it is not eligible it throws an Exception saying Authorization required.
* </p>
* @param preferenceName
* - The name of the preference.
* @return {@link DisplayPreferenceModel}
*/
@RequestMapping(method = RequestMethod.GET, value = "/preferences/{preferenceName}")
@ApiOperation(value = "This API gives us the preference if it is eligible for unauthorized access If it is not eligible it throws an Exception saying Authorization required",
notes = "No Notes please", response = DisplayPreferenceModel.class)
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid preferenceName supplied"),
@ApiResponse(code = 404, message = "Display Preference Not Found")
}
)
public DisplayPreferenceModel getDisplayPreference( @PathVariable("preferenceName") final String preferenceName ) {
}
我能够生成 Swagger 文档。@ApiOperation 和 @ApiResponses 的使用使我的文档看起来很棒。
但是,我的问题是:我是否可以使用 Javadocs 来代替让每个开发人员创建 @ApiOperation 和 @ApiResponses,以便为我的团队节省时间?