以下是一些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文檔。