diff --git a/package.json b/package.json index ab4e239..cc9e7c9 100644 --- a/package.json +++ b/package.json @@ -28,10 +28,10 @@ "generators" ], "devDependencies": { - "@types/update-notifier": "^5.1.0", "@types/glob": "^7.1.4", "@types/lodash": "^4.14.168", "@types/node": "^16.4.13", + "@types/update-notifier": "^5.1.0", "@types/yeoman-generator": "5.2.2", "@types/yosay": "^2.0.0", "copyfiles": "^2.4.1", diff --git a/src/sdk-auto-generate-dotnet/templates/script.sh b/src/sdk-auto-generate-dotnet/templates/script.sh index 679cb6b..9a817c4 100644 --- a/src/sdk-auto-generate-dotnet/templates/script.sh +++ b/src/sdk-auto-generate-dotnet/templates/script.sh @@ -8,7 +8,21 @@ packageName=$5 projectPath=$targetDirectory/$packageName -openApiConfigPath=$targetDirectory/.openapi-generator/csharp-netcore.yaml +openApiConfigPath=$targetDirectory/.openapi-generator/csharp.yaml + +# Verify that openapi-generator is installed +if ! command -v openapi-generator &> /dev/null +then + echo "openapi-generator could not be found" + exit +fi + +# Verify that openapi-generator version is 7.0.X +if [[ $(openapi-generator version) != 6.0.* ]]; +then + echo "openapi-generator version 7.0.X is required" + exit +fi # Create target path mkdir -p $targetDirectory/.openapi-generator @@ -34,7 +48,7 @@ dotnet build $webservice -c Release openapi-generator generate \ -i $swagger \ -o $targetDirectory \ - -g csharp-netcore \ + -g csharp \ -c $openApiConfigPath # Remove generated SLN @@ -68,9 +82,15 @@ fi # Add generated project to root sln dotnet sln $solution add $projectPath/ +# Discard changes made to csproj file +git checkout $projectPath/$packageName.csproj + # Install SpaceBlocks.Libs.Sdk into AutoGenerated project dotnet add $projectPath/$packageName.csproj package SpaceBlocks.Libs.Sdk +# Remove the Newtonsoft.Json dependency because it is already included in SpaceBlocks.Libs.Sdk +dotnet remove $projectPath/$packageName.csproj package Newtonsoft.Json + # Place partial class ApiClient`.cs cat > $projectPath/Client/ApiClient\`.cs <