在Ubuntu上使用Swagger进行接口测试,你可以按照以下步骤进行操作:
首先,你需要在Ubuntu上安装Node.js和npm。你可以通过以下命令来安装:
sudo apt update
sudo apt install -y nodejs npm
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
npm install -g http-server
http-server -p 8080
现在,你可以在浏览器中访问http://localhost:8080
来使用Swagger Editor。
wget https://github.com/swagger-api/swagger-ui/archive/refs/tags/v3.48.0.tar.gz
tar -xvf v3.48.0.tar.gz
cd swagger-ui-3.48.0
npm install
npm install -g http-server
http-server -p 8081
现在,你可以在浏览器中访问http://localhost:8081
来使用Swagger UI。
Swagger Editor:默认情况下,Swagger Editor会加载https://petstore.swagger.io/v2/swagger.json
。你可以通过编辑index.html
文件来更改默认的Swagger规范文件路径。
Swagger UI:在Swagger UI中,你可以通过输入框来输入你的Swagger规范文件(通常是swagger.yaml
或swagger.json
)的URL,然后点击“Explore”按钮来加载和测试你的API接口。
swagger.yaml
或swagger.json
文件。以上步骤应该可以帮助你在Ubuntu上成功安装和配置Swagger,并进行接口测试。如果在安装过程中遇到问题,可以参考相关的官方文档或社区论坛寻求帮助。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:如何在Linux上使用Swagger进行API测试