以下是一些CentOS上使用Swagger的案例分享:
curl -sL https://rpm.nodesource.com/setup_14.x | sudo -E bash -
,再sudo yum install -y nodejs
。git clone https://github.com/swagger-api/swagger-ui.git
,然后cd
到项目目录安装依赖npm install
。index.js
文件配置Swagger UI,如指定静态文件目录等,然后node index.js
启动,通过浏览器访问http://localhost:3000
查看。sudo yum install -y java-1.8.0-openjdk-devel
和sudo yum install -y maven
安装。pom.xml
中添加springfox-swagger2
和springfox-swagger-ui
依赖。@EnableSwagger2
注解等配置相关信息。http://localhost:8080/swagger-ui.html
访问Swagger UI查看和测试API文档。