簡介
Swagger UI是目前最流行的RestFul接口API文檔和測(cè)試工具。
編譯和測(cè)試方式
1.選擇操作環(huán)境
本文選用華為鯤鵬云服務(wù)ECS KC1實(shí)例做測(cè)試
2.配置編譯環(huán)境
1)Swagger UI依賴于nodejs,因此先安裝nodejs。
cd /usr/local/src
wget https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-arm64.tar.xz
tar -xvf node-v10.16.0-linux-arm64.tar.xz
ln -s /usr/local/src/node-v10.16.0-linux-arm64/bin/node /usr/local/bin/node
ln -s /usr/local/src/node-v10.16.0-linux-arm64/bin/npm /usr/local/bin/npm
2)Swagger UI需要由http-server啟動(dòng)運(yùn)行,因此需要安裝http-server。
npm install -g http-server
ln -s /usr/local/src/node-v10.16.0-linux-arm64/bin/http-server /usr/local/bin/http-server
3)下載和安裝Swagger UI,選用的驗(yàn)證Swagger UI版本為“2.0.24”。
cd /usr/local/src
wget https://github.com/swagger-api/swagger-ui/archive/v2.0.24.tar.gz
tar -xvf v2.0.24.tar.gz
3.測(cè)試已完成編譯的軟件
進(jìn)入Swagger UI軟件解壓的目錄,執(zhí)行http-server運(yùn)行。
cd /usr/local/src/swagger-ui-2.0.24/
http-server
回顯內(nèi)容如下:
Starting up http-server, serving ./
Available on:
http://127.0.0.1:8081
http://192.168.1.140:8081
已知問題匯總
問題描述:
安裝http-server過程中提示如下錯(cuò)誤:
npm ERR! Unexpected end of JSON input while parsing near '...ect.js":"*","mocha":"'
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-07-04T02_59_09_022Z-debug.log
問題原因:解析其中一個(gè)json格式的緩存文件時(shí)發(fā)生錯(cuò)誤。
解決方法:
清除緩存,重新設(shè)置npm倉庫。
npm cache clean --force
npm set registry https://registry.npmjs.org/
最新文章
- 華為云CodeArts API_接口遷移_接口導(dǎo)入
- 華為云CodeArts API_如何在CodeArts API中設(shè)置API的設(shè)計(jì)規(guī)范?
- 華為云CodeArts API_APIFirst_API設(shè)計(jì)_API設(shè)計(jì)規(guī)范_API全生命周期
- Astro低代碼平臺(tái)關(guān)鍵能力_低代碼開發(fā)平臺(tái)_華為云Astro-華為云
- 如何在測(cè)試計(jì)劃服務(wù)中使用關(guān)鍵字?
- 華為云CodeArts API_什么是API_APIFirst_API設(shè)計(jì)