異なるパスの複数のプロジェクトのインタフェースドキュメントをswagger-uiで表示
1、指定したパスの下に空のフォルダnode_を作成app
mkdir node_app;
2,cd node_app
nom init(ずっとenter)
3,expressのインストール
npm install express --save
、indexを作成する.js vim index.js
、コードをindexに貼り付けます.js中var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('Hello World!');});
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});
6,mkdir public
7,git clone
https://github.com/swagger-api/swagger-ui.git
8, swagger-ui dist public
9, index.js
app.use('/static', express.static('public'));
10,node index.js node
11, http://localhost:3000/static /dist/index.html
, , node
npm install forever -g
forever start index.js , forever , ln -s forever 、usr/local/bin/forever
,
public resources, css js resources , public index , index.html index , index。html ../resources/xxxx , index.html http://localhost:3000/static/index; clp, index index.html clp , clp json clp , index.html url :http://localhost:3000/static/clp/swagger.json. :http://localhost:3000/static/clp/index.html ,ok;
, Jenkins json , swagger-ui
Jenkins excude shell
ssh -p 22222 $SWAGGER_URL rm -rf $PUBLIC_ROOT/$JOB_NAME
ssh -p 22222 $SWAGGER_URL mkdir $PUBLIC_ROOT/$JOB_NAME
scp -P 22222 $DEST/api/swagger.json $SWAGGER_URL:$PUBLIC_ROOT/$JOB_NAME/
ssh -p 22222 $SWAGGER_URL cp $INDEX_FILE $PUBLIC_ROOT/$JOB_NAME/
ssh -p 22222 $SWAGGER_URL sh /nodeservice/node_app/replace_str.sh $JOB_NAME
$SWAGGER_URL:
$PUBLIC_ROOT/$JOB_NAME:
$DEST/api/swagger.json: json
$DEST/api/swagger.json :
replace_str.sh:
#! /bin/sh
NAME=$1
exp="'s|http://petstore.swagger.io/v2/swagger.json|http://xxx:3000/$NAME/swagger.json|g'"
sed_cmd="sed -i $exp $PUBLIC_ROOT/$NAME/index.html"
eval $sed_cmd