Skip to content

Commit

Permalink
Merge pull request #3179 from franzwong/master
Browse files Browse the repository at this point in the history
Copy swagger.json to nginx directory
  • Loading branch information
fehguy committed Jun 9, 2017
2 parents f6e921f + 071307c commit 99c03cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -40,6 +40,12 @@ docker run -p 80:8080 swaggerapi/swagger-ui

Will start nginx with swagger-ui on port 80.

Or you can provide your own swagger.json on your host

```
docker run -p 80:8080 -e "SWAGGER_JSON=/foo/swagger.json" -v /bar:/foo swaggerapi/swagger-ui
```

##### Prerequisites
- Node 6.x
- NPM 3.x
Expand Down
9 changes: 6 additions & 3 deletions docker-run.sh
Expand Up @@ -2,7 +2,8 @@

set -e

INDEX_FILE=/usr/share/nginx/html/index.html
NGINX_ROOT=/usr/share/nginx/html
INDEX_FILE=$NGINX_ROOT/index.html

replace_in_index () {
if [ "$1" != "**None**" ]; then
Expand Down Expand Up @@ -30,8 +31,10 @@ if [ "$OAUTH_ADDITIONAL_PARAMS" != "**None**" ]; then
fi

if [[ -f $SWAGGER_JSON ]]; then
sed -i "s|http://petstore.swagger.io/v2/swagger.json|swagger.json|g" $INDEX_FILE
sed -i "s|http://example.com/api|swagger.json|g" $INDEX_FILE
cp $SWAGGER_JSON $NGINX_ROOT
REL_PATH="/$(basename $SWAGGER_JSON)"
sed -i "s|http://petstore.swagger.io/v2/swagger.json|$REL_PATH|g" $INDEX_FILE
sed -i "s|http://example.com/api|$REL_PATH|g" $INDEX_FILE
else
sed -i "s|http://petstore.swagger.io/v2/swagger.json|$API_URL|g" $INDEX_FILE
sed -i "s|http://example.com/api|$API_URL|g" $INDEX_FILE
Expand Down

0 comments on commit 99c03cf

Please sign in to comment.