在Ubuntu上使用Postman生成接口文档的实用方法
一 使用Postman内置文档功能
二 使用docgen将集合导出为HTML或Markdown
wget https://raw.githubusercontent.com/thedevsaddam/docgen/v3/install.sh -O install.sh && sudo chmod +x install.sh && sudo ./install.sh && rm install.sh
docgen server -f ~/Downloads/Api_Test_postman_collection.json -p 8000
浏览器访问:http://localhost:8000 查看实时HTML文档。docgen build -i ~/Downloads/Api_Test_postman_collection.json -o ~/Downloads/Api_Test_postman_collection.html
docgen build -i ~/Downloads/Api_Test_postman_collection.json -o ~/Downloads/Api_Test_postman_collection.md -m
三 使用Newman生成报告并与CI集成
sudo apt-get update && sudo apt-get install -y nodejs npm
sudo npm install -g newman
newman run ~/Downloads/Api_Test_postman_collection.json \
-e ~/Downloads/postman_environment.json \
-r html --reporter-html-export ~/Downloads/newman-report.html
四 协作与分享实践
五 常见问题与建议