以下是在Linux下高效配置Swagger的方法:
sudo apt update && sudo apt install -y docker.io,启动并设置开机自启。docker pull swaggerapi/swagger-editor:v4.6.0(编辑器)docker pull swaggerapi/swagger-ui:v4.15.5(UI界面)。docker run -d -p 38080:8080 swaggerapi/swagger-editor:v4.6.0docker run -d -p 38081:8080 swaggerapi/swagger-ui:v4.15.5http://服务器IP:端口访问。sudo apt install -y nodejs npm。sudo apt install -y openjdk-11-jdk maven。wget https://github.com/swagger-api/swagger-editor/archive/refs/tags/v3.16.1.tar.gz,tar -xvf v3.16.1.tar.gz。cd swagger-editor-3.16.1 && npm install。node ./bin/swagger-editor.js,访问http://localhost:8080。wget https://github.com/swagger-api/swagger-ui/archive/refs/tags/v3.16.1.tar.gz。/var/www/html:sudo cp -r swagger-ui-3.16.1/* /var/www/html/。sudo nano /etc/nginx/sites-available/default,设置root /var/www/html,重启Nginx。http://localhost/swagger-ui.html。pom.xml中引入springdoc-openapi-starter-webmvc-ui(最新版)。SwaggerConfig类,添加@OpenAPIDefinition注解定义文档信息。http://localhost:8080/swagger-ui/查看。