Skip to content

Commit de45e03

Browse files
authored
Fix float/double default value in C# generator (OpenAPITools#791)
* fix float/double default value * better code format * better CI for openapi3 batch files (C# client) * update nancyfx samples * pipe output to /dev/null to reduce log size * fix windows batch file * add C# API client generated by OAS3 spec
1 parent 49bc971 commit de45e03

File tree

182 files changed

+22328
-134
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

182 files changed

+22328
-134
lines changed

appveyor.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,19 @@ build_script:
3535
# install openapi-generator locally
3636
- mvn clean install --quiet
3737
test_script:
38+
# restore test-related files
39+
- copy /b/v/y CI\samples.ci\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj samples\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
3840
# test c# API client
3941
- nunit-console samples\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\bin\Debug\Org.OpenAPITools.Test.dll --result=myresults.xml;format=AppVeyor
4042
# test c# API client (with PropertyChanged)
4143
- nunit-console samples\client\petstore\csharp\OpenAPIClientWithPropertyChanged\src\Org.OpenAPITools.Test\bin\Debug\Org.OpenAPITools.Test.dll --result=myresults.xml;format=AppVeyor
4244

4345
# generate all petstore clients
4446
- .\bin\windows\run-all-petstore.cmd
47+
48+
# generate all petstore clients (openapi3)
49+
- .\bin\openapi3\windows\run-all-petstore.cmd
50+
4551
cache:
4652
- C:\maven\
4753
- C:\Users\appveyor\.m2

bin/csharp-petstore.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ fi
2929
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
3030
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g csharp -o samples/client/petstore/csharp/OpenAPIClient --additional-properties packageGuid={321C8C3F-0156-40C1-AE42-D59761FB9B6C} $@"
3131

32+
java $JAVA_OPTS -jar $executable $ags
33+
3234
# restore csproj file
3335
echo "restore csproject file: CI/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj"
34-
cp ./CI/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj ./samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/
36+
cp ./CI/samples.ci/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj ./samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/
3537

36-
java $JAVA_OPTS -jar $executable $ags

bin/openapi3/csharp-petstore.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ fi
2727

2828
# if you've executed sbt assembly previously it will use that instead.
2929
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
30-
ags="generate $@ -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g csharp -o samples/client/petstore/csharp/OpenAPIClient --additional-properties packageGuid={321C8C3F-0156-40C1-AE42-D59761FB9B6C}"
30+
ags="generate $@ -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g csharp -o samples/openapi3/client/petstore/csharp/OpenAPIClient --additional-properties packageGuid={321C8C3F-0156-40C1-AE42-D59761FB9B6C}"
3131

3232
java $JAVA_OPTS -jar $executable $ags

bin/openapi3/run-all-petstore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
# this bash script will loop through all the .sh files under bin
3+
# execute the script and check the result (exit code) to see if
4+
# there's any error
5+
6+
echo "IMPORTANT: this script should be run by the CI (e.g. Shippable) only. There's no need to run this script to update Petstore samples for all generators."
7+
echo "Please press CTRL+C to stop or the script will continue in 10 seconds."
8+
9+
sleep 10
10+
11+
successes=0
12+
failures=0
13+
for SCRIPT in $(ls -l ./bin/openapi3/*.sh | grep -v all)
14+
do
15+
if [ -f ${SCRIPT} -a -x ${SCRIPT} ]; then
16+
echo "Running $SCRIPT (output to /dev/null)"
17+
${SCRIPT} 2>&1 > /dev/null
18+
rc=$?
19+
if [[ ${rc} != 0 ]]; then
20+
>&2 echo "ERROR!! FAILED TO RUN ${SCRIPT}"
21+
((failures+=1))
22+
else
23+
((successes+=1))
24+
fi
25+
fi
26+
done
27+
28+
if (( failures > 0 )); then
29+
>&2 echo "[ERROR] ${failures} out of $((failures+successes)) scripts failed."
30+
exit 1
31+
else
32+
echo "[SUCCESS] ${successes} generators finished."
33+
fi
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
2+
3+
If Not Exist %executable% (
4+
mvn clean package
5+
)
6+
7+
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
8+
set ags=generate -i modules\openapi-generator\src\test/resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g csharp -o samples\openapi3\client\petstore\csharp\SwaggerClient --additional-properties packageGuid={321C8C3F-0156-40C1-AE42-D59761FB9B6C}
9+
10+
java %JAVA_OPTS% -jar %executable% %ags%
11+
12+
REM restore csproj file
13+
echo "restore csproject file: CI\samples.ci\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj"
14+
copy /b/v/y CI\samples.ci\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj samples\openapi3\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
REM this batch file will loop through all the .bat files under bin\openapi3\windows\
2+
REM execute the script and check the error level to see if there's any error
3+
4+
echo IMPORTANT: this script should be run by the CI (e.g. appveyor) only. There's no need to run this script to update Petstore samples for all generators.
5+
echo Please press CTRL+C to stop or the script will continue in 10 seconds.
6+
7+
timeout 10
8+
9+
for /f "delims=" %%i in ('dir /b ".\bin\openapi3\windows\*.bat"') do (
10+
11+
CALL .\bin\openapi3\windows\%%i
12+
13+
IF ERRORLEVEL 1 IF NOT ERRORLEVEL 2 exit /b 1
14+
15+
)

bin/run-all-petstore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ failures=0
1313
for SCRIPT in $(ls -l ./bin/*.sh | grep -v all)
1414
do
1515
if [ -f ${SCRIPT} -a -x ${SCRIPT} ]; then
16-
echo "Running $SCRIPT"
17-
${SCRIPT}
16+
echo "Running $SCRIPT (output to /dev/null)"
17+
${SCRIPT} 2>&1 > /dev/null
1818
rc=$?
1919
if [[ ${rc} != 0 ]]; then
2020
>&2 echo "ERROR!! FAILED TO RUN ${SCRIPT}"
@@ -30,4 +30,4 @@ if (( failures > 0 )); then
3030
exit 1
3131
else
3232
echo "[SUCCESS] ${successes} generators finished."
33-
fi
33+
fi

bin/utils/ensure-up-to-date

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ sleep 5
3131
./bin/typescript-inversify-petstore.sh > /dev/null 2>&1
3232
./bin/rust-server-petstore.sh > /dev/null 2>&1
3333
./bin/openapi3/haskell-http-client-petstore.sh > /dev/null 2>&1
34+
./bin/csharp-petstore.sh > /dev/null 2>&1
3435

3536
# Check:
3637
if [ -n "$(git status --porcelain)" ]; then

bin/windows/csharp-petstore-net-40.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ If Not Exist %executable% (
55
)
66

77
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
8-
set ags=generate -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g csharp -o samples/client/petstore/csharp/SwaggerClientNet40 --additional-properties packageGuid={321C8C3F-0156-40C1-AE42-D59761FB9B6C} -c ./bin/csharp-petstore-net-40.json
8+
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g csharp -o samples\client\petstore\csharp\SwaggerClientNet40 --additional-properties packageGuid={321C8C3F-0156-40C1-AE42-D59761FB9B6C} -c .\bin\csharp-petstore-net-40.json
99

1010
java %JAVA_OPTS% -jar %executable% %ags%

0 commit comments

Comments
 (0)