Skip to content

Commit

Permalink
httpClient using the 'library' swagger-api#1889
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksabor committed Dec 10, 2020
1 parent d5ab6ba commit bd49ea0
Show file tree
Hide file tree
Showing 396 changed files with 55,659 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bin/csharp-petstore-all-httpClient.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

# C# Petstore API client (.NET 3.5)
./bin/csharp-petstore-httpClient.sh

# C# Petstore API client (v5.0 for .net standarnd 1.3+)
./bin/csharp-petstore-net-standard-httpClient.sh

./bin/csharp-petstore-netcore-project-httpClient.sh

3 changes: 3 additions & 0 deletions bin/csharp-petstore-httpClient.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"library": "httpClient"
}
31 changes: 31 additions & 0 deletions bin/csharp-petstore-httpClient.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

SCRIPT="$0"

while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done

if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi

executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"

if [ ! -f "$executable" ]
then
mvn clean package
fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate $@ -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l csharp -o samples/client/petstore/httpClient/csharp/SwaggerClient --additional-properties packageGuid={321C8C3F-0156-40C1-AE42-D59761FB9B6C}" -c ./bin/csharp-petstore-httpClient.json"
java $JAVA_OPTS -jar $executable $ags
4 changes: 4 additions & 0 deletions bin/csharp-petstore-net-standard-httpClient.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"targetFramework": "v5.0",
"library": "httpClient"
}
31 changes: 31 additions & 0 deletions bin/csharp-petstore-net-standard-httpClient.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

SCRIPT="$0"

while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done

if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi

executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"

if [ ! -f "$executable" ]
then
mvn clean package
fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate $@ -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l csharp -o samples/client/petstore/csharp/httpClient/SwaggerClientNetStandard --additional-properties packageGuid={321C8C3F-0156-40C1-AE42-D59761FB9B6C} -c ./bin/csharp-petstore-net-standard-httpClient.json"

java $JAVA_OPTS -jar $executable $ags
3 changes: 3 additions & 0 deletions bin/csharp-petstore-netcore-project-httpClient.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"library": "httpClient"
}
31 changes: 31 additions & 0 deletions bin/csharp-petstore-netcore-project-httpClient.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

SCRIPT="$0"

while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done

if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi

executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"

if [ ! -f "$executable" ]
then
mvn clean package
fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate $@ -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l csharp -o samples/client/petstore/csharp/httpClient/SwaggerClientNetCoreProject --additional-properties packageGuid={67035b31-f8e5-41a4-9673-954035084f7d},netCoreProjectFile=true -c ./bin/csharp-petstore-net-standard-httpClient.json"

java $JAVA_OPTS -jar $executable $ags
8 changes: 8 additions & 0 deletions bin/windows/csharp-petstore-all-httpClient.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
REM C# Petstore API client
call .\bin\windows\csharp-petstore-httpClient.bat

REM C# Petstore API client (v5.0 for .net standarnd 1.3+)
call .\bin\windows\csharp-petstore-netstandard-httpClient.bat

call .\bin\windows\csharp-petstore-netcore-project-httpClient.bat

10 changes: 10 additions & 0 deletions bin/windows/csharp-petstore-httpClient.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar

If Not Exist %executable% (
mvn clean package
)

REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l csharp -o samples\client\petstore\csharp\httpClient\SwaggerClient --additional-properties packageGuid={321C8C3F-0156-40C1-AE42-D59761FB9B6C} -c ./bin/csharp-petstore-httpClient.json"

java %JAVA_OPTS% -jar %executable% %ags%
10 changes: 10 additions & 0 deletions bin/windows/csharp-petstore-netcore-project-httpClient.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar

If Not Exist %executable% (
mvn clean package
)

REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l csharp -o samples\client\petstore\csharp\httpClient\SwaggerClientNetCoreProject --additional-properties targetFramework=v5.0,packageGuid={67035b31-f8e5-41a4-9673-954035084f7d},netCoreProjectFile=true -c ./bin/csharp-petstore-netcore-project-httpClient.json"

java %JAVA_OPTS% -jar %executable% %ags%
10 changes: 10 additions & 0 deletions bin/windows/csharp-petstore-netstandard-httpClient.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar

If Not Exist %executable% (
mvn clean package
)

REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l csharp -o samples\client\petstore\csharp\httpClient\SwaggerClientNetStandard --additional-properties targetFramework=v5.0,packageGuid={3AB1F259-1769-484B-9411-84505FCCBD55}

java %JAVA_OPTS% -jar %executable% %ags%
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,17 @@ public CSharpClientCodegen() {
regexModifiers.put('m', "Multiline");
regexModifiers.put('s', "Singleline");
regexModifiers.put('x', "IgnorePatternWhitespace");

supportedLibraries.put("restSharp", "RestSharp client: RestSharp.RestClient");
supportedLibraries.put("httpClient", "HTTP client: System.Net.HttpClient");

CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
libraryOption.setEnum(supportedLibraries);
// set restSharp as the default
libraryOption.setDefault("restSharp");
cliOptions.add(libraryOption);

setLibrary("restSharp");
}

@Override
Expand Down Expand Up @@ -351,6 +362,7 @@ public void processOpts() {
clientPackageDir, "IApiAccessor.cs"));
supportingFiles.add(new SupportingFile("Configuration.mustache",
clientPackageDir, "Configuration.cs"));
LOGGER.info("apiClient {}", clientPackageDir);
supportingFiles.add(new SupportingFile("ApiClient.mustache",
clientPackageDir, "ApiClient.cs"));
supportingFiles.add(new SupportingFile("ApiException.mustache",
Expand Down Expand Up @@ -437,6 +449,11 @@ public void processOpts() {
}
}
}
if("httpClient".equals(getLibrary())) {
supportingFiles.add(new SupportingFile("RequestParameters.mustache", clientPackageDir, "RequestParameters.cs"));
supportingFiles.add(new SupportingFile("ResponseExtension.mustache", clientPackageDir, "ResponseExtension.cs"));
supportingFiles.add(new SupportingFile("InterceptResult.mustache", clientPackageDir, "InterceptResult.cs"));
}

additionalProperties.put("apiDocPath", apiDocPath);
additionalProperties.put("modelDocPath", modelDocPath);
Expand Down
Loading

0 comments on commit bd49ea0

Please sign in to comment.