在 Debian 上“导出 Swagger 接口”通常是指把 Swagger / OpenAPI 文档 导出成 JSON 或 YAML 文件,或者生成 客户端/服务端代码。下面按常见场景给你说明。
大多数 Swagger 项目都会暴露:
http://IP:端口/v2/api-docs
或
http://IP:端口/v3/api-docs
在 Debian 上用 curl 导出:
curl http://localhost:8080/v2/api-docs -o swagger.json
或 YAML(如果支持):
curl http://localhost:8080/v2/api-docs.yaml -o swagger.yaml
✅ 适用于:
如果你能打开:
http://IP:端口/swagger-ui.html
操作步骤:
swagger.jsonsudo apt update
sudo apt install nodejs npm -y
sudo npm install -g @redocly/openapi-cli
openapi lint swagger.json
如果是远程地址:
openapi lint http://localhost:8080/v2/api-docs
sudo apt install default-jre -y
wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.35/swagger-codegen-cli-3.0.35.jar
java -jar swagger-codegen-cli.jar generate \
-i swagger.json \
-l java \
-o ./client
支持语言:
在 pom.xml 中加入:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
访问:
/v2/api-docs
然后 curl 导出即可。
可告诉我:
我可以直接给你对应命令。