既存の RESTful API セットの Swagger ドキュメントを作成したいと考えています。次の要件があります。
- Swagger Doc をオフラインで生成します (私はhttp://kongchen.github.io/swagger-maven-plugin/を使用しました)。このプラグインは、コンパイル時に Swagger ドキュメントを生成するのに役立ちます。
- Swagger ドキュメントで使用できるように、既存の Javadoc を読み取ります。
これまでのところ、上記のプラグインを使用してポイント 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 を使用すると、ドキュメントの見栄えが良くなります。
ただし、私の質問は、チームの時間を節約するために、すべての開発者に @ApiOperation と @ApiResponses を作成させる代わりに、Javadocs を使用できるかということです。