在Linux中生成交互式API文档,通常有以下两种常见方式:
pom.xml中添加springfox-swagger2和springfox-swagger-ui依赖。@EnableSwagger2注解,指定API的基本信息、扫描的包路径等。@Api、@ApiOperation等注解描述API。http://localhost:8080/swagger-ui.html查看交互式文档。npm安装swagger-jsdoc和swagger-ui-express。swagger.yaml或swagger.json文件,用OpenAPI规范定义API。swagger-ui-express,将规范文件作为参数传入setup方法。http://localhost:3000/api-docs(端口可自定义)查看文档。