Skip to content

Commit 99c03cf

Browse files
authored
Merge pull request #3179 from franzwong/master
Copy swagger.json to nginx directory
2 parents f6e921f + 071307c commit 99c03cf

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ docker run -p 80:8080 swaggerapi/swagger-ui
4040

4141
Will start nginx with swagger-ui on port 80.
4242

43+
Or you can provide your own swagger.json on your host
44+
45+
```
46+
docker run -p 80:8080 -e "SWAGGER_JSON=/foo/swagger.json" -v /bar:/foo swaggerapi/swagger-ui
47+
```
48+
4349
##### Prerequisites
4450
- Node 6.x
4551
- NPM 3.x

docker-run.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
set -e
44

5-
INDEX_FILE=/usr/share/nginx/html/index.html
5+
NGINX_ROOT=/usr/share/nginx/html
6+
INDEX_FILE=$NGINX_ROOT/index.html
67

78
replace_in_index () {
89
if [ "$1" != "**None**" ]; then
@@ -30,8 +31,10 @@ if [ "$OAUTH_ADDITIONAL_PARAMS" != "**None**" ]; then
3031
fi
3132

3233
if [[ -f $SWAGGER_JSON ]]; then
33-
sed -i "s|http://petstore.swagger.io/v2/swagger.json|swagger.json|g" $INDEX_FILE
34-
sed -i "s|http://example.com/api|swagger.json|g" $INDEX_FILE
34+
cp $SWAGGER_JSON $NGINX_ROOT
35+
REL_PATH="/$(basename $SWAGGER_JSON)"
36+
sed -i "s|http://petstore.swagger.io/v2/swagger.json|$REL_PATH|g" $INDEX_FILE
37+
sed -i "s|http://example.com/api|$REL_PATH|g" $INDEX_FILE
3538
else
3639
sed -i "s|http://petstore.swagger.io/v2/swagger.json|$API_URL|g" $INDEX_FILE
3740
sed -i "s|http://example.com/api|$API_URL|g" $INDEX_FILE

0 commit comments

Comments
 (0)