Desidero creare la documentazione di Swagger per un set esistente di API RESTful. Ho il seguente requisito:Utilizzo di Javadocs per generare il documento Swagger
- Generare offline Swagger Doc (ho utilizzato http://kongchen.github.io/swagger-maven-plugin/). Questo plugin mi aiuta a generare la documentazione di Swagger durante la compilazione.
- Leggere il Javadoc esistente in modo che possano essere utilizzati nella documentazione di Swagger.
Finora utilizzando il plugin di cui sopra sono stato in grado di raggiungere il punto numero 1. Così, per un metodo REST esistente:
/**
* <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) {
}
sono stato in grado di generare la documentazione Swagger. L'utilizzo di @ApiOperation & @ApiResponses rende la documentazione eccellente.
Tuttavia, la mia domanda è possibile utilizzare Javadoc invece di fare in modo che ogni sviluppatore crei @ApiOperation & @ApiResponses in modo da risparmiare tempo per la mia squadra?
come generare questo documento @raj? il mio progetto è basato su maven ho aggiunto anche la notazione Api, la notazione ApiResonses ma come posso generare qualche aiuto? –
Ho usato "swagger-springmvc" v1.0.2. Quindi ho creato una classe CustomSwaggerConfig con "@ Configuration" e "@EnableSwagger". E in applicationContext.xml ho fatto riferimento a CustomSwaggerConfig. – Raj
non ho primavera sono solo con Maven, struts –