代码拉取完成,页面将自动刷新
同步操作将从 Gitee 极速下载/swagger-editor 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#! /bin/sh
set -e
BASE_URL=${BASE_URL:-/}
NGINX_ROOT=/usr/share/nginx/html
INDEX_FILE=$NGINX_ROOT/index.html
NGINX_CONF=/etc/nginx/nginx.conf
if [[ "${BASE_URL}" != "/" ]]; then
sed -i "s|location / {|location $BASE_URL {|g" $NGINX_CONF
fi
## Adding env var support for file passed with URL env variable
## When set, URL has priority over SWAGGER_FILE
if [[ "${URL}" ]]; then
sed -i "s|SwaggerEditorBundle({|SwaggerEditorBundle({\n url: '${URL}',|g" $INDEX_FILE
## Adding env var support for swagger file (json or yaml)
elif [[ -f "$SWAGGER_FILE" ]]; then
cp -s "$SWAGGER_FILE" "$NGINX_ROOT"
REL_PATH="/$(basename $SWAGGER_FILE)"
sed -i "s|SwaggerEditorBundle({|SwaggerEditorBundle({\n url: '$REL_PATH',|g" $INDEX_FILE
if [[ -z "$SWAGGER_ROOT" ]]; then
SWAGGER_ROOT="$(dirname $SWAGGER_FILE)"
fi
if [[ "$BASE_URL" != "/" ]]
then
BASE_URL=$(echo $BASE_URL | sed 's/\/$//')
sed -i \
"s|#SWAGGER_ROOT|rewrite ^$BASE_URL(/.*)$ \$1 break;\n #SWAGGER_ROOT|" \
$NGINX_CONF
fi
sed -i "s|#SWAGGER_ROOT|root $SWAGGER_ROOT/;|g" $NGINX_CONF
fi
## Adding env var support for `queryConfigEnabled` core configuration parameter of SwaggerUI
if [[ "${QUERY_CONFIG_ENABLED}" = "true" ]]; then
sed -i "s|queryConfigEnabled: false|queryConfigEnabled: true|" $INDEX_FILE
fi
if [[ "${URL_SWAGGER2_GENERATOR}" ]]; then
if [[ "$URL_SWAGGER2_GENERATOR" != "null" ]]; then
sed -i "s|SwaggerEditorBundle({|SwaggerEditorBundle({\n swagger2GeneratorUrl: '${URL_SWAGGER2_GENERATOR}',|g" $INDEX_FILE
else
sed -i "s|SwaggerEditorBundle({|SwaggerEditorBundle({\n swagger2GeneratorUrl: null,|g" $INDEX_FILE
fi
fi
if [[ "${URL_SWAGGER2_CONVERTER}" ]]; then
if [[ "$URL_SWAGGER2_CONVERTER" != "null" ]]; then
sed -i "s|SwaggerEditorBundle({|SwaggerEditorBundle({\n swagger2ConverterUrl: '${URL_SWAGGER2_CONVERTER}',|g" $INDEX_FILE
else
sed -i "s|SwaggerEditorBundle({|SwaggerEditorBundle({\n swagger2ConverterUrl: null,|g" $INDEX_FILE
fi
fi
if [[ "${URL_OAS3_GENERATOR}" ]]; then
if [[ "$URL_OAS3_GENERATOR" != "null" ]]; then
sed -i "s|SwaggerEditorBundle({|SwaggerEditorBundle({\n oas3GeneratorUrl: '${URL_OAS3_GENERATOR}',|g" $INDEX_FILE
else
sed -i "s|SwaggerEditorBundle({|SwaggerEditorBundle({\n oas3GeneratorUrl: null,|g" $INDEX_FILE
fi
fi
exec nginx -g 'daemon off;'
## Gzip after replacements
#find /usr/share/nginx/html/ -type f -regex ".*\.\(html\|js\|css\)" -exec sh -c "gzip < {} > {}.gz" \;
#
#exec nginx -g 'daemon off;'
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。