#!/bin/bash # safety measure if [ -d output ]; then echo "output directory already exist" echo "remove manually and try again" fi # PACKAGE_NAME will be loaded here . ENV # generate server code and endpoint stubs from openapi.yaml docker run -it --rm -v $PWD:/work -u $UID openapitools/openapi-generator:cli-v5.1.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=true,modelPropertyNaming=camelCase,\ generateBody=false,classModifier=abstract,operationModifier=abstract" # patch DbService registering into generated startup code sed -i output/src/$PACKAGE_NAME/Startup \ -e 's/\(using '$PACKAGE_NAME'.OpenApi;\)/\1\nusing '$PACKAGE_NAME'.Services;/'\ -e 's#\(// Add framework services.\)#services.AddTransient();\n\1#' # create directories for manually developed code mkdir output/src/$PACKAGE_NAME/Implementations mkdir output/src/$PACKAGE_NAME/Services # copy database service into source code try cp DbService.cs output/src/$PACKAGE_NAME/Services # generate endpoint code from openapi.yaml python3.10 generate.py # copy endpoint code into source code try cp regular.cs output/src/$PACKAGE_NAME/Implementations