[英]Automatic generate Swagger documentation from Java
I have this REST service: 我有这个REST服务:
@RestController
public class ContaCorrenteController {
@Autowired
private configCorrenteService service;
@Produces(MediaType.APPLICATION_JSON)
@RequestMapping("/v1/number/{number}/config/{config}/final/{data}")
@GET
public ResponseEntity<Final> Final(
@PathVariable("number") Integer number,
@PathVariable("config") Integer config,
@PathVariable("data") @DateTimeFormat(pattern="yyyyMMdd") LocalDate data) {
Final final = service.consultFinal(number, config, data);
return ResponseEntity.ok(final);
}
@Produces(MediaType.APPLICATION_JSON)
@RequestMapping("/v1/number/{number}/config/{config}/final")
@GET
public ResponseEntity<Final> final(
@PathVariable("number") Integer number,
@PathVariable("config") Integer config) {
Final final = service.consultFinalNow(number, config);
return ResponseEntity.ok(final);
}
}
I need to automatically genarete a REST documentation using this java file. 我需要使用这个java文件自动生成REST文档。 Can I automatically generate a json or yaml to import on Swagger editor or another way to documentation?
我可以自动生成json或yaml以在Swagger编辑器上导入或以其他方式导入文档吗?
You can integrate with SpringFox: 您可以与SpringFox集成:
https://github.com/springfox/springfox https://github.com/springfox/springfox
Which can automatically generate swagger definitions from your Spring-MVC server. 哪个可以从Spring-MVC服务器自动生成swagger定义。 You'll need to add some annotations to effectively document things but it should be quite straight forward.
您需要添加一些注释来有效地记录事物,但它应该非常直接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.