This commit is contained in:
Justin Yoo 2022-10-24 08:08:01 +00:00
Родитель 50e4574ba4
Коммит c641e2d064
1 изменённых файлов: 24 добавлений и 3 удалений

Просмотреть файл

@ -12,6 +12,10 @@ function usage() {
Default: 'http://localhost:7071/api/'
[-e|--endpoint] OpenAPI document endpoint.
Default: 'swagger.json'
[-o|--output-path] Output directory to store the generated OpenAPI document, relative to the repository root.
Default: 'generated'
[-f|--output-filename] Output filename for the generated OpenAPI document.
Default: 'swagger.json'
[-d|--delay] Delay in second between the function app run and document generation.
Default: 30
[-c|--use-codespaces] Switch indicating whether to use GitHub Codespaces or not.
@ -24,6 +28,8 @@ USAGE
functionapp_path="."
base_uri="http://localhost:7071/api/"
endpoint="swagger.json"
output_path="generated"
output_filename="swagger.json"
delay=30
repository_root=$GITHUB_WORKSPACE
@ -31,6 +37,8 @@ if [[ $# -eq 0 ]]; then
functionapp_path="."
base_uri="http://localhost:7071/api/"
endpoint="swagger.json"
output_path="generated"
output_filename="swagger.json"
delay=30
repository_root=$GITHUB_WORKSPACE
fi
@ -52,6 +60,16 @@ while [[ "$1" != "" ]]; do
endpoint=$1
;;
-o | --output-path)
shift
output_path=$1
;;
-f | --output-filename)
shift
output_filename=$1
;;
-d | --delay)
shift
delay=$1
@ -85,9 +103,14 @@ func start --verbose false &
sleep $delay
request_uri="$(echo "$base_uri" | sed 's:/*$::')/$(echo "$endpoint" | sed 's:^/*::')"
filepath="$repository_root/$(echo "$output_path" | sed 's:/*$::')/$(echo "$output_filename" | sed 's:^/*::')"
if [ ! -d "$repository_root/$output_path" ]; then
mkdir "$repository_root/$output_path"
fi
# Download the OpenAPI document
openapi=$(curl $request_uri)
curl $request_uri > $filepath
# Stop the function app
PID=$(lsof -nP -i4TCP:7071 | grep LISTEN | awk '{print $2}')
@ -96,5 +119,3 @@ if [[ "" != "$PID" ]]; then
fi
cd $current_directory
echo $openapi