with and without parameters works
This commit is contained in:
@ -4,14 +4,19 @@
|
||||
REMOVE="0"
|
||||
BUILD="0"
|
||||
EXECUTE="0"
|
||||
while getopts rxbh flag
|
||||
STAGE1="0"
|
||||
STAGE2="0"
|
||||
while getopts rxbh12 flag
|
||||
do
|
||||
case "${flag}" in
|
||||
h)
|
||||
echo "1 ... generator stage 1 (implementation generator)";
|
||||
echo "2 ... generator stage 2 (openapi generator)";
|
||||
echo "r ... remove output directory";
|
||||
echo "b ... build after generating";
|
||||
echo "x ... execute after building";
|
||||
echo "h ... show help";
|
||||
|
||||
;;
|
||||
b)
|
||||
BUILD="1"
|
||||
@ -22,6 +27,12 @@ do
|
||||
x)
|
||||
EXECUTE="1"
|
||||
;;
|
||||
1)
|
||||
STAGE1="1"
|
||||
;;
|
||||
2)
|
||||
STAGE2="1"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
@ -41,31 +52,38 @@ fi
|
||||
# PACKAGE_NAME will be loaded here
|
||||
. ENV
|
||||
|
||||
echo "generate server code and endpoint stubs from openapi.yaml"
|
||||
docker run -it --rm -v $PWD:/work -u $UID openapitools/openapi-generator-cli:v5.3.0 \
|
||||
generate -i /work/openapi.yaml -g aspnetcore -o /work/output \
|
||||
--package-name $PACKAGE_NAME \
|
||||
--additional-properties="packageVersion=0.0.1,aspnetCoreVersion=5.0,operationIsAsync=false,operationResultTask=true,\
|
||||
generateBody=false,classModifier=abstract,operationModifier=abstract"
|
||||
if [ "$STAGE1" = "1" ]; then
|
||||
echo "generate endpoint code from openapi.yaml"
|
||||
python3.10 generate.py
|
||||
fi
|
||||
|
||||
echo "patch DbService registering into generated startup code"
|
||||
sed -i output/src/$PACKAGE_NAME/Startup.cs \
|
||||
-e 's#\(using '$PACKAGE_NAME'.OpenApi;\)#\1\n\n// added by post-processor\nusing '$PACKAGE_NAME'.Services;\n#' \
|
||||
-e 's#^\([[:space:]]*\)\(// Add framework services.\)#\1// added by post-processor\n\1services.AddTransient<IDbService, DbService>();\n\n\1\2#'
|
||||
if [ "$STAGE2" = "1" ]; then
|
||||
echo "generate server code and endpoint stubs from openapi.yaml"
|
||||
docker run -it --rm -v $PWD:/work -u $UID openapitools/openapi-generator-cli:v5.3.0 \
|
||||
generate -i /work/openapi.yaml -g aspnetcore -o /work/output \
|
||||
--package-name $PACKAGE_NAME \
|
||||
--additional-properties="packageVersion=0.0.1,aspnetCoreVersion=5.0,operationIsAsync=false,operationResultTask=true,\
|
||||
generateBody=false,classModifier=abstract,operationModifier=abstract"
|
||||
|
||||
echo "create directories for manually developed code"
|
||||
mkdir output/src/$PACKAGE_NAME/Implementations
|
||||
mkdir output/src/$PACKAGE_NAME/Services
|
||||
echo "patch DbService registering into generated startup code"
|
||||
sed -i output/src/$PACKAGE_NAME/Startup.cs \
|
||||
-e 's#\(using '$PACKAGE_NAME'.OpenApi;\)#\1\n\n// added by post-processor\nusing '$PACKAGE_NAME'.Services;\n#' \
|
||||
-e 's#^\([[:space:]]*\)\(// Add framework services.\)#\1// added by post-processor\n\1services.AddTransient<IDbService, DbService>();\n\n\1\2#'
|
||||
|
||||
echo "copy database service into source code try"
|
||||
cp DbService.cs output/src/$PACKAGE_NAME/Services
|
||||
echo "create directories for manually developed code"
|
||||
mkdir output/src/$PACKAGE_NAME/Implementations
|
||||
mkdir output/src/$PACKAGE_NAME/Services
|
||||
|
||||
echo "generate endpoint code from openapi.yaml"
|
||||
python3.10 generate.py
|
||||
|
||||
echo "copy endpoint code into source code tree"
|
||||
cp regular.cs output/src/$PACKAGE_NAME/Implementations
|
||||
echo "copy database service into source code try"
|
||||
cp DbService.cs output/src/$PACKAGE_NAME/Services
|
||||
|
||||
if [ -f regular.cs ]; then
|
||||
echo "copy endpoint code into source code tree"
|
||||
cp regular.cs output/src/$PACKAGE_NAME/Implementations
|
||||
else
|
||||
echo "implementation not available, forgot to run stage 1?"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$BUILD" = "1" ]; then
|
||||
echo "build service"
|
||||
|
Reference in New Issue
Block a user