From 4d705081c85ad1b36ac0191d42ba89c451b842ee Mon Sep 17 00:00:00 2001 From: wing328 Date: Fri, 26 May 2017 21:47:49 +0800 Subject: [PATCH 01/10] [PHP] Fix broken links in the auto-generated documentation (#5715) * remove trailing space in cpprest, update samples * remove unused pom.xml in go pestore * fix broken links in php api doc by fixing baseType * fix csharp api doc * fix php examples * fix examples for abstract php generator --- .../io/swagger/codegen/DefaultCodegen.java | 3 +- .../codegen/languages/AbstractPhpCodegen.java | 2 +- .../codegen/languages/PhpClientCodegen.java | 6 +- .../main/resources/csharp/api_doc.mustache | 2 +- .../client/petstore-security-test/go/pom.xml | 75 ------------------- samples/client/petstore/cpprest/ApiClient.cpp | 5 -- .../SwaggerClient/.swagger-codegen/VERSION | 1 + .../petstore/csharp/SwaggerClient/README.md | 4 +- .../src/IO.Swagger/Api/FakeApi.cs | 8 -- .../src/IO.Swagger/IO.Swagger.csproj | 6 +- .../src/IO.Swagger/Model/OuterBoolean.cs | 2 +- .../src/IO.Swagger/Model/OuterComposite.cs | 2 +- .../src/IO.Swagger/Model/OuterNumber.cs | 2 +- .../src/IO.Swagger/Model/OuterString.cs | 2 +- .../gen/io/swagger/client/BuildConfig.java | 8 -- .../main/gen/io/swagger/client/Manifest.java | 7 -- .../src/main/gen/io/swagger/client/R.java | 7 -- .../petstore/php/SwaggerClient-php/README.md | 4 +- .../php/SwaggerClient-php/docs/Api/FakeApi.md | 14 ++-- .../php/SwaggerClient-php/docs/Api/PetApi.md | 4 +- .../SwaggerClient-php/docs/Api/StoreApi.md | 2 +- .../php/SwaggerClient-php/docs/Api/UserApi.md | 8 +- 22 files changed, 32 insertions(+), 142 deletions(-) delete mode 100644 samples/client/petstore-security-test/go/pom.xml create mode 100644 samples/client/petstore/csharp/SwaggerClient/.swagger-codegen/VERSION delete mode 100644 samples/client/petstore/java/okhttp-gson/src/main/gen/io/swagger/client/BuildConfig.java delete mode 100644 samples/client/petstore/java/okhttp-gson/src/main/gen/io/swagger/client/Manifest.java delete mode 100644 samples/client/petstore/java/okhttp-gson/src/main/gen/io/swagger/client/R.java diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java index 249a049259e..49ea0d4bb5f 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java @@ -2561,7 +2561,9 @@ public class DefaultCodegen { name = getAlias(name); if (typeMapping.containsKey(name)) { name = typeMapping.get(name); + p.baseType = name; } else { + p.baseType = name; name = toModelName(name); if (defaultIncludes.contains(name)) { imports.add(name); @@ -2570,7 +2572,6 @@ public class DefaultCodegen { name = getTypeDeclaration(name); } p.dataType = name; - p.baseType = name; } } p.paramName = toParamName(bp.getName()); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractPhpCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractPhpCodegen.java index 8d9c3e6c7fc..a7c339d90f9 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractPhpCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractPhpCodegen.java @@ -560,7 +560,7 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg example = "new \\DateTime(\"" + escapeText(example) + "\")"; } else if (!languageSpecificPrimitives.contains(type)) { // type is a model class, e.g. User - example = "new " + type + "()"; + example = "new " + getTypeDeclaration(type) + "()"; } else { LOGGER.warn("Type " + type + " not handled properly in setParameterExampleValue"); } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java index dd7489a57d9..a9286f58fe8 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PhpClientCodegen.java @@ -616,19 +616,19 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig { example = "/path/to/file"; } example = "\"" + escapeText(example) + "\""; - } else if ("Date".equalsIgnoreCase(type)) { + } else if ("\\Date".equalsIgnoreCase(type)) { if (example == null) { example = "2013-10-20"; } example = "new \\DateTime(\"" + escapeText(example) + "\")"; - } else if ("DateTime".equalsIgnoreCase(type)) { + } else if ("\\DateTime".equalsIgnoreCase(type)) { if (example == null) { example = "2013-10-20T19:20:30+01:00"; } example = "new \\DateTime(\"" + escapeText(example) + "\")"; } else if (!languageSpecificPrimitives.contains(type)) { // type is a model class, e.g. User - example = "new " + type + "()"; + example = "new " + getTypeDeclaration(type) + "()"; } else { LOGGER.warn("Type " + type + " not handled properly in setParameterExampleValue"); } diff --git a/modules/swagger-codegen/src/main/resources/csharp/api_doc.mustache b/modules/swagger-codegen/src/main/resources/csharp/api_doc.mustache index 614c7057c3a..9ef645bed3f 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/api_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/api_doc.mustache @@ -75,7 +75,7 @@ namespace Example {{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}} Name | Type | Description | Notes ------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}} -{{#allParams}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} +{{#allParams}} **{{paramName}}** | {{#isFile}}**{{dataType}}**{{/isFile}}{{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{dataType}}**]({{#isContainer}}{{baseType}}{{/isContainer}}{{^isContainer}}{{dataType}}{{/isContainer}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} | {{^required}}[optional] {{/required}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}} {{/allParams}} ### Return type diff --git a/samples/client/petstore-security-test/go/pom.xml b/samples/client/petstore-security-test/go/pom.xml deleted file mode 100644 index 50bfe7f14f8..00000000000 --- a/samples/client/petstore-security-test/go/pom.xml +++ /dev/null @@ -1,75 +0,0 @@ - - 4.0.0 - com.wordnik - Goswagger - pom - 1.0.0 - Goswagger - - - - maven-dependency-plugin - - - package - - copy-dependencies - - - ${project.build.directory} - - - - - - org.codehaus.mojo - exec-maven-plugin - 1.2.1 - - - go-get-testify - pre-integration-test - - exec - - - go - - get - github.com/stretchr/testify/assert - - - - - go-get-sling - pre-integration-test - - exec - - - go - - get - github.com/dghubble/sling - - - - - go-test - integration-test - - exec - - - go - - test - -v - - - - - - - - \ No newline at end of file diff --git a/samples/client/petstore/cpprest/ApiClient.cpp b/samples/client/petstore/cpprest/ApiClient.cpp index cdfcea93c8b..aeed9ef42ae 100644 --- a/samples/client/petstore/cpprest/ApiClient.cpp +++ b/samples/client/petstore/cpprest/ApiClient.cpp @@ -61,11 +61,6 @@ utility::string_t ApiClient::parameterToString(float value) return utility::conversions::to_string_t(std::to_string(value)); } -utility::string_t ApiClient::parameterToString(float value) -{ - return utility::conversions::to_string_t(std::to_string(value)); -} - utility::string_t ApiClient::parameterToString(const utility::datetime &value) { return utility::conversions::to_string_t(value.to_string(utility::datetime::ISO_8601)); diff --git a/samples/client/petstore/csharp/SwaggerClient/.swagger-codegen/VERSION b/samples/client/petstore/csharp/SwaggerClient/.swagger-codegen/VERSION new file mode 100644 index 00000000000..7fea99011a6 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClient/.swagger-codegen/VERSION @@ -0,0 +1 @@ +2.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/csharp/SwaggerClient/README.md b/samples/client/petstore/csharp/SwaggerClient/README.md index e9f8551872b..576c89fed51 100644 --- a/samples/client/petstore/csharp/SwaggerClient/README.md +++ b/samples/client/petstore/csharp/SwaggerClient/README.md @@ -132,10 +132,8 @@ Class | Method | HTTP request | Description - [Model.ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [Model.ArrayTest](docs/ArrayTest.md) - [Model.Capitalization](docs/Capitalization.md) - - [Model.Cat](docs/Cat.md) - [Model.Category](docs/Category.md) - [Model.ClassModel](docs/ClassModel.md) - - [Model.Dog](docs/Dog.md) - [Model.EnumArrays](docs/EnumArrays.md) - [Model.EnumClass](docs/EnumClass.md) - [Model.EnumTest](docs/EnumTest.md) @@ -160,6 +158,8 @@ Class | Method | HTTP request | Description - [Model.SpecialModelName](docs/SpecialModelName.md) - [Model.Tag](docs/Tag.md) - [Model.User](docs/User.md) + - [Model.Cat](docs/Cat.md) + - [Model.Dog](docs/Dog.md) diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/FakeApi.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/FakeApi.cs index 76d88a6b174..953b7844ed2 100644 --- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Api/FakeApi.cs @@ -579,7 +579,6 @@ namespace IO.Swagger.Api return new ApiResponse(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (OuterBoolean) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterBoolean))); - } /// @@ -650,7 +649,6 @@ namespace IO.Swagger.Api return new ApiResponse(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (OuterBoolean) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterBoolean))); - } /// @@ -720,7 +718,6 @@ namespace IO.Swagger.Api return new ApiResponse(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (OuterComposite) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterComposite))); - } /// @@ -791,7 +788,6 @@ namespace IO.Swagger.Api return new ApiResponse(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (OuterComposite) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterComposite))); - } /// @@ -861,7 +857,6 @@ namespace IO.Swagger.Api return new ApiResponse(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (OuterNumber) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterNumber))); - } /// @@ -932,7 +927,6 @@ namespace IO.Swagger.Api return new ApiResponse(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (OuterNumber) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterNumber))); - } /// @@ -1002,7 +996,6 @@ namespace IO.Swagger.Api return new ApiResponse(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (OuterString) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterString))); - } /// @@ -1073,7 +1066,6 @@ namespace IO.Swagger.Api return new ApiResponse(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (OuterString) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterString))); - } /// diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/IO.Swagger.csproj b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/IO.Swagger.csproj index df95d7cfb58..4c942e8cd5f 100644 --- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/IO.Swagger.csproj +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/IO.Swagger.csproj @@ -62,10 +62,8 @@ Contact: apiteam@swagger.io - - - - + diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/OuterBoolean.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/OuterBoolean.cs index c25f48db758..86d7a8ef3dd 100644 --- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/OuterBoolean.cs +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/OuterBoolean.cs @@ -104,7 +104,7 @@ namespace IO.Swagger.Model /// Validation context /// Validation Result IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { + { yield break; } } diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/OuterComposite.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/OuterComposite.cs index ce12f7bb6ce..2d9c23842fc 100644 --- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/OuterComposite.cs +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/OuterComposite.cs @@ -148,7 +148,7 @@ namespace IO.Swagger.Model /// Validation context /// Validation Result IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { + { yield break; } } diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/OuterNumber.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/OuterNumber.cs index a53914c4840..6e6d4f74f0f 100644 --- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/OuterNumber.cs +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/OuterNumber.cs @@ -104,7 +104,7 @@ namespace IO.Swagger.Model /// Validation context /// Validation Result IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { + { yield break; } } diff --git a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/OuterString.cs b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/OuterString.cs index d2d0905e162..95d879acf69 100644 --- a/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/OuterString.cs +++ b/samples/client/petstore/csharp/SwaggerClient/src/IO.Swagger/Model/OuterString.cs @@ -104,7 +104,7 @@ namespace IO.Swagger.Model /// Validation context /// Validation Result IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { + { yield break; } } diff --git a/samples/client/petstore/java/okhttp-gson/src/main/gen/io/swagger/client/BuildConfig.java b/samples/client/petstore/java/okhttp-gson/src/main/gen/io/swagger/client/BuildConfig.java deleted file mode 100644 index 720765940d3..00000000000 --- a/samples/client/petstore/java/okhttp-gson/src/main/gen/io/swagger/client/BuildConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */ -public final class BuildConfig { - public final static boolean DEBUG = Boolean.parseBoolean(null); -} \ No newline at end of file diff --git a/samples/client/petstore/java/okhttp-gson/src/main/gen/io/swagger/client/Manifest.java b/samples/client/petstore/java/okhttp-gson/src/main/gen/io/swagger/client/Manifest.java deleted file mode 100644 index 41e0523a208..00000000000 --- a/samples/client/petstore/java/okhttp-gson/src/main/gen/io/swagger/client/Manifest.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */ -public final class Manifest { -} \ No newline at end of file diff --git a/samples/client/petstore/java/okhttp-gson/src/main/gen/io/swagger/client/R.java b/samples/client/petstore/java/okhttp-gson/src/main/gen/io/swagger/client/R.java deleted file mode 100644 index cd0683364d5..00000000000 --- a/samples/client/petstore/java/okhttp-gson/src/main/gen/io/swagger/client/R.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */ -public final class R { -} \ No newline at end of file diff --git a/samples/client/petstore/php/SwaggerClient-php/README.md b/samples/client/petstore/php/SwaggerClient-php/README.md index 11365910027..a68094996d3 100644 --- a/samples/client/petstore/php/SwaggerClient-php/README.md +++ b/samples/client/petstore/php/SwaggerClient-php/README.md @@ -114,11 +114,9 @@ Class | Method | HTTP request | Description - [ArrayOfNumberOnly](docs/Model/ArrayOfNumberOnly.md) - [ArrayTest](docs/Model/ArrayTest.md) - [Capitalization](docs/Model/Capitalization.md) - - [Cat](docs/Model/Cat.md) - [Category](docs/Model/Category.md) - [ClassModel](docs/Model/ClassModel.md) - [Client](docs/Model/Client.md) - - [Dog](docs/Model/Dog.md) - [EnumArrays](docs/Model/EnumArrays.md) - [EnumClass](docs/Model/EnumClass.md) - [EnumTest](docs/Model/EnumTest.md) @@ -142,6 +140,8 @@ Class | Method | HTTP request | Description - [SpecialModelName](docs/Model/SpecialModelName.md) - [Tag](docs/Model/Tag.md) - [User](docs/Model/User.md) + - [Cat](docs/Model/Cat.md) + - [Dog](docs/Model/Dog.md) ## Documentation For Authorization diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Api/FakeApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/Api/FakeApi.md index 2c25bfcc9cb..08fb21b07ea 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Api/FakeApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Api/FakeApi.md @@ -41,7 +41,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**\Swagger\Client\Model\OuterBoolean**](../Model/\Swagger\Client\Model\OuterBoolean.md)| Input boolean as post body | [optional] + **body** | [**\Swagger\Client\Model\OuterBoolean**](../Model/OuterBoolean.md)| Input boolean as post body | [optional] ### Return type @@ -86,7 +86,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**\Swagger\Client\Model\OuterComposite**](../Model/\Swagger\Client\Model\OuterComposite.md)| Input composite as post body | [optional] + **body** | [**\Swagger\Client\Model\OuterComposite**](../Model/OuterComposite.md)| Input composite as post body | [optional] ### Return type @@ -131,7 +131,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**\Swagger\Client\Model\OuterNumber**](../Model/\Swagger\Client\Model\OuterNumber.md)| Input number as post body | [optional] + **body** | [**\Swagger\Client\Model\OuterNumber**](../Model/OuterNumber.md)| Input number as post body | [optional] ### Return type @@ -176,7 +176,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**\Swagger\Client\Model\OuterString**](../Model/\Swagger\Client\Model\OuterString.md)| Input string as post body | [optional] + **body** | [**\Swagger\Client\Model\OuterString**](../Model/OuterString.md)| Input string as post body | [optional] ### Return type @@ -221,7 +221,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**\Swagger\Client\Model\Client**](../Model/\Swagger\Client\Model\Client.md)| client model | + **body** | [**\Swagger\Client\Model\Client**](../Model/Client.md)| client model | ### Return type @@ -265,8 +265,8 @@ $int64 = 789; // int | None $float = 3.4; // float | None $string = "string_example"; // string | None $binary = "B"; // string | None -$date = new \DateTime(); // \DateTime | None -$date_time = new \DateTime(); // \DateTime | None +$date = new \DateTime("2013-10-20"); // \DateTime | None +$date_time = new \DateTime("2013-10-20T19:20:30+01:00"); // \DateTime | None $password = "password_example"; // string | None $callback = "callback_example"; // string | None diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Api/PetApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/Api/PetApi.md index 0349289f81d..aee0e2b4d18 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Api/PetApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Api/PetApi.md @@ -44,7 +44,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**\Swagger\Client\Model\Pet**](../Model/\Swagger\Client\Model\Pet.md)| Pet object that needs to be added to the store | + **body** | [**\Swagger\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -286,7 +286,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**\Swagger\Client\Model\Pet**](../Model/\Swagger\Client\Model\Pet.md)| Pet object that needs to be added to the store | + **body** | [**\Swagger\Client\Model\Pet**](../Model/Pet.md)| Pet object that needs to be added to the store | ### Return type diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Api/StoreApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/Api/StoreApi.md index d959d6141d0..60347048078 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Api/StoreApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Api/StoreApi.md @@ -173,7 +173,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**\Swagger\Client\Model\Order**](../Model/\Swagger\Client\Model\Order.md)| order placed for purchasing the pet | + **body** | [**\Swagger\Client\Model\Order**](../Model/Order.md)| order placed for purchasing the pet | ### Return type diff --git a/samples/client/petstore/php/SwaggerClient-php/docs/Api/UserApi.md b/samples/client/petstore/php/SwaggerClient-php/docs/Api/UserApi.md index dd6a1cddb78..ba9673f784d 100644 --- a/samples/client/petstore/php/SwaggerClient-php/docs/Api/UserApi.md +++ b/samples/client/petstore/php/SwaggerClient-php/docs/Api/UserApi.md @@ -41,7 +41,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**\Swagger\Client\Model\User**](../Model/\Swagger\Client\Model\User.md)| Created user object | + **body** | [**\Swagger\Client\Model\User**](../Model/User.md)| Created user object | ### Return type @@ -71,7 +71,7 @@ Creates list of users with given input array require_once(__DIR__ . '/vendor/autoload.php'); $api_instance = new Swagger\Client\Api\UserApi(); -$body = array(new User()); // \Swagger\Client\Model\User[] | List of user object +$body = array(new \Swagger\Client\Model\User()); // \Swagger\Client\Model\User[] | List of user object try { $api_instance->createUsersWithArrayInput($body); @@ -115,7 +115,7 @@ Creates list of users with given input array require_once(__DIR__ . '/vendor/autoload.php'); $api_instance = new Swagger\Client\Api\UserApi(); -$body = array(new User()); // \Swagger\Client\Model\User[] | List of user object +$body = array(new \Swagger\Client\Model\User()); // \Swagger\Client\Model\User[] | List of user object try { $api_instance->createUsersWithListInput($body); @@ -351,7 +351,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **username** | **string**| name that need to be deleted | - **body** | [**\Swagger\Client\Model\User**](../Model/\Swagger\Client\Model\User.md)| Updated user object | + **body** | [**\Swagger\Client\Model\User**](../Model/User.md)| Updated user object | ### Return type From 54119a7ac16845f023b47df92b973ea2718d65ad Mon Sep 17 00:00:00 2001 From: wing328 Date: Fri, 26 May 2017 22:49:30 +0800 Subject: [PATCH 02/10] roll back clojure petstore to use petstore.json --- bin/clojure-petstore.sh | 2 +- samples/client/petstore/clojure/.swagger-codegen/VERSION | 1 + .../client/petstore/clojure/src/swagger_petstore/api/pet.clj | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 samples/client/petstore/clojure/.swagger-codegen/VERSION diff --git a/bin/clojure-petstore.sh b/bin/clojure-petstore.sh index 2c55a03e1c5..1f53d9d386c 100755 --- a/bin/clojure-petstore.sh +++ b/bin/clojure-petstore.sh @@ -26,6 +26,6 @@ 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.yaml -l clojure -o samples/client/petstore/clojure" +ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l clojure -o samples/client/petstore/clojure" java $JAVA_OPTS -jar $executable $ags diff --git a/samples/client/petstore/clojure/.swagger-codegen/VERSION b/samples/client/petstore/clojure/.swagger-codegen/VERSION new file mode 100644 index 00000000000..7fea99011a6 --- /dev/null +++ b/samples/client/petstore/clojure/.swagger-codegen/VERSION @@ -0,0 +1 @@ +2.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/clojure/src/swagger_petstore/api/pet.clj b/samples/client/petstore/clojure/src/swagger_petstore/api/pet.clj index 845aa55b526..344ea3bb1f8 100644 --- a/samples/client/petstore/clojure/src/swagger_petstore/api/pet.clj +++ b/samples/client/petstore/clojure/src/swagger_petstore/api/pet.clj @@ -98,7 +98,7 @@ :form-params {} :content-types [] :accepts ["application/json" "application/xml"] - :auth-names ["petstore_auth" "api_key"]})) + :auth-names ["api_key" "petstore_auth"]})) (defn get-pet-by-id "Find pet by ID From d315ba2984b2d833168a70514e365b3d924ef170 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sat, 27 May 2017 00:04:17 +0800 Subject: [PATCH 03/10] add SAS to list of companies using swagger codegen --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b1fa433f818..a63c2bf32ed 100644 --- a/README.md +++ b/README.md @@ -785,6 +785,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you - [Riffyn](https://riffyn.com) - [Royal Bank of Canada (RBC)](http://www.rbc.com/canada.html) - [Saritasa](https://www.saritasa.com/) +- [SAS](https://www.sas.com) - [SCOOP Software GmbH](http://www.scoop-software.de) - [Shine Solutions](https://shinesolutions.com/) - [Simpfony](https://www.simpfony.com/) From b1ccaf69ac68a9b7a4e3067cc6c20592bed20739 Mon Sep 17 00:00:00 2001 From: Michael Langford Date: Fri, 26 May 2017 12:27:11 -0400 Subject: [PATCH 04/10] Updates http-client dependency to correctly handles certificates (#5707) * Updates http-client dependency to one that correctly handles certificates This is important as amazon AWS gateway and several other types of certificates will not work correctly due to the old java library used by the 2.0.0 version of http-client. * Runs the petstore updates switch for clojure * Runs the petstore updates switch for clojure --- .../main/resources/clojure/project.mustache | 2 +- samples/client/petstore/clojure/project.clj | 4 +- .../clojure/src/swagger_petstore/api/pet.clj | 111 +++++++-------- .../src/swagger_petstore/api/store.clj | 32 ++--- .../clojure/src/swagger_petstore/api/user.clj | 134 ++++++++---------- 5 files changed, 132 insertions(+), 151 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/clojure/project.mustache b/modules/swagger-codegen/src/main/resources/clojure/project.mustache index df83142e428..0fe990d02c8 100644 --- a/modules/swagger-codegen/src/main/resources/clojure/project.mustache +++ b/modules/swagger-codegen/src/main/resources/clojure/project.mustache @@ -4,5 +4,5 @@ :license {:name "<&projectLicenseName>"<#projectLicenseUrl> :url "<&projectLicenseUrl>"} :dependencies [[org.clojure/clojure "1.7.0"] - [clj-http "2.0.0"] + [clj-http "3.6.0"] [cheshire "5.5.0"]]) diff --git a/samples/client/petstore/clojure/project.clj b/samples/client/petstore/clojure/project.clj index 34dcb2d99a7..e64d9ef7447 100644 --- a/samples/client/petstore/clojure/project.clj +++ b/samples/client/petstore/clojure/project.clj @@ -1,7 +1,7 @@ (defproject swagger-petstore "1.0.0" - :description "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters" + :description "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters." :license {:name "Apache 2.0" :url "http://www.apache.org/licenses/LICENSE-2.0.html"} :dependencies [[org.clojure/clojure "1.7.0"] - [clj-http "2.0.0"] + [clj-http "3.6.0"] [cheshire "5.5.0"]]) diff --git a/samples/client/petstore/clojure/src/swagger_petstore/api/pet.clj b/samples/client/petstore/clojure/src/swagger_petstore/api/pet.clj index 344ea3bb1f8..92ab5e13218 100644 --- a/samples/client/petstore/clojure/src/swagger_petstore/api/pet.clj +++ b/samples/client/petstore/clojure/src/swagger_petstore/api/pet.clj @@ -5,24 +5,22 @@ (defn add-pet-with-http-info "Add a new pet to the store " - ([] (add-pet-with-http-info nil)) - ([{:keys [body ]}] - (call-api "/pet" :post - {:path-params {} - :header-params {} - :query-params {} - :form-params {} - :body-param body - :content-types ["application/json" "application/xml"] - :accepts ["application/json" "application/xml"] - :auth-names ["petstore_auth"]}))) + [body ] + (call-api "/pet" :post + {:path-params {} + :header-params {} + :query-params {} + :form-params {} + :body-param body + :content-types ["application/json" "application/xml"] + :accepts ["application/xml" "application/json"] + :auth-names ["petstore_auth"]})) (defn add-pet "Add a new pet to the store " - ([] (add-pet nil)) - ([optional-params] - (:data (add-pet-with-http-info optional-params)))) + [body ] + (:data (add-pet-with-http-info body))) (defn delete-pet-with-http-info "Deletes a pet @@ -35,7 +33,7 @@ :query-params {} :form-params {} :content-types [] - :accepts ["application/json" "application/xml"] + :accepts ["application/xml" "application/json"] :auth-names ["petstore_auth"]}))) (defn delete-pet @@ -48,48 +46,44 @@ (defn find-pets-by-status-with-http-info "Finds Pets by status Multiple status values can be provided with comma separated strings" - ([] (find-pets-by-status-with-http-info nil)) - ([{:keys [status ]}] - (call-api "/pet/findByStatus" :get - {:path-params {} - :header-params {} - :query-params {"status" (with-collection-format status :multi) } - :form-params {} - :content-types [] - :accepts ["application/json" "application/xml"] - :auth-names ["petstore_auth"]}))) + [status ] + (call-api "/pet/findByStatus" :get + {:path-params {} + :header-params {} + :query-params {"status" (with-collection-format status :csv) } + :form-params {} + :content-types [] + :accepts ["application/xml" "application/json"] + :auth-names ["petstore_auth"]})) (defn find-pets-by-status "Finds Pets by status Multiple status values can be provided with comma separated strings" - ([] (find-pets-by-status nil)) - ([optional-params] - (:data (find-pets-by-status-with-http-info optional-params)))) + [status ] + (:data (find-pets-by-status-with-http-info status))) (defn find-pets-by-tags-with-http-info "Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing." - ([] (find-pets-by-tags-with-http-info nil)) - ([{:keys [tags ]}] - (call-api "/pet/findByTags" :get - {:path-params {} - :header-params {} - :query-params {"tags" (with-collection-format tags :multi) } - :form-params {} - :content-types [] - :accepts ["application/json" "application/xml"] - :auth-names ["petstore_auth"]}))) + [tags ] + (call-api "/pet/findByTags" :get + {:path-params {} + :header-params {} + :query-params {"tags" (with-collection-format tags :csv) } + :form-params {} + :content-types [] + :accepts ["application/xml" "application/json"] + :auth-names ["petstore_auth"]})) (defn find-pets-by-tags "Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing." - ([] (find-pets-by-tags nil)) - ([optional-params] - (:data (find-pets-by-tags-with-http-info optional-params)))) + [tags ] + (:data (find-pets-by-tags-with-http-info tags))) (defn get-pet-by-id-with-http-info "Find pet by ID - Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions" + Returns a single pet" [pet-id ] (call-api "/pet/{petId}" :get {:path-params {"petId" pet-id } @@ -97,36 +91,35 @@ :query-params {} :form-params {} :content-types [] + :accepts ["application/json" "application/xml"] :auth-names ["api_key" "petstore_auth"]})) (defn get-pet-by-id "Find pet by ID - Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions" + Returns a single pet" [pet-id ] (:data (get-pet-by-id-with-http-info pet-id))) (defn update-pet-with-http-info "Update an existing pet " - ([] (update-pet-with-http-info nil)) - ([{:keys [body ]}] - (call-api "/pet" :put - {:path-params {} - :header-params {} - :query-params {} - :form-params {} - :body-param body - :content-types ["application/json" "application/xml"] - :accepts ["application/json" "application/xml"] - :auth-names ["petstore_auth"]}))) + [body ] + (call-api "/pet" :put + {:path-params {} + :header-params {} + :query-params {} + :form-params {} + :body-param body + :content-types ["application/json" "application/xml"] + :accepts ["application/xml" "application/json"] + :auth-names ["petstore_auth"]})) (defn update-pet "Update an existing pet " - ([] (update-pet nil)) - ([optional-params] - (:data (update-pet-with-http-info optional-params)))) + [body ] + (:data (update-pet-with-http-info body))) (defn update-pet-with-form-with-http-info "Updates a pet in the store with form data @@ -139,7 +132,7 @@ :query-params {} :form-params {"name" name "status" status } :content-types ["application/x-www-form-urlencoded"] - :accepts ["application/json" "application/xml"] + :accepts ["application/xml" "application/json"] :auth-names ["petstore_auth"]}))) (defn update-pet-with-form @@ -160,7 +153,7 @@ :query-params {} :form-params {"additionalMetadata" additional-metadata "file" file } :content-types ["multipart/form-data"] - :accepts ["application/json" "application/xml"] + :accepts ["application/json"] :auth-names ["petstore_auth"]}))) (defn upload-file diff --git a/samples/client/petstore/clojure/src/swagger_petstore/api/store.clj b/samples/client/petstore/clojure/src/swagger_petstore/api/store.clj index 04d185a8086..0e1bf23f41a 100644 --- a/samples/client/petstore/clojure/src/swagger_petstore/api/store.clj +++ b/samples/client/petstore/clojure/src/swagger_petstore/api/store.clj @@ -12,7 +12,7 @@ :query-params {} :form-params {} :content-types [] - :accepts ["application/json" "application/xml"] + :accepts ["application/xml" "application/json"] :auth-names []})) (defn delete-order @@ -31,7 +31,7 @@ :query-params {} :form-params {} :content-types [] - :accepts ["application/json" "application/xml"] + :accepts ["application/json"] :auth-names ["api_key"]})) (defn get-inventory @@ -50,7 +50,7 @@ :query-params {} :form-params {} :content-types [] - :accepts ["application/json" "application/xml"] + :accepts ["application/xml" "application/json"] :auth-names []})) (defn get-order-by-id @@ -62,22 +62,20 @@ (defn place-order-with-http-info "Place an order for a pet " - ([] (place-order-with-http-info nil)) - ([{:keys [body ]}] - (call-api "/store/order" :post - {:path-params {} - :header-params {} - :query-params {} - :form-params {} - :body-param body - :content-types [] - :accepts ["application/json" "application/xml"] - :auth-names []}))) + [body ] + (call-api "/store/order" :post + {:path-params {} + :header-params {} + :query-params {} + :form-params {} + :body-param body + :content-types [] + :accepts ["application/xml" "application/json"] + :auth-names []})) (defn place-order "Place an order for a pet " - ([] (place-order nil)) - ([optional-params] - (:data (place-order-with-http-info optional-params)))) + [body ] + (:data (place-order-with-http-info body))) diff --git a/samples/client/petstore/clojure/src/swagger_petstore/api/user.clj b/samples/client/petstore/clojure/src/swagger_petstore/api/user.clj index 26e3dffc624..a57846f44c4 100644 --- a/samples/client/petstore/clojure/src/swagger_petstore/api/user.clj +++ b/samples/client/petstore/clojure/src/swagger_petstore/api/user.clj @@ -5,68 +5,62 @@ (defn create-user-with-http-info "Create user This can only be done by the logged in user." - ([] (create-user-with-http-info nil)) - ([{:keys [body ]}] - (call-api "/user" :post - {:path-params {} - :header-params {} - :query-params {} - :form-params {} - :body-param body - :content-types [] - :accepts ["application/json" "application/xml"] - :auth-names []}))) + [body ] + (call-api "/user" :post + {:path-params {} + :header-params {} + :query-params {} + :form-params {} + :body-param body + :content-types [] + :accepts ["application/xml" "application/json"] + :auth-names []})) (defn create-user "Create user This can only be done by the logged in user." - ([] (create-user nil)) - ([optional-params] - (:data (create-user-with-http-info optional-params)))) + [body ] + (:data (create-user-with-http-info body))) (defn create-users-with-array-input-with-http-info "Creates list of users with given input array " - ([] (create-users-with-array-input-with-http-info nil)) - ([{:keys [body ]}] - (call-api "/user/createWithArray" :post - {:path-params {} - :header-params {} - :query-params {} - :form-params {} - :body-param body - :content-types [] - :accepts ["application/json" "application/xml"] - :auth-names []}))) + [body ] + (call-api "/user/createWithArray" :post + {:path-params {} + :header-params {} + :query-params {} + :form-params {} + :body-param body + :content-types [] + :accepts ["application/xml" "application/json"] + :auth-names []})) (defn create-users-with-array-input "Creates list of users with given input array " - ([] (create-users-with-array-input nil)) - ([optional-params] - (:data (create-users-with-array-input-with-http-info optional-params)))) + [body ] + (:data (create-users-with-array-input-with-http-info body))) (defn create-users-with-list-input-with-http-info "Creates list of users with given input array " - ([] (create-users-with-list-input-with-http-info nil)) - ([{:keys [body ]}] - (call-api "/user/createWithList" :post - {:path-params {} - :header-params {} - :query-params {} - :form-params {} - :body-param body - :content-types [] - :accepts ["application/json" "application/xml"] - :auth-names []}))) + [body ] + (call-api "/user/createWithList" :post + {:path-params {} + :header-params {} + :query-params {} + :form-params {} + :body-param body + :content-types [] + :accepts ["application/xml" "application/json"] + :auth-names []})) (defn create-users-with-list-input "Creates list of users with given input array " - ([] (create-users-with-list-input nil)) - ([optional-params] - (:data (create-users-with-list-input-with-http-info optional-params)))) + [body ] + (:data (create-users-with-list-input-with-http-info body))) (defn delete-user-with-http-info "Delete user @@ -78,7 +72,7 @@ :query-params {} :form-params {} :content-types [] - :accepts ["application/json" "application/xml"] + :accepts ["application/xml" "application/json"] :auth-names []})) (defn delete-user @@ -97,7 +91,7 @@ :query-params {} :form-params {} :content-types [] - :accepts ["application/json" "application/xml"] + :accepts ["application/xml" "application/json"] :auth-names []})) (defn get-user-by-name @@ -109,23 +103,21 @@ (defn login-user-with-http-info "Logs user into the system " - ([] (login-user-with-http-info nil)) - ([{:keys [username password ]}] - (call-api "/user/login" :get - {:path-params {} - :header-params {} - :query-params {"username" username "password" password } - :form-params {} - :content-types [] - :accepts ["application/json" "application/xml"] - :auth-names []}))) + [username password ] + (call-api "/user/login" :get + {:path-params {} + :header-params {} + :query-params {"username" username "password" password } + :form-params {} + :content-types [] + :accepts ["application/xml" "application/json"] + :auth-names []})) (defn login-user "Logs user into the system " - ([] (login-user nil)) - ([optional-params] - (:data (login-user-with-http-info optional-params)))) + [username password ] + (:data (login-user-with-http-info username password))) (defn logout-user-with-http-info "Logs out current logged in user session @@ -137,7 +129,7 @@ :query-params {} :form-params {} :content-types [] - :accepts ["application/json" "application/xml"] + :accepts ["application/xml" "application/json"] :auth-names []})) (defn logout-user @@ -149,22 +141,20 @@ (defn update-user-with-http-info "Updated user This can only be done by the logged in user." - ([username ] (update-user-with-http-info username nil)) - ([username {:keys [body ]}] - (call-api "/user/{username}" :put - {:path-params {"username" username } - :header-params {} - :query-params {} - :form-params {} - :body-param body - :content-types [] - :accepts ["application/json" "application/xml"] - :auth-names []}))) + [username body ] + (call-api "/user/{username}" :put + {:path-params {"username" username } + :header-params {} + :query-params {} + :form-params {} + :body-param body + :content-types [] + :accepts ["application/xml" "application/json"] + :auth-names []})) (defn update-user "Updated user This can only be done by the logged in user." - ([username ] (update-user username nil)) - ([username optional-params] - (:data (update-user-with-http-info username optional-params)))) + [username body ] + (:data (update-user-with-http-info username body))) From 999f901d2bdcc83b220f5c038c8352479112c8fb Mon Sep 17 00:00:00 2001 From: wing328 Date: Sat, 27 May 2017 00:33:49 +0800 Subject: [PATCH 05/10] update clojure petstore cient --- samples/client/petstore/clojure/project.clj | 2 +- .../clojure/src/swagger_petstore/api/pet.clj | 111 ++++++++------- .../src/swagger_petstore/api/store.clj | 32 +++-- .../clojure/src/swagger_petstore/api/user.clj | 134 ++++++++++-------- 4 files changed, 149 insertions(+), 130 deletions(-) diff --git a/samples/client/petstore/clojure/project.clj b/samples/client/petstore/clojure/project.clj index e64d9ef7447..b30c4b0f3fb 100644 --- a/samples/client/petstore/clojure/project.clj +++ b/samples/client/petstore/clojure/project.clj @@ -1,5 +1,5 @@ (defproject swagger-petstore "1.0.0" - :description "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters." + :description "This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters" :license {:name "Apache 2.0" :url "http://www.apache.org/licenses/LICENSE-2.0.html"} :dependencies [[org.clojure/clojure "1.7.0"] diff --git a/samples/client/petstore/clojure/src/swagger_petstore/api/pet.clj b/samples/client/petstore/clojure/src/swagger_petstore/api/pet.clj index 92ab5e13218..344ea3bb1f8 100644 --- a/samples/client/petstore/clojure/src/swagger_petstore/api/pet.clj +++ b/samples/client/petstore/clojure/src/swagger_petstore/api/pet.clj @@ -5,22 +5,24 @@ (defn add-pet-with-http-info "Add a new pet to the store " - [body ] - (call-api "/pet" :post - {:path-params {} - :header-params {} - :query-params {} - :form-params {} - :body-param body - :content-types ["application/json" "application/xml"] - :accepts ["application/xml" "application/json"] - :auth-names ["petstore_auth"]})) + ([] (add-pet-with-http-info nil)) + ([{:keys [body ]}] + (call-api "/pet" :post + {:path-params {} + :header-params {} + :query-params {} + :form-params {} + :body-param body + :content-types ["application/json" "application/xml"] + :accepts ["application/json" "application/xml"] + :auth-names ["petstore_auth"]}))) (defn add-pet "Add a new pet to the store " - [body ] - (:data (add-pet-with-http-info body))) + ([] (add-pet nil)) + ([optional-params] + (:data (add-pet-with-http-info optional-params)))) (defn delete-pet-with-http-info "Deletes a pet @@ -33,7 +35,7 @@ :query-params {} :form-params {} :content-types [] - :accepts ["application/xml" "application/json"] + :accepts ["application/json" "application/xml"] :auth-names ["petstore_auth"]}))) (defn delete-pet @@ -46,44 +48,48 @@ (defn find-pets-by-status-with-http-info "Finds Pets by status Multiple status values can be provided with comma separated strings" - [status ] - (call-api "/pet/findByStatus" :get - {:path-params {} - :header-params {} - :query-params {"status" (with-collection-format status :csv) } - :form-params {} - :content-types [] - :accepts ["application/xml" "application/json"] - :auth-names ["petstore_auth"]})) + ([] (find-pets-by-status-with-http-info nil)) + ([{:keys [status ]}] + (call-api "/pet/findByStatus" :get + {:path-params {} + :header-params {} + :query-params {"status" (with-collection-format status :multi) } + :form-params {} + :content-types [] + :accepts ["application/json" "application/xml"] + :auth-names ["petstore_auth"]}))) (defn find-pets-by-status "Finds Pets by status Multiple status values can be provided with comma separated strings" - [status ] - (:data (find-pets-by-status-with-http-info status))) + ([] (find-pets-by-status nil)) + ([optional-params] + (:data (find-pets-by-status-with-http-info optional-params)))) (defn find-pets-by-tags-with-http-info "Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing." - [tags ] - (call-api "/pet/findByTags" :get - {:path-params {} - :header-params {} - :query-params {"tags" (with-collection-format tags :csv) } - :form-params {} - :content-types [] - :accepts ["application/xml" "application/json"] - :auth-names ["petstore_auth"]})) + ([] (find-pets-by-tags-with-http-info nil)) + ([{:keys [tags ]}] + (call-api "/pet/findByTags" :get + {:path-params {} + :header-params {} + :query-params {"tags" (with-collection-format tags :multi) } + :form-params {} + :content-types [] + :accepts ["application/json" "application/xml"] + :auth-names ["petstore_auth"]}))) (defn find-pets-by-tags "Finds Pets by tags Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing." - [tags ] - (:data (find-pets-by-tags-with-http-info tags))) + ([] (find-pets-by-tags nil)) + ([optional-params] + (:data (find-pets-by-tags-with-http-info optional-params)))) (defn get-pet-by-id-with-http-info "Find pet by ID - Returns a single pet" + Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions" [pet-id ] (call-api "/pet/{petId}" :get {:path-params {"petId" pet-id } @@ -91,35 +97,36 @@ :query-params {} :form-params {} :content-types [] - :accepts ["application/json" "application/xml"] :auth-names ["api_key" "petstore_auth"]})) (defn get-pet-by-id "Find pet by ID - Returns a single pet" + Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions" [pet-id ] (:data (get-pet-by-id-with-http-info pet-id))) (defn update-pet-with-http-info "Update an existing pet " - [body ] - (call-api "/pet" :put - {:path-params {} - :header-params {} - :query-params {} - :form-params {} - :body-param body - :content-types ["application/json" "application/xml"] - :accepts ["application/xml" "application/json"] - :auth-names ["petstore_auth"]})) + ([] (update-pet-with-http-info nil)) + ([{:keys [body ]}] + (call-api "/pet" :put + {:path-params {} + :header-params {} + :query-params {} + :form-params {} + :body-param body + :content-types ["application/json" "application/xml"] + :accepts ["application/json" "application/xml"] + :auth-names ["petstore_auth"]}))) (defn update-pet "Update an existing pet " - [body ] - (:data (update-pet-with-http-info body))) + ([] (update-pet nil)) + ([optional-params] + (:data (update-pet-with-http-info optional-params)))) (defn update-pet-with-form-with-http-info "Updates a pet in the store with form data @@ -132,7 +139,7 @@ :query-params {} :form-params {"name" name "status" status } :content-types ["application/x-www-form-urlencoded"] - :accepts ["application/xml" "application/json"] + :accepts ["application/json" "application/xml"] :auth-names ["petstore_auth"]}))) (defn update-pet-with-form @@ -153,7 +160,7 @@ :query-params {} :form-params {"additionalMetadata" additional-metadata "file" file } :content-types ["multipart/form-data"] - :accepts ["application/json"] + :accepts ["application/json" "application/xml"] :auth-names ["petstore_auth"]}))) (defn upload-file diff --git a/samples/client/petstore/clojure/src/swagger_petstore/api/store.clj b/samples/client/petstore/clojure/src/swagger_petstore/api/store.clj index 0e1bf23f41a..04d185a8086 100644 --- a/samples/client/petstore/clojure/src/swagger_petstore/api/store.clj +++ b/samples/client/petstore/clojure/src/swagger_petstore/api/store.clj @@ -12,7 +12,7 @@ :query-params {} :form-params {} :content-types [] - :accepts ["application/xml" "application/json"] + :accepts ["application/json" "application/xml"] :auth-names []})) (defn delete-order @@ -31,7 +31,7 @@ :query-params {} :form-params {} :content-types [] - :accepts ["application/json"] + :accepts ["application/json" "application/xml"] :auth-names ["api_key"]})) (defn get-inventory @@ -50,7 +50,7 @@ :query-params {} :form-params {} :content-types [] - :accepts ["application/xml" "application/json"] + :accepts ["application/json" "application/xml"] :auth-names []})) (defn get-order-by-id @@ -62,20 +62,22 @@ (defn place-order-with-http-info "Place an order for a pet " - [body ] - (call-api "/store/order" :post - {:path-params {} - :header-params {} - :query-params {} - :form-params {} - :body-param body - :content-types [] - :accepts ["application/xml" "application/json"] - :auth-names []})) + ([] (place-order-with-http-info nil)) + ([{:keys [body ]}] + (call-api "/store/order" :post + {:path-params {} + :header-params {} + :query-params {} + :form-params {} + :body-param body + :content-types [] + :accepts ["application/json" "application/xml"] + :auth-names []}))) (defn place-order "Place an order for a pet " - [body ] - (:data (place-order-with-http-info body))) + ([] (place-order nil)) + ([optional-params] + (:data (place-order-with-http-info optional-params)))) diff --git a/samples/client/petstore/clojure/src/swagger_petstore/api/user.clj b/samples/client/petstore/clojure/src/swagger_petstore/api/user.clj index a57846f44c4..26e3dffc624 100644 --- a/samples/client/petstore/clojure/src/swagger_petstore/api/user.clj +++ b/samples/client/petstore/clojure/src/swagger_petstore/api/user.clj @@ -5,62 +5,68 @@ (defn create-user-with-http-info "Create user This can only be done by the logged in user." - [body ] - (call-api "/user" :post - {:path-params {} - :header-params {} - :query-params {} - :form-params {} - :body-param body - :content-types [] - :accepts ["application/xml" "application/json"] - :auth-names []})) + ([] (create-user-with-http-info nil)) + ([{:keys [body ]}] + (call-api "/user" :post + {:path-params {} + :header-params {} + :query-params {} + :form-params {} + :body-param body + :content-types [] + :accepts ["application/json" "application/xml"] + :auth-names []}))) (defn create-user "Create user This can only be done by the logged in user." - [body ] - (:data (create-user-with-http-info body))) + ([] (create-user nil)) + ([optional-params] + (:data (create-user-with-http-info optional-params)))) (defn create-users-with-array-input-with-http-info "Creates list of users with given input array " - [body ] - (call-api "/user/createWithArray" :post - {:path-params {} - :header-params {} - :query-params {} - :form-params {} - :body-param body - :content-types [] - :accepts ["application/xml" "application/json"] - :auth-names []})) + ([] (create-users-with-array-input-with-http-info nil)) + ([{:keys [body ]}] + (call-api "/user/createWithArray" :post + {:path-params {} + :header-params {} + :query-params {} + :form-params {} + :body-param body + :content-types [] + :accepts ["application/json" "application/xml"] + :auth-names []}))) (defn create-users-with-array-input "Creates list of users with given input array " - [body ] - (:data (create-users-with-array-input-with-http-info body))) + ([] (create-users-with-array-input nil)) + ([optional-params] + (:data (create-users-with-array-input-with-http-info optional-params)))) (defn create-users-with-list-input-with-http-info "Creates list of users with given input array " - [body ] - (call-api "/user/createWithList" :post - {:path-params {} - :header-params {} - :query-params {} - :form-params {} - :body-param body - :content-types [] - :accepts ["application/xml" "application/json"] - :auth-names []})) + ([] (create-users-with-list-input-with-http-info nil)) + ([{:keys [body ]}] + (call-api "/user/createWithList" :post + {:path-params {} + :header-params {} + :query-params {} + :form-params {} + :body-param body + :content-types [] + :accepts ["application/json" "application/xml"] + :auth-names []}))) (defn create-users-with-list-input "Creates list of users with given input array " - [body ] - (:data (create-users-with-list-input-with-http-info body))) + ([] (create-users-with-list-input nil)) + ([optional-params] + (:data (create-users-with-list-input-with-http-info optional-params)))) (defn delete-user-with-http-info "Delete user @@ -72,7 +78,7 @@ :query-params {} :form-params {} :content-types [] - :accepts ["application/xml" "application/json"] + :accepts ["application/json" "application/xml"] :auth-names []})) (defn delete-user @@ -91,7 +97,7 @@ :query-params {} :form-params {} :content-types [] - :accepts ["application/xml" "application/json"] + :accepts ["application/json" "application/xml"] :auth-names []})) (defn get-user-by-name @@ -103,21 +109,23 @@ (defn login-user-with-http-info "Logs user into the system " - [username password ] - (call-api "/user/login" :get - {:path-params {} - :header-params {} - :query-params {"username" username "password" password } - :form-params {} - :content-types [] - :accepts ["application/xml" "application/json"] - :auth-names []})) + ([] (login-user-with-http-info nil)) + ([{:keys [username password ]}] + (call-api "/user/login" :get + {:path-params {} + :header-params {} + :query-params {"username" username "password" password } + :form-params {} + :content-types [] + :accepts ["application/json" "application/xml"] + :auth-names []}))) (defn login-user "Logs user into the system " - [username password ] - (:data (login-user-with-http-info username password))) + ([] (login-user nil)) + ([optional-params] + (:data (login-user-with-http-info optional-params)))) (defn logout-user-with-http-info "Logs out current logged in user session @@ -129,7 +137,7 @@ :query-params {} :form-params {} :content-types [] - :accepts ["application/xml" "application/json"] + :accepts ["application/json" "application/xml"] :auth-names []})) (defn logout-user @@ -141,20 +149,22 @@ (defn update-user-with-http-info "Updated user This can only be done by the logged in user." - [username body ] - (call-api "/user/{username}" :put - {:path-params {"username" username } - :header-params {} - :query-params {} - :form-params {} - :body-param body - :content-types [] - :accepts ["application/xml" "application/json"] - :auth-names []})) + ([username ] (update-user-with-http-info username nil)) + ([username {:keys [body ]}] + (call-api "/user/{username}" :put + {:path-params {"username" username } + :header-params {} + :query-params {} + :form-params {} + :body-param body + :content-types [] + :accepts ["application/json" "application/xml"] + :auth-names []}))) (defn update-user "Updated user This can only be done by the logged in user." - [username body ] - (:data (update-user-with-http-info username body))) + ([username ] (update-user username nil)) + ([username optional-params] + (:data (update-user-with-http-info username optional-params)))) From 3d97d83f7a45e01da84df1adc3e7de6f05517055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Winkelmeyer?= Date: Mon, 29 May 2017 05:16:06 +0200 Subject: [PATCH 06/10] Apex update for NamedCredentials and Salesforce DX (#5717) * Added mustache file for namedCredentials * Removed Basic and OAuth from Apex API in favor of NamedCredentials * Moved old README to README for ant deployment * Added SFDX OSS descriptor * Removed remoteSite mustache * Changed package.xml from RemoteSite to NamedCredential * Update ApexClientCodegen to support SFDX and namedCredentials * Created initial README for Salesforce DX * Ran Petstore test for Apex commit * Fixed error in README mustache --- .../codegen/languages/ApexClientCodegen.java | 105 +++-- .../{README.mustache => README_ant.mustache} | 0 .../main/resources/apex/README_sfdx.mustache | 114 +++++ .../src/main/resources/apex/Swagger.cls | 88 +--- .../src/main/resources/apex/SwaggerTest.cls | 416 ------------------ .../src/main/resources/apex/api_test.mustache | 14 +- .../src/main/resources/apex/client.mustache | 10 +- .../resources/apex/namedCredential.mustache | 7 + .../src/main/resources/apex/package.mustache | 2 +- .../main/resources/apex/remoteSite.mustache | 7 - .../src/main/resources/apex/sfdx.mustache | 10 + .../client/petstore/apex/docs/SwagPetApi.md | 4 +- .../client/petstore/apex/docs/SwagStoreApi.md | 2 +- .../client/petstore/apex/docs/SwagUserApi.md | 4 +- .../main/default/classes/SwagApiResponse.cls | 69 +++ .../classes/SwagApiResponse.cls-meta.xml | 5 + .../default/classes/SwagApiResponseTest.cls | 87 ++++ .../classes/SwagApiResponseTest.cls-meta.xml | 5 + .../main/default/classes/SwagCategory.cls | 52 +++ .../default/classes/SwagCategory.cls-meta.xml | 5 + .../main/default/classes/SwagCategoryTest.cls | 80 ++++ .../classes/SwagCategoryTest.cls-meta.xml | 5 + .../main/default/classes/SwagClient.cls | 7 + .../default/classes/SwagClient.cls-meta.xml | 5 + .../main/default/classes/SwagOrder.cls | 101 +++++ .../default/classes/SwagOrder.cls-meta.xml | 5 + .../main/default/classes/SwagOrderTest.cls | 91 ++++ .../classes/SwagOrderTest.cls-meta.xml | 5 + .../main/default/classes/SwagPet.cls | 102 +++++ .../main/default/classes/SwagPet.cls-meta.xml | 5 + .../main/default/classes/SwagPetApi.cls | 241 ++++++++++ .../default/classes/SwagPetApi.cls-meta.xml | 5 + .../main/default/classes/SwagPetApiTest.cls | 233 ++++++++++ .../classes/SwagPetApiTest.cls-meta.xml | 5 + .../main/default/classes/SwagPetTest.cls | 91 ++++ .../default/classes/SwagPetTest.cls-meta.xml | 5 + .../main/default/classes/SwagStoreApi.cls | 122 +++++ .../default/classes/SwagStoreApi.cls-meta.xml | 5 + .../main/default/classes/SwagStoreApiTest.cls | 115 +++++ .../classes/SwagStoreApiTest.cls-meta.xml | 5 + .../main/default/classes/SwagTag.cls | 52 +++ .../main/default/classes/SwagTag.cls-meta.xml | 5 + .../main/default/classes/SwagTagTest.cls | 80 ++++ .../default/classes/SwagTagTest.cls-meta.xml | 5 + .../main/default/classes/SwagUser.cls | 106 +++++ .../default/classes/SwagUser.cls-meta.xml | 5 + .../main/default/classes/SwagUserApi.cls | 223 ++++++++++ .../default/classes/SwagUserApi.cls-meta.xml | 5 + .../main/default/classes/SwagUserApiTest.cls | 204 +++++++++ .../classes/SwagUserApiTest.cls-meta.xml | 5 + .../main/default/classes/SwagUserTest.cls | 80 ++++ .../default/classes/SwagUserTest.cls-meta.xml | 5 + .../main/default/classes/Swagger.cls | 313 +++++++++++++ .../main/default/classes/Swagger.cls-meta.xml | 5 + .../default/classes/SwaggerResponseMock.cls | 18 + .../classes/SwaggerResponseMock.cls-meta.xml | 5 + .../main/default/classes/SwaggerTest.cls | 366 +++++++++++++++ .../default/classes/SwaggerTest.cls-meta.xml | 5 + .../Swagger_Petstore.namedCredential | 7 + 59 files changed, 3172 insertions(+), 561 deletions(-) rename modules/swagger-codegen/src/main/resources/apex/{README.mustache => README_ant.mustache} (100%) create mode 100644 modules/swagger-codegen/src/main/resources/apex/README_sfdx.mustache create mode 100644 modules/swagger-codegen/src/main/resources/apex/namedCredential.mustache delete mode 100644 modules/swagger-codegen/src/main/resources/apex/remoteSite.mustache create mode 100644 modules/swagger-codegen/src/main/resources/apex/sfdx.mustache create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponse.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponse.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponseTest.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponseTest.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagCategory.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagCategory.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagCategoryTest.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagCategoryTest.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagClient.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagClient.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagOrder.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagOrder.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagOrderTest.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagOrderTest.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagPet.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagPet.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagPetApi.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagPetApi.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagPetApiTest.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagPetApiTest.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagPetTest.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagPetTest.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApi.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApi.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApiTest.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApiTest.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagTag.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagTag.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagTagTest.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagTagTest.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagUser.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagUser.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagUserApi.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagUserApi.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagUserApiTest.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagUserApiTest.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagUserTest.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwagUserTest.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/Swagger.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/Swagger.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwaggerResponseMock.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwaggerResponseMock.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwaggerTest.cls create mode 100644 samples/client/petstore/apex/force-app/main/default/classes/SwaggerTest.cls-meta.xml create mode 100644 samples/client/petstore/apex/force-app/main/default/namedCredentials/Swagger_Petstore.namedCredential diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ApexClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ApexClientCodegen.java index 775e8f43e22..41cc0b37270 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ApexClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ApexClientCodegen.java @@ -17,21 +17,27 @@ public class ApexClientCodegen extends AbstractJavaCodegen { private static final String CLASS_PREFIX = "classPrefix"; private static final String API_VERSION = "apiVersion"; + private static final String BUILD_METHOD = "buildMethod"; + private static final String NAMED_CREDENTIAL = "namedCredential"; private static final Logger LOGGER = LoggerFactory.getLogger(ApexClientCodegen.class); private String classPrefix = "Swag"; private String apiVersion = "39.0"; + private String buildMethod = "sfdx"; + private String namedCredential = classPrefix; + private String srcPath = "force-app/main/default/"; public ApexClientCodegen() { super(); importMapping.clear(); + testFolder = sourceFolder = srcPath; + embeddedTemplateDir = templateDir = "apex"; outputFolder = "generated-code" + File.separator + "apex"; - testFolder = sourceFolder = "deploy"; apiPackage = "classes"; modelPackage = "classes"; - testPackage = "deploy.classes"; + testPackage = "force-app.main.default.classes"; modelNamePrefix = classPrefix; dateLibrary = ""; @@ -46,22 +52,15 @@ public class ApexClientCodegen extends AbstractJavaCodegen { cliOptions.add(CliOption.newString(CLASS_PREFIX, "Prefix for generated classes. Set this to avoid overwriting existing classes in your org.")); cliOptions.add(CliOption.newString(API_VERSION, "The Metadata API version number to use for components in this package.")); + cliOptions.add(CliOption.newString(BUILD_METHOD, "The build method for this package.")); + cliOptions.add(CliOption.newString(NAMED_CREDENTIAL, "The named credential name for the HTTP callouts")); - supportingFiles.add(new SupportingFile("package.mustache", "deploy", "package.xml")); - supportingFiles.add(new SupportingFile("package.mustache", "undeploy", "destructiveChanges.xml")); - supportingFiles.add(new SupportingFile("build.mustache", "build.xml")); - supportingFiles.add(new SupportingFile("build.properties", "build.properties")); - supportingFiles.add(new SupportingFile("remove.package.mustache", "undeploy", "package.xml")); - supportingFiles.add(new SupportingFile("Swagger.cls", "deploy/classes", "Swagger.cls")); - supportingFiles.add(new SupportingFile("cls-meta.mustache", "deploy/classes", "Swagger.cls-meta.xml")); - supportingFiles.add(new SupportingFile("SwaggerTest.cls", "deploy/classes", "SwaggerTest.cls")); - supportingFiles.add(new SupportingFile("cls-meta.mustache", "deploy/classes", "SwaggerTest.cls-meta.xml")); - supportingFiles.add(new SupportingFile("SwaggerResponseMock.cls", "deploy/classes", "SwaggerResponseMock.cls")); - supportingFiles.add(new SupportingFile("cls-meta.mustache", "deploy/classes", "SwaggerResponseMock.cls-meta.xml")); - supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); - supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); - - writeOptional(outputFolder, new SupportingFile("README.mustache", "README.md")); + supportingFiles.add(new SupportingFile("Swagger.cls", srcPath + "classes", "Swagger.cls")); + supportingFiles.add(new SupportingFile("cls-meta.mustache", srcPath + "classes", "Swagger.cls-meta.xml")); + supportingFiles.add(new SupportingFile("SwaggerTest.cls", srcPath + "classes", "SwaggerTest.cls")); + supportingFiles.add(new SupportingFile("cls-meta.mustache", srcPath + "classes", "SwaggerTest.cls-meta.xml")); + supportingFiles.add(new SupportingFile("SwaggerResponseMock.cls", srcPath + "classes", "SwaggerResponseMock.cls")); + supportingFiles.add(new SupportingFile("cls-meta.mustache", srcPath + "classes", "SwaggerResponseMock.cls-meta.xml")); typeMapping.put("BigDecimal", "Double"); typeMapping.put("binary", "String"); @@ -114,6 +113,16 @@ public class ApexClientCodegen extends AbstractJavaCodegen { } additionalProperties.put(API_VERSION, apiVersion); + if (additionalProperties.containsKey(BUILD_METHOD)) { + setBuildMethod((String)additionalProperties.get(BUILD_METHOD)); + } + additionalProperties.put(BUILD_METHOD, buildMethod); + + if (additionalProperties.containsKey(NAMED_CREDENTIAL)) { + setNamedCredential((String)additionalProperties.get(NAMED_CREDENTIAL)); + } + additionalProperties.put(NAMED_CREDENTIAL, namedCredential); + postProcessOpts(); } @@ -232,18 +241,20 @@ public class ApexClientCodegen extends AbstractJavaCodegen { @Override public void preprocessSwagger(Swagger swagger) { Info info = swagger.getInfo(); - String description = info.getDescription(); - String sanitized = sanitizeName(info.getTitle()); - additionalProperties.put("sanitizedName", sanitized); - supportingFiles.add(new SupportingFile("remoteSite.mustache", "deploy/remoteSiteSettings", - sanitized + ".remoteSite" + String calloutLabel = info.getTitle(); + additionalProperties.put("calloutLabel", calloutLabel); + String sanitized = sanitizeName(calloutLabel); + additionalProperties.put("calloutName", sanitized); + supportingFiles.add(new SupportingFile("namedCredential.mustache", srcPath + "/namedCredentials", + sanitized + ".namedCredential" )); - // max length for description for a Remote Site setting - if (description != null && description.length() > 255) { - description = description.substring(0, 255); + if (additionalProperties.get(BUILD_METHOD).equals("sfdx")) { + generateSfdxSupportingFiles(); + } else if (additionalProperties.get(BUILD_METHOD).equals("ant")) { + generateAntSupportingFiles(); } - additionalProperties.put("shortDescription", description); + } @Override @@ -289,6 +300,20 @@ public class ApexClientCodegen extends AbstractJavaCodegen { return input.replace("'", "\\'"); } + public void setBuildMethod(String buildMethod) { + if (buildMethod.equals("ant")) { + this.srcPath = "deploy/"; + } else { + this.srcPath = "src/"; + } + testFolder = sourceFolder = srcPath; + this.buildMethod = buildMethod; + } + + public void setNamedCredential(String namedCredential) { + this.namedCredential = namedCredential; + } + public void setClassPrefix(String classPrefix) { // the best thing we can do without namespacing in Apex modelNamePrefix = classPrefix; @@ -310,8 +335,8 @@ public class ApexClientCodegen extends AbstractJavaCodegen { private void postProcessOpts() { supportingFiles.add( - new SupportingFile("client.mustache", "deploy/classes", classPrefix + "Client.cls")); - supportingFiles.add(new SupportingFile("cls-meta.mustache", "deploy/classes", + new SupportingFile("client.mustache", srcPath + "classes", classPrefix + "Client.cls")); + supportingFiles.add(new SupportingFile("cls-meta.mustache", srcPath + "classes", classPrefix + "Client.cls-meta.xml" )); } @@ -451,4 +476,28 @@ public class ApexClientCodegen extends AbstractJavaCodegen { public String getHelp() { return "Generates an Apex API client library (beta)."; } + + private void generateAntSupportingFiles() { + + supportingFiles.add(new SupportingFile("package.mustache", "deploy", "package.xml")); + supportingFiles.add(new SupportingFile("package.mustache", "undeploy", "destructiveChanges.xml")); + supportingFiles.add(new SupportingFile("build.mustache", "build.xml")); + supportingFiles.add(new SupportingFile("build.properties", "build.properties")); + supportingFiles.add(new SupportingFile("remove.package.mustache", "undeploy", "package.xml")); + supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); + supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); + + writeOptional(outputFolder, new SupportingFile("README_ant.mustache", "README.md")); + + } + + private void generateSfdxSupportingFiles() { + + supportingFiles.add(new SupportingFile("sfdx.mustache", "", "sfdx-oss-manifest.json")); + + writeOptional(outputFolder, new SupportingFile("README_sfdx.mustache", "README.md")); + + } + + } diff --git a/modules/swagger-codegen/src/main/resources/apex/README.mustache b/modules/swagger-codegen/src/main/resources/apex/README_ant.mustache similarity index 100% rename from modules/swagger-codegen/src/main/resources/apex/README.mustache rename to modules/swagger-codegen/src/main/resources/apex/README_ant.mustache diff --git a/modules/swagger-codegen/src/main/resources/apex/README_sfdx.mustache b/modules/swagger-codegen/src/main/resources/apex/README_sfdx.mustache new file mode 100644 index 00000000000..50f428b5128 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/apex/README_sfdx.mustache @@ -0,0 +1,114 @@ +# {{appName}} API Client +{{#appDescription}} + +{{{appDescription}}} +{{/appDescription}} + +## Requirements + +- [Salesforce DX](https://www.salesforce.com/products/platform/products/salesforce-dx/) + + +If everything is set correctly: + +- Running `sfdx version` in a command prompt should output something like: + + ```bash + sfdx-cli/5.7.5-05549de (darwin-amd64) go1.7.5 sfdxstable + ``` + + +## Installation + +1. Copy the output into your Salesforce DX folder - or alternatively deploy the output directly into the workspace. +2. Deploy the code via Salesforce DX to your Scratch Org + + ```bash + $ sfdx force:source:push + ``` +3. If the API needs authentication update the Named Credential in Setup. +4. Run your Apex tests using + + ```bash + $ sfdx sfdx force:apex:test:run + ``` +5. Retrieve the job id from the console and check the test results. + + ```bash + $ sfdx force:apex:test:report -i theJobId + ``` + + +## Getting Started + +Please follow the [installation](#installation) instruction and execute the following Apex code: + +```java{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} +{{classname}} api = new {{classname}}(); +{{#hasAuthMethods}} +{{classPrefix}}Client client = api.getClient(); +{{#isApiKey}} +// Configure API key authorization: {{{name}}} +ApiKeyAuth {{{name}}} = (ApiKeyAuth) client.getAuthentication('{{{name}}}'); +{{{name}}}.setApiKey('YOUR API KEY');{{/isApiKey}} +{{/hasAuthMethods}} +{{#hasParams}} + +Map params = new Map{ + {{#allParams}} + '{{{paramName}}}' => {{{example}}}{{#hasMore}},{{/hasMore}} + {{/allParams}} +}; +{{/hasParams}} + +try { + // cross your fingers + {{#returnType}}{{{returnType}}} result = {{/returnType}}api.{{{operationId}}}({{#hasParams}}params{{/hasParams}}); + {{#returnType}} + System.debug(result); + {{/returnType}} +} catch (Swagger.ApiException e) { + // ...handle your exceptions +}{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} +``` + +## Documentation for API Endpoints + +All URIs are relative to *{{basePath}}* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}} +{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} + +## Documentation for Models + +{{#models}}{{#model}} - [{{classname}}]({{modelDocPath}}{{classname}}.md) +{{/model}}{{/models}} + +## Documentation for Authorization + +{{^authMethods}}All endpoints do not require authorization. +{{/authMethods}}Authentication schemes defined for the API: +{{#authMethods}}### {{name}} + +{{#isApiKey}}- **Type**: API key +- **API key parameter name**: {{keyParamName}} +- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}} +{{/isApiKey}} +{{#isBasic}}- **Type**: HTTP basic authentication +{{/isBasic}} +{{#isOAuth}}- **Type**: OAuth +- **Flow**: {{flow}} +- **Authorizatoin URL**: {{authorizationUrl}} +- **Scopes**: {{^scopes}}N/A{{/scopes}} +{{#scopes}} - {{scope}}: {{description}} +{{/scopes}} +{{/isOAuth}} + +{{/authMethods}} + +## Author + +{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}} +{{/hasMore}}{{/apis}}{{/apiInfo}} diff --git a/modules/swagger-codegen/src/main/resources/apex/Swagger.cls b/modules/swagger-codegen/src/main/resources/apex/Swagger.cls index 0a7a1b106a7..172c3038111 100644 --- a/modules/swagger-codegen/src/main/resources/apex/Swagger.cls +++ b/modules/swagger-codegen/src/main/resources/apex/Swagger.cls @@ -65,50 +65,7 @@ public class Swagger { } } - public class HttpBasicAuth implements Authentication { - private String username = ''; - private String password = ''; - - public void setUsername(String username) { - this.username = username; - } - - public void setPassword(String password) { - this.password = password; - } - - public void setCredentials(String username, String password) { - setUsername(username); - setPassword(password); - } - - @TestVisible - private String getHeaderValue() { - return 'Basic ' + EncodingUtil.base64Encode(Blob.valueOf(username + ':' + password)); - } - - public void apply(Map headers, List query) { - headers.put('Authorization', getHeaderValue()); - } - } - - public class OAuth2 implements Authentication { - private String accessToken = ''; - - public void setAccessToken(String accessToken) { - this.accessToken = accessToken; - } - - @TestVisible - private String getHeaderValue() { - return 'Bearer ' + accessToken; - } - - public void apply(Map headers, List query) { - headers.put('Authorization', getHeaderValue()); - } - } - + public class ApiException extends Exception { private final Integer code; private final String status; @@ -144,6 +101,7 @@ public class Swagger { protected String preferredContentType = 'application/json'; protected String preferredAccept = 'application/json'; protected final String basePath; + protected final String calloutName; @TestVisible protected final Map authentications = new Map(); @@ -152,36 +110,6 @@ public class Swagger { return authentications.get(authName); } - public virtual void setUsername(String username) { - for (Authentication auth : authentications.values()) { - if (auth instanceof HttpBasicAuth) { - ((HttpBasicAuth) auth).setUsername(username); - return; - } - } - throw new NoSuchElementException('No HTTP basic authentication configured!'); - } - - public virtual void setPassword(String password) { - for (Authentication auth : authentications.values()) { - if (auth instanceof HttpBasicAuth) { - ((HttpBasicAuth) auth).setPassword(password); - return; - } - } - throw new NoSuchElementException('No HTTP basic authentication configured!'); - } - - public virtual void setCredentials(String username, String password) { - for (Authentication auth : authentications.values()) { - if (auth instanceof HttpBasicAuth) { - ((HttpBasicAuth) auth).setCredentials(username, password); - return; - } - } - throw new NoSuchElementException('No HTTP basic authentication configured!'); - } - public virtual void setApiKey(String apiKey) { for (Authentication auth : authentications.values()) { if (auth instanceof ApiKeyAuth) { @@ -192,16 +120,6 @@ public class Swagger { throw new NoSuchElementException('No API key authentication configured!'); } - public virtual void setAccessToken(String accessToken) { - for (Authentication auth : authentications.values()) { - if (auth instanceof OAuth2) { - ((OAuth2) auth).setAccessToken(accessToken); - return; - } - } - throw new NoSuchElementException('No OAuth2 authentication configured!'); - } - public List makeParams(String name, List values) { List pairs = new List(); for (Object value : new List(values)) { @@ -380,7 +298,7 @@ public class Swagger { protected virtual String toEndpoint(String path, Map params, List queryParams) { String query = '?' + paramsToString(queryParams); - return basePath + toPath(path, params) + query.removeEnd('?'); + return '"callout:' + calloutName + toPath(path, params) + query.removeEnd('?') + '""'; } @TestVisible diff --git a/modules/swagger-codegen/src/main/resources/apex/SwaggerTest.cls b/modules/swagger-codegen/src/main/resources/apex/SwaggerTest.cls index dcbca6cdd94..e3cec8831c6 100644 --- a/modules/swagger-codegen/src/main/resources/apex/SwaggerTest.cls +++ b/modules/swagger-codegen/src/main/resources/apex/SwaggerTest.cls @@ -35,217 +35,17 @@ private class SwaggerTest { System.assertEquals('auth_token=foo-bar-api-key', query.get(0).toString()); } - @isTest - private static void HttpBasicAuth_base64EncodeCredentials() { - Map headers = new Map(); - List query = new List(); - Swagger.HttpBasicAuth auth = new Swagger.HttpBasicAuth(); - auth.setCredentials('username', 'password'); - auth.apply(headers, query); - - System.assert(query.isEmpty()); - System.assertEquals(1, headers.size()); - System.assertEquals('Basic dXNlcm5hbWU6cGFzc3dvcmQ=', headers.get('Authorization')); - } - - @isTest - private static void HttpBasicAuth_base64EncodeUsernamePassword() { - Map headers = new Map(); - List query = new List(); - Swagger.HttpBasicAuth auth = new Swagger.HttpBasicAuth(); - auth.setUsername('username'); - auth.setPassword('password'); - auth.apply(headers, query); - - System.assert(query.isEmpty()); - System.assertEquals(1, headers.size()); - System.assertEquals('Basic dXNlcm5hbWU6cGFzc3dvcmQ=', headers.get('Authorization')); - } - - @isTest - private static void OAuth2_tokenInAuthorizationHeaderWithBearerPrefix() { - Map headers = new Map(); - List query = new List(); - Swagger.OAuth2 auth = new Swagger.OAuth2(); - auth.setAccessToken('foo-bar-api-key'); - auth.apply(headers, query); - - System.assert(query.isEmpty()); - System.assertEquals(1, headers.size()); - System.assertEquals('Bearer foo-bar-api-key', headers.get('Authorization')); - } - @isTest private static void ApiClient_returnAuthenticationMatchingInput() { MockApiClient client = new MockApiClient(); Swagger.ApiKeyHeaderAuth auth1 = new Swagger.ApiKeyHeaderAuth('foo'); Swagger.ApiKeyQueryAuth auth2 = new Swagger.ApiKeyQueryAuth('foo'); - Swagger.HttpBasicAuth auth3 = new Swagger.HttpBasicAuth(); - Swagger.OAuth2 auth4 = new Swagger.OAuth2(); client.authentications.put('auth1', auth1); client.authentications.put('auth2', auth2); - client.authentications.put('auth3', auth3); - client.authentications.put('auth4', auth4); System.assertEquals(auth1, client.getAuthentication('auth1')); System.assertEquals(auth2, client.getAuthentication('auth2')); - System.assertEquals(auth3, client.getAuthentication('auth3')); - System.assertEquals(auth4, client.getAuthentication('auth4')); - } - - @isTest - private static void ApiClient_noAuthenticationsMatchInputReturnNull() { - MockApiClient client = new MockApiClient(); - Swagger.OAuth2 auth = new Swagger.OAuth2(); - client.authentications.put('auth', auth); - - System.assertEquals(auth, client.getAuthentication('auth')); - System.assertEquals(null, client.getAuthentication('no-auth')); - } - - @isTest - private static void ApiClient_setUsernamePasswordFirstBasicAuthOnly() { - MockApiClient client = new MockApiClient(); - Swagger.OAuth2 auth1 = new Swagger.OAuth2(); - Swagger.ApiKeyQueryAuth auth2 = new Swagger.ApiKeyQueryAuth('auth2'); - Swagger.ApiKeyHeaderAuth auth3 = new Swagger.ApiKeyHeaderAuth('auth3'); - Swagger.HttpBasicAuth auth4 = new Swagger.HttpBasicAuth(); - Swagger.HttpBasicAuth auth5 = new Swagger.HttpBasicAuth(); - client.authentications.put('auth1', auth1); - client.authentications.put('auth2', auth2); - client.authentications.put('auth3', auth3); - client.authentications.put('auth4', auth4); - client.authentications.put('auth5', auth5); - client.setUsername('username'); - client.setPassword('password'); - - System.assertEquals('Bearer ', auth1.getHeaderValue()); - System.assertEquals('', auth2.getApiKey()); - System.assertEquals('', auth3.getApiKey()); - System.assertEquals('Basic dXNlcm5hbWU6cGFzc3dvcmQ=', auth4.getHeaderValue()); - System.assertEquals('Basic Og==', auth5.getHeaderValue()); - } - - @isTest - private static void ApiClient_setUsernameExceptionNoBasicAuth() { - Swagger.ApiClient client = new Swagger.ApiClient(); - try { - client.setUsername('username'); - } catch (NoSuchElementException e) { - return; - } - System.assert(false); - } - - @isTest - private static void ApiClient_setPasswordExceptionNoBasicAuth() { - Swagger.ApiClient client = new Swagger.ApiClient(); - try { - client.setPassword('password'); - } catch (NoSuchElementException e) { - return; - } - System.assert(false); - } - - @isTest - private static void ApiClient_setCredentialsFirstBasicAuthOnly() { - MockApiClient client = new MockApiClient(); - Swagger.OAuth2 auth1 = new Swagger.OAuth2(); - Swagger.ApiKeyQueryAuth auth2 = new Swagger.ApiKeyQueryAuth('auth2'); - Swagger.ApiKeyHeaderAuth auth3 = new Swagger.ApiKeyHeaderAuth('auth3'); - Swagger.HttpBasicAuth auth4 = new Swagger.HttpBasicAuth(); - Swagger.HttpBasicAuth auth5 = new Swagger.HttpBasicAuth(); - client.authentications.put('auth1', auth1); - client.authentications.put('auth2', auth2); - client.authentications.put('auth3', auth3); - client.authentications.put('auth4', auth4); - client.authentications.put('auth5', auth5); - client.setCredentials('username', 'password'); - - System.assertEquals('Bearer ', auth1.getHeaderValue()); - System.assertEquals('', auth2.getApiKey()); - System.assertEquals('', auth3.getApiKey()); - System.assertEquals('Basic dXNlcm5hbWU6cGFzc3dvcmQ=', auth4.getHeaderValue()); - System.assertEquals('Basic Og==', auth5.getHeaderValue()); - } - - @isTest - private static void ApiClient_setCredentialsExceptionNoBasicAuth() { - Swagger.ApiClient client = new Swagger.ApiClient(); - try { - client.setCredentials('username', 'password'); - } catch (NoSuchElementException e) { - return; - } - System.assert(false); - } - - @isTest - private static void ApiClient_setApiKeyFirstKeyAuthOnly() { - MockApiClient client = new MockApiClient(); - Swagger.OAuth2 auth1 = new Swagger.OAuth2(); - Swagger.HttpBasicAuth auth2 = new Swagger.HttpBasicAuth(); - Swagger.HttpBasicAuth auth3 = new Swagger.HttpBasicAuth(); - Swagger.ApiKeyQueryAuth auth4 = new Swagger.ApiKeyQueryAuth('auth4'); - Swagger.ApiKeyHeaderAuth auth5 = new Swagger.ApiKeyHeaderAuth('auth5'); - client.authentications.put('auth1', auth1); - client.authentications.put('auth2', auth2); - client.authentications.put('auth3', auth3); - client.authentications.put('auth4', auth4); - client.authentications.put('auth5', auth5); - client.setApiKey('foo-bar-api-key'); - - System.assertEquals('Bearer ', auth1.getHeaderValue()); - System.assertEquals('Basic Og==', auth2.getHeaderValue()); - System.assertEquals('Basic Og==', auth3.getHeaderValue()); - System.assertEquals('foo-bar-api-key', auth4.getApiKey()); - System.assertEquals('', auth5.getApiKey()); - } - - @isTest - private static void ApiClient_setApiKeyExceptionNoKeyAuth() { - Swagger.ApiClient client = new Swagger.ApiClient(); - try { - client.setApiKey('foo-bar-api-key'); - } catch (NoSuchElementException e) { - return; - } - System.assert(false); - } - - @isTest - private static void ApiClient_setAccessTokenFirstOauthOnly() { - MockApiClient client = new MockApiClient(); - Swagger.HttpBasicAuth auth1 = new Swagger.HttpBasicAuth(); - Swagger.ApiKeyQueryAuth auth2 = new Swagger.ApiKeyQueryAuth('auth2'); - Swagger.ApiKeyHeaderAuth auth3 = new Swagger.ApiKeyHeaderAuth('auth3'); - Swagger.OAuth2 auth4 = new Swagger.OAuth2(); - Swagger.OAuth2 auth5 = new Swagger.OAuth2(); - client.authentications.put('auth1', auth1); - client.authentications.put('auth2', auth2); - client.authentications.put('auth3', auth3); - client.authentications.put('auth4', auth4); - client.authentications.put('auth5', auth5); - client.setAccessToken('foo-bar-api-key'); - - System.assertEquals('Basic Og==', auth1.getHeaderValue()); - System.assertEquals('', auth2.getApiKey()); - System.assertEquals('', auth3.getApiKey()); - System.assertEquals('Bearer foo-bar-api-key', auth4.getHeaderValue()); - System.assertEquals('Bearer ', auth5.getHeaderValue()); - } - - @isTest - private static void ApiClient_setAccessTokenExceptionNoOAuth() { - Swagger.ApiClient client = new Swagger.ApiClient(); - try { - client.setAccessToken('foo-bar-api-key'); - } catch (NoSuchElementException e) { - return; - } - System.assert(false); } @isTest @@ -483,22 +283,6 @@ private class SwaggerTest { System.assert(headers3.isEmpty()); } - @isTest - private static void ApiClient_applyOnlyGivenAuthMethodsToParams() { - MockApiClient client = new MockApiClient(); - Map headers = new Map(); - Swagger.OAuth2 auth1 = new Swagger.OAuth2(); - Swagger.ApiKeyHeaderAuth auth2 = new Swagger.ApiKeyHeaderAuth('X-Authentication-Token'); - auth1.setAccessToken('boo-bat-api-key'); - auth2.setApiKey('foo-bar-api-key'); - client.authentications.put('auth1', auth1); - client.authentications.put('auth2', auth2); - client.applyAuthentication(new List{'auth2'}, headers, new List()); - - System.assertEquals(1, headers.size()); - System.assertEquals('foo-bar-api-key', headers.get('X-Authentication-Token')); - } - @isTest private static void ApiClient_formUrlWithQueryParamsPathParams() { MockApiClient client = new MockApiClient(); @@ -513,206 +297,6 @@ private class SwaggerTest { System.assertEquals(expected, actual); } - @isTest - private static void ApiClient_setupRequestWithBody() { - MockApiClient client = new MockApiClient(); - HttpResponse res = new HttpResponse(); - SwaggerResponseMock mock = new SwaggerResponseMock(res); - Swagger.OAuth2 auth = new Swagger.OAuth2(); - auth.setAccessToken('foo-bar-access-token'); - client.authentications.put('oauth_method', auth); - Test.setMock(HttpCalloutMock.class, mock); - - HttpResponse returned = client.getResponse( - 'PUT', '/courses/{course}/assignments/{assignmentId}', - new Map { - 'title' => 'Chapter 4 quiz', - 'timed' => true, - 'time' => 60, - 'points' => 20.5, - 'due' => Datetime.newInstanceGmt(2016, 5, 10, 23, 59, 59), - 'description' => '' - }, - new List(), - new List(), - new Map{ - 'course' => 'acc321', - 'assignmentId' => 5 - }, - new Map{ - 'X-Session' => 'foo-bar-444' - }, - new List{'application/json', 'application/xml'}, - new List{'application/json', 'application/xml'}, - new List{'oauth_method'} - ); - - HttpRequest req = mock.getRequest(); - String expectedUrl = 'https://www.mccombs.utexas.edu/courses/acc321/assignments/5'; - Set body = new Set(req - .getBody() - .removeStart('{') - .removeEnd('}') - .split(',') - ); - - System.assertEquals(res, returned); - System.assertEquals(expectedUrl, req.getEndpoint()); - System.assertEquals(6, body.size()); - System.assert(body.contains('"title":"Chapter 4 quiz"')); - System.assert(body.contains('"timed":true')); - System.assert(body.contains('"time":60')); - System.assert(body.contains('"points":20.5')); - System.assert(body.contains('"due":"2016-05-10T23:59:59.000Z"')); - System.assert(body.contains('"description":""')); - System.assertEquals('PUT', req.getMethod()); - System.assertEquals('Bearer foo-bar-access-token', req.getHeader('Authorization')); - System.assertEquals('foo-bar-444', req.getHeader('X-Session')); - System.assertEquals('application/json', req.getHeader('Accept')); - System.assertEquals('application/json', req.getHeader('Content-Type')); - } - - @isTest - private static void ApiClient_setupRequestWithForm() { - MockApiClient client = new MockApiClient(); - HttpResponse res = new HttpResponse(); - SwaggerResponseMock mock = new SwaggerResponseMock(res); - Swagger.OAuth2 auth = new Swagger.OAuth2(); - auth.setAccessToken('foo-bar-access-token'); - client.authentications.put('oauth_method', auth); - Test.setMock(HttpCalloutMock.class, mock); - - HttpResponse returned = client.getResponse( - 'PUT', '/courses/{course}/assignments/{assignmentId}', '', - new List(), - new List{ - new Swagger.Param('title', 'Chapter 4 quiz'), - new Swagger.Param('timed', 'true'), - new Swagger.Param('time', '60'), - new Swagger.Param('points', '20.5'), - new Swagger.Param('due', '2016-05-10 18:59:59'), - new Swagger.Param('description', 'complete & upload \'section1: advanced\'') - }, - new Map{ - 'course' => 'acc321', - 'assignmentId' => 5 - }, - new Map{ - 'X-Session' => 'foo-bar-444' - }, - new List{'text/html', 'application/xml'}, - new List{'application/x-www-form-urlencoded'}, - new List{'oauth_method'} - ); - - HttpRequest req = mock.getRequest(); - String expectedUrl = 'https://www.mccombs.utexas.edu/courses/acc321/assignments/5'; - Set body = new Set(req.getBody().split('&')); - - System.assertEquals(res, returned); - System.assertEquals(expectedUrl, req.getEndpoint()); - System.assertEquals(6, body.size()); - System.assert(body.contains('title=Chapter+4+quiz')); - System.assert(body.contains('timed=true')); - System.assert(body.contains('time=60')); - System.assert(body.contains('points=20.5')); - System.assert(body.contains('due=2016-05-10+18%3A59%3A59')); - System.assert(body.contains('description=complete+%26+upload+%27section1%3A+advanced%27')); - System.assertEquals('PUT', req.getMethod()); - System.assertEquals('Bearer foo-bar-access-token', req.getHeader('Authorization')); - System.assertEquals('foo-bar-444', req.getHeader('X-Session')); - System.assertEquals('text/html,application/xml', req.getHeader('Accept')); - System.assertEquals('application/x-www-form-urlencoded', req.getHeader('Content-Type')); - } - - @isTest - private static void ApiClient_setupRequestWithQuery() { - MockApiClient client = new MockApiClient(); - HttpResponse res = new HttpResponse(); - SwaggerResponseMock mock = new SwaggerResponseMock(res); - Swagger.OAuth2 auth = new Swagger.OAuth2(); - auth.setAccessToken('foo-bar-access-token'); - client.authentications.put('oauth_method', auth); - Test.setMock(HttpCalloutMock.class, mock); - - HttpResponse returned = client.getResponse( - 'GET', '/courses/{course}/assignments', '', - new List{ - new Swagger.Param('title', '#chapter1:section2'), - new Swagger.Param('due', '2016-05-10 18:59:59') - }, - new List(), - new Map{ - 'course' => 'acc321' - }, - new Map(), - new List{'application/xml'}, - new List{'text/plain'}, - new List{'oauth_method'} - ); - - HttpRequest req = mock.getRequest(); - List splitUrl = req.getEndpoint().split('\\?'); - String expectedUrl = 'https://www.mccombs.utexas.edu/courses/acc321/assignments'; - Set query = new Set(splitUrl.get(1).split('&')); - - System.assertEquals(res, returned); - System.assertEquals(expectedUrl, splitUrl.get(0)); - System.assertEquals(2, query.size()); - System.assert(query.contains('title=%23chapter1%3Asection2')); - System.assert(query.contains('due=2016-05-10+18%3A59%3A59')); - System.assertEquals('GET', req.getMethod()); - System.assertEquals('Bearer foo-bar-access-token', req.getHeader('Authorization')); - System.assertEquals('application/xml', req.getHeader('Accept')); - System.assertEquals('text/plain', req.getHeader('Content-Type')); - } - - @isTest - private static void ApiClient_nonSuccessfulStatusCodeException() { - MockApiClient client = new MockApiClient(); - HttpResponse res = new HttpResponse(); - SwaggerResponseMock mock = new SwaggerResponseMock(res); - Swagger.OAuth2 auth = new Swagger.OAuth2(); - auth.setAccessToken('foo-bar-access-token'); - client.authentications.put('oauth_method', auth); - Test.setMock(HttpCalloutMock.class, mock); - - res.setStatus('Not Found'); - res.setStatusCode(404); - res.setHeader('X-Request-ID', '1234567890'); - res.setHeader('Content-Type', 'application/json'); - res.setBody('{"error":"the specified course does not exist"}'); - - try { - client.invoke( - 'GET', '/courses/{course}', '', - new List(), - new List(), - new Map{ - 'course' => 'acc321' - }, - new Map(), - new List{'application/json'}, - new List{'text/plain'}, - new List{'oauth_method'}, - null - ); - } catch (Swagger.ApiException e) { - Map headers = e.getHeaders(); - - System.assertEquals('API returned HTTP 404: Not Found', e.getMessage()); - System.assertEquals(404, e.getStatusCode()); - System.assertEquals('Not Found', e.getStatus()); - System.assertEquals('{"error":"the specified course does not exist"}', e.getBody()); - System.assertEquals(2, headers.size()); - System.assertEquals('1234567890', headers.get('X-Request-ID')); - System.assertEquals('application/json', headers.get('Content-Type')); - return; - } - - System.assert(false); - } - @isTest private static void ApiClient_returnParsedBody() { MockApiClient client = new MockApiClient(); diff --git a/modules/swagger-codegen/src/main/resources/apex/api_test.mustache b/modules/swagger-codegen/src/main/resources/apex/api_test.mustache index 7ddb1afd210..f7a3cf0a63f 100644 --- a/modules/swagger-codegen/src/main/resources/apex/api_test.mustache +++ b/modules/swagger-codegen/src/main/resources/apex/api_test.mustache @@ -37,18 +37,10 @@ private class {{classname}}Test { {{#authMethods}} client = new {{classPrefix}}Client(); - api = new {{classname}}(client);{{#isBasic}} - ((Swagger.HttpBasicAuth){{/isBasic}}{{#isOAuth}} - ((Swagger.OAuth2){{/isOAuth}}{{#isApiKey}} - ((Swagger.ApiKeyAuth){{/isApiKey}} client.getAuthentication('{{name}}')) - {{#isBasic}} - .setCredentials('username', 'password'); - {{/isBasic}} - {{#isOAuth}} - .setAccessToken('foo-bar-access-token'); - {{/isOAuth}} + api = new {{classname}}(client);{{#isApiKey}} + ((Swagger.ApiKeyAuth){{/isApiKey}} client.getAuthentication('{{name}}'); {{#isApiKey}} - .setApiKey('foo-bar-api-key'); + client.setApiKey('foo-bar-api-key'); {{/isApiKey}} {{#examples}} diff --git a/modules/swagger-codegen/src/main/resources/apex/client.mustache b/modules/swagger-codegen/src/main/resources/apex/client.mustache index 13fd8363dba..fe5ba4f77bb 100644 --- a/modules/swagger-codegen/src/main/resources/apex/client.mustache +++ b/modules/swagger-codegen/src/main/resources/apex/client.mustache @@ -2,6 +2,7 @@ public class {{classPrefix}}Client extends Swagger.ApiClient { {{#hasAuthMethods}} public {{classPrefix}}Client() { basePath = '{{basePath}}'; + calloutName = '{{calloutName}}'; {{#authMethods}} {{#isApiKey}} {{#isKeyInQuery}} @@ -11,20 +12,13 @@ public class {{classPrefix}}Client extends Swagger.ApiClient { authentications.put('{{name}}', new Swagger.ApiKeyHeaderAuth('{{keyParamName}}')); {{/isKeyInQuery}} {{/isApiKey}} - {{^isApiKey}} - {{#isBasic}} - authentications.put('{{name}}', new Swagger.HttpBasicAuth()); - {{/isBasic}} - {{^isBasic}} - authentications.put('{{name}}', new Swagger.OAuth2()); - {{/isBasic}} - {{/isApiKey}} {{/authMethods}} } {{/hasAuthMethods}} {{^hasAuthMethods}} public {{classPrefix}}Client() { basePath = '{{basePath}}'; + calloutName = '{{calloutName}}'; } {{/hasAuthMethods}} } diff --git a/modules/swagger-codegen/src/main/resources/apex/namedCredential.mustache b/modules/swagger-codegen/src/main/resources/apex/namedCredential.mustache new file mode 100644 index 00000000000..fd966139c0d --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/apex/namedCredential.mustache @@ -0,0 +1,7 @@ + + + {{basePath}} + Anonymous + NoAuthentication + + \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/apex/package.mustache b/modules/swagger-codegen/src/main/resources/apex/package.mustache index 0d2438aac08..e13680359ba 100644 --- a/modules/swagger-codegen/src/main/resources/apex/package.mustache +++ b/modules/swagger-codegen/src/main/resources/apex/package.mustache @@ -25,7 +25,7 @@ Generated with Swagger Codegen (github.com/swagger-api/swagger-codegen) {{sanitizedName}} - RemoteSiteSetting + NamedCredential {{apiVersion}} diff --git a/modules/swagger-codegen/src/main/resources/apex/remoteSite.mustache b/modules/swagger-codegen/src/main/resources/apex/remoteSite.mustache deleted file mode 100644 index eb3e7985462..00000000000 --- a/modules/swagger-codegen/src/main/resources/apex/remoteSite.mustache +++ /dev/null @@ -1,7 +0,0 @@ - -{{#shortDescription}} - {{{shortDescription}}}{{/shortDescription}} - false - true - {{basePath}} - \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/apex/sfdx.mustache b/modules/swagger-codegen/src/main/resources/apex/sfdx.mustache new file mode 100644 index 00000000000..f63e2e36114 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/apex/sfdx.mustache @@ -0,0 +1,10 @@ +{ + "sfdxSource": true, + "version": "1.0.0", + "sourceFolder": "src/", + "folders": [ + "src/classes" + ], + "files": [ + ] +} \ No newline at end of file diff --git a/samples/client/petstore/apex/docs/SwagPetApi.md b/samples/client/petstore/apex/docs/SwagPetApi.md index cb6ca928adb..0911fbd0fa8 100644 --- a/samples/client/petstore/apex/docs/SwagPetApi.md +++ b/samples/client/petstore/apex/docs/SwagPetApi.md @@ -47,7 +47,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**SwagPet**](SwagPet.md)| Pet object that needs to be added to the store | + **body** | [**SwagPet**](Pet.md)| Pet object that needs to be added to the store | ### Return type @@ -292,7 +292,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**SwagPet**](SwagPet.md)| Pet object that needs to be added to the store | + **body** | [**SwagPet**](Pet.md)| Pet object that needs to be added to the store | ### Return type diff --git a/samples/client/petstore/apex/docs/SwagStoreApi.md b/samples/client/petstore/apex/docs/SwagStoreApi.md index c18a1ac229c..c0212e0300f 100644 --- a/samples/client/petstore/apex/docs/SwagStoreApi.md +++ b/samples/client/petstore/apex/docs/SwagStoreApi.md @@ -168,7 +168,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**SwagOrder**](SwagOrder.md)| order placed for purchasing the pet | + **body** | [**SwagOrder**](Order.md)| order placed for purchasing the pet | ### Return type diff --git a/samples/client/petstore/apex/docs/SwagUserApi.md b/samples/client/petstore/apex/docs/SwagUserApi.md index 349791c0665..aa559ddeac2 100644 --- a/samples/client/petstore/apex/docs/SwagUserApi.md +++ b/samples/client/petstore/apex/docs/SwagUserApi.md @@ -42,7 +42,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **body** | [**SwagUser**](SwagUser.md)| Created user object | + **body** | [**SwagUser**](User.md)| Created user object | ### Return type @@ -342,7 +342,7 @@ try { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **username** | **String**| name that need to be deleted | - **body** | [**SwagUser**](SwagUser.md)| Updated user object | + **body** | [**SwagUser**](User.md)| Updated user object | ### Return type diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponse.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponse.cls new file mode 100644 index 00000000000..8f87c98fd11 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponse.cls @@ -0,0 +1,69 @@ +/* + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +/** + * Describes the result of uploading an image resource + */ +public class SwagApiResponse implements Swagger.MappedProperties { + /** + * Get code + * @return code + */ + public Integer code { get; set; } + + /** + * Get r_type + * @return r_type + */ + public String r_type { get; set; } + + /** + * Get message + * @return message + */ + public String message { get; set; } + + private static final Map propertyMappings = new Map{ + 'type' => 'r_type' + }; + + public Map getPropertyMappings() { + return propertyMappings; + } + + public static SwagApiResponse getExample() { + SwagApiResponse apiResponse = new SwagApiResponse(); + apiResponse.code = 123; + apiResponse.r_type = 'aeiou'; + apiResponse.message = 'aeiou'; + return apiResponse; + } + + public Boolean equals(Object obj) { + if (obj instanceof SwagApiResponse) { + SwagApiResponse apiResponse = (SwagApiResponse) obj; + return this.code == apiResponse.code + && this.r_type == apiResponse.r_type + && this.message == apiResponse.message; + } + return false; + } + + public Integer hashCode() { + Integer hashCode = 43; + hashCode = (17 * hashCode) + (code == null ? 0 : System.hashCode(code)); + hashCode = (17 * hashCode) + (r_type == null ? 0 : System.hashCode(r_type)); + hashCode = (17 * hashCode) + (message == null ? 0 : System.hashCode(message)); + return hashCode; + } +} + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponse.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponse.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponse.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponseTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponseTest.cls new file mode 100644 index 00000000000..a7095a4f1c2 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponseTest.cls @@ -0,0 +1,87 @@ +@isTest +private class SwagApiResponseTest { + @isTest + private static void equalsSameInstance() { + SwagApiResponse apiResponse1 = SwagApiResponse.getExample(); + SwagApiResponse apiResponse2 = apiResponse1; + SwagApiResponse apiResponse3 = new SwagApiResponse(); + SwagApiResponse apiResponse4 = apiResponse3; + + System.assert(apiResponse1.equals(apiResponse2)); + System.assert(apiResponse2.equals(apiResponse1)); + System.assert(apiResponse1.equals(apiResponse1)); + System.assert(apiResponse3.equals(apiResponse4)); + System.assert(apiResponse4.equals(apiResponse3)); + System.assert(apiResponse3.equals(apiResponse3)); + } + + @isTest + private static void equalsIdenticalInstance() { + SwagApiResponse apiResponse1 = SwagApiResponse.getExample(); + SwagApiResponse apiResponse2 = SwagApiResponse.getExample(); + SwagApiResponse apiResponse3 = new SwagApiResponse(); + SwagApiResponse apiResponse4 = new SwagApiResponse(); + + System.assert(apiResponse1.equals(apiResponse2)); + System.assert(apiResponse2.equals(apiResponse1)); + System.assert(apiResponse3.equals(apiResponse4)); + System.assert(apiResponse4.equals(apiResponse3)); + } + + @isTest + private static void notEqualsUnlikeInstance() { + SwagApiResponse apiResponse1 = SwagApiResponse.getExample(); + SwagApiResponse apiResponse2 = new SwagApiResponse(); + + System.assertEquals(false, apiResponse1.equals(apiResponse2)); + System.assertEquals(false, apiResponse2.equals(apiResponse1)); + } + + @isTest + private static void notEqualsDifferentType() { + SwagApiResponse apiResponse1 = SwagApiResponse.getExample(); + SwagApiResponse apiResponse2 = new SwagApiResponse(); + + System.assertEquals(false, apiResponse1.equals('foo')); + System.assertEquals(false, apiResponse2.equals('foo')); + } + + @isTest + private static void notEqualsNull() { + SwagApiResponse apiResponse1 = SwagApiResponse.getExample(); + SwagApiResponse apiResponse2 = new SwagApiResponse(); + SwagApiResponse apiResponse3; + + System.assertEquals(false, apiResponse1.equals(apiResponse3)); + System.assertEquals(false, apiResponse2.equals(apiResponse3)); + } + + @isTest + private static void consistentHashCodeValue() { + SwagApiResponse apiResponse1 = SwagApiResponse.getExample(); + SwagApiResponse apiResponse2 = new SwagApiResponse(); + + System.assertEquals(apiResponse1.hashCode(), apiResponse1.hashCode()); + System.assertEquals(apiResponse2.hashCode(), apiResponse2.hashCode()); + } + + @isTest + private static void equalInstancesHaveSameHashCode() { + SwagApiResponse apiResponse1 = SwagApiResponse.getExample(); + SwagApiResponse apiResponse2 = SwagApiResponse.getExample(); + SwagApiResponse apiResponse3 = new SwagApiResponse(); + SwagApiResponse apiResponse4 = new SwagApiResponse(); + + System.assert(apiResponse1.equals(apiResponse2)); + System.assert(apiResponse3.equals(apiResponse4)); + System.assertEquals(apiResponse1.hashCode(), apiResponse2.hashCode()); + System.assertEquals(apiResponse3.hashCode(), apiResponse4.hashCode()); + } + + @isTest + private static void maintainRenamedProperties() { + SwagApiResponse apiResponse = new SwagApiResponse(); + Map propertyMappings = apiResponse.getPropertyMappings(); + System.assertEquals('r_type', propertyMappings.get('type')); + } +} diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponseTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponseTest.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagApiResponseTest.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagCategory.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagCategory.cls new file mode 100644 index 00000000000..b9e0e81b137 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagCategory.cls @@ -0,0 +1,52 @@ +/* + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +/** + * A category for a pet + */ +public class SwagCategory { + /** + * Get id + * @return id + */ + public Long id { get; set; } + + /** + * Get name + * @return name + */ + public String name { get; set; } + + public static SwagCategory getExample() { + SwagCategory category = new SwagCategory(); + category.id = 123456789L; + category.name = 'aeiou'; + return category; + } + + public Boolean equals(Object obj) { + if (obj instanceof SwagCategory) { + SwagCategory category = (SwagCategory) obj; + return this.id == category.id + && this.name == category.name; + } + return false; + } + + public Integer hashCode() { + Integer hashCode = 43; + hashCode = (17 * hashCode) + (id == null ? 0 : System.hashCode(id)); + hashCode = (17 * hashCode) + (name == null ? 0 : System.hashCode(name)); + return hashCode; + } +} + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagCategory.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagCategory.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagCategory.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagCategoryTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagCategoryTest.cls new file mode 100644 index 00000000000..8689ece6dc5 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagCategoryTest.cls @@ -0,0 +1,80 @@ +@isTest +private class SwagCategoryTest { + @isTest + private static void equalsSameInstance() { + SwagCategory category1 = SwagCategory.getExample(); + SwagCategory category2 = category1; + SwagCategory category3 = new SwagCategory(); + SwagCategory category4 = category3; + + System.assert(category1.equals(category2)); + System.assert(category2.equals(category1)); + System.assert(category1.equals(category1)); + System.assert(category3.equals(category4)); + System.assert(category4.equals(category3)); + System.assert(category3.equals(category3)); + } + + @isTest + private static void equalsIdenticalInstance() { + SwagCategory category1 = SwagCategory.getExample(); + SwagCategory category2 = SwagCategory.getExample(); + SwagCategory category3 = new SwagCategory(); + SwagCategory category4 = new SwagCategory(); + + System.assert(category1.equals(category2)); + System.assert(category2.equals(category1)); + System.assert(category3.equals(category4)); + System.assert(category4.equals(category3)); + } + + @isTest + private static void notEqualsUnlikeInstance() { + SwagCategory category1 = SwagCategory.getExample(); + SwagCategory category2 = new SwagCategory(); + + System.assertEquals(false, category1.equals(category2)); + System.assertEquals(false, category2.equals(category1)); + } + + @isTest + private static void notEqualsDifferentType() { + SwagCategory category1 = SwagCategory.getExample(); + SwagCategory category2 = new SwagCategory(); + + System.assertEquals(false, category1.equals('foo')); + System.assertEquals(false, category2.equals('foo')); + } + + @isTest + private static void notEqualsNull() { + SwagCategory category1 = SwagCategory.getExample(); + SwagCategory category2 = new SwagCategory(); + SwagCategory category3; + + System.assertEquals(false, category1.equals(category3)); + System.assertEquals(false, category2.equals(category3)); + } + + @isTest + private static void consistentHashCodeValue() { + SwagCategory category1 = SwagCategory.getExample(); + SwagCategory category2 = new SwagCategory(); + + System.assertEquals(category1.hashCode(), category1.hashCode()); + System.assertEquals(category2.hashCode(), category2.hashCode()); + } + + @isTest + private static void equalInstancesHaveSameHashCode() { + SwagCategory category1 = SwagCategory.getExample(); + SwagCategory category2 = SwagCategory.getExample(); + SwagCategory category3 = new SwagCategory(); + SwagCategory category4 = new SwagCategory(); + + System.assert(category1.equals(category2)); + System.assert(category3.equals(category4)); + System.assertEquals(category1.hashCode(), category2.hashCode()); + System.assertEquals(category3.hashCode(), category4.hashCode()); + } +} diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagCategoryTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagCategoryTest.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagCategoryTest.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagClient.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagClient.cls new file mode 100644 index 00000000000..e229bc325bf --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagClient.cls @@ -0,0 +1,7 @@ +public class SwagClient extends Swagger.ApiClient { + public SwagClient() { + basePath = 'http://petstore.swagger.io/v2'; + calloutName = 'Swagger_Petstore'; + authentications.put('api_key', new Swagger.ApiKeyHeaderAuth('api_key')); + } +} diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagClient.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagClient.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagClient.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagOrder.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagOrder.cls new file mode 100644 index 00000000000..775081a55c8 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagOrder.cls @@ -0,0 +1,101 @@ +/* + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +/** + * An order for a pets from the pet store + */ +public class SwagOrder { + /** + * Get id + * @return id + */ + public Long id { get; set; } + + /** + * Get petId + * @return petId + */ + public Long petId { get; set; } + + /** + * Get quantity + * @return quantity + */ + public Integer quantity { get; set; } + + /** + * Get shipDate + * @return shipDate + */ + public Datetime shipDate { get; set; } + + /** + * Order Status + */ + public enum StatusEnum { + PLACED, + APPROVED, + DELIVERED + } + + /** + * Order Status + * @return status + */ + public StatusEnum status { get; set; } + + /** + * Get complete + * @return complete + */ + public Boolean complete { get; set; } + + public SwagOrder() { + complete = false; + } + + public static SwagOrder getExample() { + SwagOrder order = new SwagOrder(); + order.id = 123456789L; + order.petId = 123456789L; + order.quantity = 123; + order.shipDate = Datetime.newInstanceGmt(2000, 1, 23, 4, 56, 7); + order.status = StatusEnum.PLACED; + order.complete = true; + return order; + } + + public Boolean equals(Object obj) { + if (obj instanceof SwagOrder) { + SwagOrder order = (SwagOrder) obj; + return this.id == order.id + && this.petId == order.petId + && this.quantity == order.quantity + && this.shipDate == order.shipDate + && this.status == order.status + && this.complete == order.complete; + } + return false; + } + + public Integer hashCode() { + Integer hashCode = 43; + hashCode = (17 * hashCode) + (id == null ? 0 : System.hashCode(id)); + hashCode = (17 * hashCode) + (petId == null ? 0 : System.hashCode(petId)); + hashCode = (17 * hashCode) + (quantity == null ? 0 : System.hashCode(quantity)); + hashCode = (17 * hashCode) + (shipDate == null ? 0 : System.hashCode(shipDate)); + hashCode = (17 * hashCode) + (status == null ? 0 : System.hashCode(status)); + hashCode = (17 * hashCode) + (complete == null ? 0 : System.hashCode(complete)); + return hashCode; + } +} + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagOrder.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagOrder.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagOrder.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagOrderTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagOrderTest.cls new file mode 100644 index 00000000000..090eea45e5e --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagOrderTest.cls @@ -0,0 +1,91 @@ +@isTest +private class SwagOrderTest { + @isTest + private static void equalsSameInstance() { + SwagOrder order1 = SwagOrder.getExample(); + SwagOrder order2 = order1; + SwagOrder order3 = new SwagOrder(); + SwagOrder order4 = order3; + + System.assert(order1.equals(order2)); + System.assert(order2.equals(order1)); + System.assert(order1.equals(order1)); + System.assert(order3.equals(order4)); + System.assert(order4.equals(order3)); + System.assert(order3.equals(order3)); + } + + @isTest + private static void equalsIdenticalInstance() { + SwagOrder order1 = SwagOrder.getExample(); + SwagOrder order2 = SwagOrder.getExample(); + SwagOrder order3 = new SwagOrder(); + SwagOrder order4 = new SwagOrder(); + + System.assert(order1.equals(order2)); + System.assert(order2.equals(order1)); + System.assert(order3.equals(order4)); + System.assert(order4.equals(order3)); + } + + @isTest + private static void notEqualsUnlikeInstance() { + SwagOrder order1 = SwagOrder.getExample(); + SwagOrder order2 = new SwagOrder(); + + System.assertEquals(false, order1.equals(order2)); + System.assertEquals(false, order2.equals(order1)); + } + + @isTest + private static void notEqualsDifferentType() { + SwagOrder order1 = SwagOrder.getExample(); + SwagOrder order2 = new SwagOrder(); + + System.assertEquals(false, order1.equals('foo')); + System.assertEquals(false, order2.equals('foo')); + } + + @isTest + private static void notEqualsNull() { + SwagOrder order1 = SwagOrder.getExample(); + SwagOrder order2 = new SwagOrder(); + SwagOrder order3; + + System.assertEquals(false, order1.equals(order3)); + System.assertEquals(false, order2.equals(order3)); + } + + @isTest + private static void consistentHashCodeValue() { + SwagOrder order1 = SwagOrder.getExample(); + SwagOrder order2 = new SwagOrder(); + + System.assertEquals(order1.hashCode(), order1.hashCode()); + System.assertEquals(order2.hashCode(), order2.hashCode()); + } + + @isTest + private static void equalInstancesHaveSameHashCode() { + SwagOrder order1 = SwagOrder.getExample(); + SwagOrder order2 = SwagOrder.getExample(); + SwagOrder order3 = new SwagOrder(); + SwagOrder order4 = new SwagOrder(); + + System.assert(order1.equals(order2)); + System.assert(order3.equals(order4)); + System.assertEquals(order1.hashCode(), order2.hashCode()); + System.assertEquals(order3.hashCode(), order4.hashCode()); + } + + @isTest + private static void defaultValuesPopulated() { + SwagOrder order = new SwagOrder(); + System.assertEquals(false, order.complete); + System.assertEquals(null, order.id); + System.assertEquals(null, order.petId); + System.assertEquals(null, order.quantity); + System.assertEquals(null, order.shipDate); + System.assertEquals(null, order.status); + } +} diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagOrderTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagOrderTest.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagOrderTest.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagPet.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagPet.cls new file mode 100644 index 00000000000..4c0b2346a8c --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagPet.cls @@ -0,0 +1,102 @@ +/* + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +/** + * A pet for sale in the pet store + */ +public class SwagPet { + /** + * Get id + * @return id + */ + public Long id { get; set; } + + /** + * Get category + * @return category + */ + public SwagCategory category { get; set; } + + /** + * Get name + * @return name + */ + public String name { get; set; } + + /** + * Get photoUrls + * @return photoUrls + */ + public List photoUrls { get; set; } + + /** + * Get tags + * @return tags + */ + public List tags { get; set; } + + /** + * pet status in the store + */ + public enum StatusEnum { + AVAILABLE, + PENDING, + SOLD + } + + /** + * pet status in the store + * @return status + */ + public StatusEnum status { get; set; } + + public SwagPet() { + photoUrls = new List(); + tags = new List(); + } + + public static SwagPet getExample() { + SwagPet pet = new SwagPet(); + pet.id = 123456789L; + pet.category = SwagCategory.getExample(); + pet.name = 'doggie'; + pet.photoUrls = new List{'aeiou'}; + pet.tags = new List{SwagTag.getExample()}; + pet.status = StatusEnum.AVAILABLE; + return pet; + } + + public Boolean equals(Object obj) { + if (obj instanceof SwagPet) { + SwagPet pet = (SwagPet) obj; + return this.id == pet.id + && this.category == pet.category + && this.name == pet.name + && this.photoUrls == pet.photoUrls + && this.tags == pet.tags + && this.status == pet.status; + } + return false; + } + + public Integer hashCode() { + Integer hashCode = 43; + hashCode = (17 * hashCode) + (id == null ? 0 : System.hashCode(id)); + hashCode = (17 * hashCode) + (category == null ? 0 : System.hashCode(category)); + hashCode = (17 * hashCode) + (name == null ? 0 : System.hashCode(name)); + hashCode = (17 * hashCode) + (photoUrls == null ? 0 : System.hashCode(photoUrls)); + hashCode = (17 * hashCode) + (tags == null ? 0 : System.hashCode(tags)); + hashCode = (17 * hashCode) + (status == null ? 0 : System.hashCode(status)); + return hashCode; + } +} + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagPet.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagPet.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagPet.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagPetApi.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagPetApi.cls new file mode 100644 index 00000000000..059b7bdcd78 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagPetApi.cls @@ -0,0 +1,241 @@ +/* + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +public class SwagPetApi { + SwagClient client; + + public SwagPetApi(SwagClient client) { + this.client = client; + } + + public SwagPetApi() { + this.client = new SwagClient(); + } + + public SwagClient getClient() { + return this.client; + } + + /** + * Add a new pet to the store + * + * @param body Pet object that needs to be added to the store (required) + * @throws Swagger.ApiException if fails to make API call + */ + public void addPet(Map params) { + client.assertNotNull(params.get('body'), 'body'); + List query = new List(); + List form = new List(); + + client.invoke( + 'POST', '/pet', + (SwagPet) params.get('body'), + query, form, + new Map(), + new Map(), + new List{ 'application/json' }, + new List{ 'application/json' }, + new List { 'petstore_auth' }, + null + ); + } + /** + * Deletes a pet + * + * @param petId Pet id to delete (required) + * @param apiKey (optional) + * @throws Swagger.ApiException if fails to make API call + */ + public void deletePet(Map params) { + client.assertNotNull(params.get('petId'), 'petId'); + List query = new List(); + List form = new List(); + + client.invoke( + 'DELETE', '/pet/{petId}', '', + query, form, + new Map{ + 'petId' => (Long) params.get('petId') + }, + new Map{ + 'api_key' => (String) params.get('apiKey') + }, + new List{ 'application/json' }, + new List{ 'application/json' }, + new List { 'petstore_auth' }, + null + ); + } + /** + * Finds Pets by status + * Multiple status values can be provided with comma separated strings + * @param status Status values that need to be considered for filter (required) + * @return List + * @throws Swagger.ApiException if fails to make API call + */ + public List findPetsByStatus(Map params) { + client.assertNotNull(params.get('status'), 'status'); + List query = new List(); + + // cast query params to verify their expected type + query.addAll(client.makeParam('status', (List) params.get('status'), 'csv')); + + List form = new List(); + + return (List) client.invoke( + 'GET', '/pet/findByStatus', '', + query, form, + new Map(), + new Map(), + new List{ 'application/json' }, + new List{ 'application/json' }, + new List { 'petstore_auth' }, + List.class + ); + } + /** + * Finds Pets by tags + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by (required) + * @return List + * @throws Swagger.ApiException if fails to make API call + */ + public List findPetsByTags(Map params) { + client.assertNotNull(params.get('tags'), 'tags'); + List query = new List(); + + // cast query params to verify their expected type + query.addAll(client.makeParam('tags', (List) params.get('tags'), 'csv')); + + List form = new List(); + + return (List) client.invoke( + 'GET', '/pet/findByTags', '', + query, form, + new Map(), + new Map(), + new List{ 'application/json' }, + new List{ 'application/json' }, + new List { 'petstore_auth' }, + List.class + ); + } + /** + * Find pet by ID + * Returns a single pet + * @param petId ID of pet to return (required) + * @return SwagPet + * @throws Swagger.ApiException if fails to make API call + */ + public SwagPet getPetById(Map params) { + client.assertNotNull(params.get('petId'), 'petId'); + List query = new List(); + List form = new List(); + + return (SwagPet) client.invoke( + 'GET', '/pet/{petId}', '', + query, form, + new Map{ + 'petId' => (Long) params.get('petId') + }, + new Map(), + new List{ 'application/json' }, + new List{ 'application/json' }, + new List { 'api_key' }, + SwagPet.class + ); + } + /** + * Update an existing pet + * + * @param body Pet object that needs to be added to the store (required) + * @throws Swagger.ApiException if fails to make API call + */ + public void updatePet(Map params) { + client.assertNotNull(params.get('body'), 'body'); + List query = new List(); + List form = new List(); + + client.invoke( + 'PUT', '/pet', + (SwagPet) params.get('body'), + query, form, + new Map(), + new Map(), + new List{ 'application/json' }, + new List{ 'application/json' }, + new List { 'petstore_auth' }, + null + ); + } + /** + * Updates a pet in the store with form data + * + * @param petId ID of pet that needs to be updated (required) + * @param name Updated name of the pet (optional) + * @param status Updated status of the pet (optional) + * @throws Swagger.ApiException if fails to make API call + */ + public void updatePetWithForm(Map params) { + client.assertNotNull(params.get('petId'), 'petId'); + List query = new List(); + List form = new List(); + + // cast form params to verify their expected type + form.addAll(client.makeParam('name', (String) params.get('name'))); + form.addAll(client.makeParam('status', (String) params.get('status'))); + + client.invoke( + 'POST', '/pet/{petId}', '', + query, form, + new Map{ + 'petId' => (Long) params.get('petId') + }, + new Map(), + new List{ 'application/json' }, + new List{ 'application/x-www-form-urlencoded' }, + new List { 'petstore_auth' }, + null + ); + } + /** + * uploads an image + * + * @param petId ID of pet to update (required) + * @param additionalMetadata Additional data to pass to server (optional) + * @param file file to upload (optional) + * @return SwagApiResponse + * @throws Swagger.ApiException if fails to make API call + */ + public SwagApiResponse uploadFile(Map params) { + client.assertNotNull(params.get('petId'), 'petId'); + List query = new List(); + List form = new List(); + + // cast form params to verify their expected type + form.addAll(client.makeParam('additionalMetadata', (String) params.get('additionalMetadata'))); + form.addAll(client.makeParam('file', (Blob) params.get('file'))); + + return (SwagApiResponse) client.invoke( + 'POST', '/pet/{petId}/uploadImage', '', + query, form, + new Map{ + 'petId' => (Long) params.get('petId') + }, + new Map(), + new List{ 'application/json' }, + new List{ 'application/x-www-form-urlencoded' }, + new List { 'petstore_auth' }, + SwagApiResponse.class + ); + } +} diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagPetApi.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagPetApi.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagPetApi.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagPetApiTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagPetApiTest.cls new file mode 100644 index 00000000000..c1daa5f6264 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagPetApiTest.cls @@ -0,0 +1,233 @@ +@isTest +private class SwagPetApiTest { + /** + * Add a new pet to the store + * + * + */ + @isTest + private static void addPetTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(201); + res.setStatus('Created'); + Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + + Map params = new Map{ + 'body' => SwagPet.getExample() + }; + + SwagClient client; + SwagPetApi api; + + client = new SwagClient(); + api = new SwagPetApi(client); client.getAuthentication('petstore_auth'); + + api.addPet(params); + } + + /** + * Deletes a pet + * + * + */ + @isTest + private static void deletePetTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + + Map params = new Map{ + 'petId' => 2147483648L, + 'apiKey' => 'apiKey_example' + }; + + SwagClient client; + SwagPetApi api; + + client = new SwagClient(); + api = new SwagPetApi(client); client.getAuthentication('petstore_auth'); + + api.deletePet(params); + } + + /** + * Finds Pets by status + * + * Multiple status values can be provided with comma separated strings + */ + @isTest + private static void findPetsByStatusTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + + Map params = new Map{ + 'status' => new List{'available'} + }; + + SwagClient client; + SwagPetApi api; + List response; + List expectedResponse; + + client = new SwagClient(); + api = new SwagPetApi(client); client.getAuthentication('petstore_auth'); + + res.setHeader('Content-Type', 'application/json'); + res.setBody('[ {\n "photoUrls" : [ "aeiou" ],\n "name" : "doggie",\n "id" : 0,\n "category" : {\n "name" : "aeiou",\n "id" : 6\n },\n "tags" : [ {\n "name" : "aeiou",\n "id" : 1\n } ],\n "status" : "available"\n} ]'); + expectedResponse = new List{SwagPet.getExample()}; + response = (List) api.findPetsByStatus(params); + System.assertEquals(expectedResponse, response); + } + + /** + * Finds Pets by tags + * + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + */ + @isTest + private static void findPetsByTagsTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + + Map params = new Map{ + 'tags' => new List{'aeiou'} + }; + + SwagClient client; + SwagPetApi api; + List response; + List expectedResponse; + + client = new SwagClient(); + api = new SwagPetApi(client); client.getAuthentication('petstore_auth'); + + res.setHeader('Content-Type', 'application/json'); + res.setBody('[ {\n "photoUrls" : [ "aeiou" ],\n "name" : "doggie",\n "id" : 0,\n "category" : {\n "name" : "aeiou",\n "id" : 6\n },\n "tags" : [ {\n "name" : "aeiou",\n "id" : 1\n } ],\n "status" : "available"\n} ]'); + expectedResponse = new List{SwagPet.getExample()}; + response = (List) api.findPetsByTags(params); + System.assertEquals(expectedResponse, response); + } + + /** + * Find pet by ID + * + * Returns a single pet + */ + @isTest + private static void getPetByIdTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + + Map params = new Map{ + 'petId' => 2147483648L + }; + + SwagClient client; + SwagPetApi api; + SwagPet response; + SwagPet expectedResponse; + + client = new SwagClient(); + api = new SwagPetApi(client); + ((Swagger.ApiKeyAuth) client.getAuthentication('api_key'); + client.setApiKey('foo-bar-api-key'); + + res.setHeader('Content-Type', 'application/json'); + res.setBody('{\n "photoUrls" : [ "aeiou" ],\n "name" : "doggie",\n "id" : 0,\n "category" : {\n "name" : "aeiou",\n "id" : 6\n },\n "tags" : [ {\n "name" : "aeiou",\n "id" : 1\n } ],\n "status" : "available"\n}'); + expectedResponse = SwagPet.getExample(); + response = (SwagPet) api.getPetById(params); + System.assertEquals(expectedResponse, response); + } + + /** + * Update an existing pet + * + * + */ + @isTest + private static void updatePetTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + + Map params = new Map{ + 'body' => SwagPet.getExample() + }; + + SwagClient client; + SwagPetApi api; + + client = new SwagClient(); + api = new SwagPetApi(client); client.getAuthentication('petstore_auth'); + + api.updatePet(params); + } + + /** + * Updates a pet in the store with form data + * + * + */ + @isTest + private static void updatePetWithFormTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + + Map params = new Map{ + 'petId' => 2147483648L, + 'name' => 'name_example', + 'status' => 'status_example' + }; + + SwagClient client; + SwagPetApi api; + + client = new SwagClient(); + api = new SwagPetApi(client); client.getAuthentication('petstore_auth'); + + api.updatePetWithForm(params); + } + + /** + * uploads an image + * + * + */ + @isTest + private static void uploadFileTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + + Map params = new Map{ + 'petId' => 2147483648L, + 'additionalMetadata' => 'additionalMetadata_example', + 'file' => Blob.valueOf('Sample text file\nContents') + }; + + SwagClient client; + SwagPetApi api; + SwagApiResponse response; + SwagApiResponse expectedResponse; + + client = new SwagClient(); + api = new SwagPetApi(client); client.getAuthentication('petstore_auth'); + + res.setHeader('Content-Type', 'application/json'); + res.setBody('{\n "code" : 0,\n "type" : "aeiou",\n "message" : "aeiou"\n}'); + expectedResponse = SwagApiResponse.getExample(); + response = (SwagApiResponse) api.uploadFile(params); + System.assertEquals(expectedResponse, response); + } +} \ No newline at end of file diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagPetApiTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagPetApiTest.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagPetApiTest.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagPetTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagPetTest.cls new file mode 100644 index 00000000000..30b6d88b963 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagPetTest.cls @@ -0,0 +1,91 @@ +@isTest +private class SwagPetTest { + @isTest + private static void equalsSameInstance() { + SwagPet pet1 = SwagPet.getExample(); + SwagPet pet2 = pet1; + SwagPet pet3 = new SwagPet(); + SwagPet pet4 = pet3; + + System.assert(pet1.equals(pet2)); + System.assert(pet2.equals(pet1)); + System.assert(pet1.equals(pet1)); + System.assert(pet3.equals(pet4)); + System.assert(pet4.equals(pet3)); + System.assert(pet3.equals(pet3)); + } + + @isTest + private static void equalsIdenticalInstance() { + SwagPet pet1 = SwagPet.getExample(); + SwagPet pet2 = SwagPet.getExample(); + SwagPet pet3 = new SwagPet(); + SwagPet pet4 = new SwagPet(); + + System.assert(pet1.equals(pet2)); + System.assert(pet2.equals(pet1)); + System.assert(pet3.equals(pet4)); + System.assert(pet4.equals(pet3)); + } + + @isTest + private static void notEqualsUnlikeInstance() { + SwagPet pet1 = SwagPet.getExample(); + SwagPet pet2 = new SwagPet(); + + System.assertEquals(false, pet1.equals(pet2)); + System.assertEquals(false, pet2.equals(pet1)); + } + + @isTest + private static void notEqualsDifferentType() { + SwagPet pet1 = SwagPet.getExample(); + SwagPet pet2 = new SwagPet(); + + System.assertEquals(false, pet1.equals('foo')); + System.assertEquals(false, pet2.equals('foo')); + } + + @isTest + private static void notEqualsNull() { + SwagPet pet1 = SwagPet.getExample(); + SwagPet pet2 = new SwagPet(); + SwagPet pet3; + + System.assertEquals(false, pet1.equals(pet3)); + System.assertEquals(false, pet2.equals(pet3)); + } + + @isTest + private static void consistentHashCodeValue() { + SwagPet pet1 = SwagPet.getExample(); + SwagPet pet2 = new SwagPet(); + + System.assertEquals(pet1.hashCode(), pet1.hashCode()); + System.assertEquals(pet2.hashCode(), pet2.hashCode()); + } + + @isTest + private static void equalInstancesHaveSameHashCode() { + SwagPet pet1 = SwagPet.getExample(); + SwagPet pet2 = SwagPet.getExample(); + SwagPet pet3 = new SwagPet(); + SwagPet pet4 = new SwagPet(); + + System.assert(pet1.equals(pet2)); + System.assert(pet3.equals(pet4)); + System.assertEquals(pet1.hashCode(), pet2.hashCode()); + System.assertEquals(pet3.hashCode(), pet4.hashCode()); + } + + @isTest + private static void defaultValuesPopulated() { + SwagPet pet = new SwagPet(); + System.assertEquals(new List(), pet.photoUrls); + System.assertEquals(new List(), pet.tags); + System.assertEquals(null, pet.id); + System.assertEquals(null, pet.category); + System.assertEquals(null, pet.name); + System.assertEquals(null, pet.status); + } +} diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagPetTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagPetTest.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagPetTest.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApi.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApi.cls new file mode 100644 index 00000000000..feb55354464 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApi.cls @@ -0,0 +1,122 @@ +/* + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +public class SwagStoreApi { + SwagClient client; + + public SwagStoreApi(SwagClient client) { + this.client = client; + } + + public SwagStoreApi() { + this.client = new SwagClient(); + } + + public SwagClient getClient() { + return this.client; + } + + /** + * Delete purchase order by ID + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * @param orderId ID of the order that needs to be deleted (required) + * @throws Swagger.ApiException if fails to make API call + */ + public void deleteOrder(Map params) { + client.assertNotNull(params.get('orderId'), 'orderId'); + List query = new List(); + List form = new List(); + + client.invoke( + 'DELETE', '/store/order/{orderId}', '', + query, form, + new Map{ + 'orderId' => (String) params.get('orderId') + }, + new Map(), + new List{ 'application/json' }, + new List{ 'application/json' }, + new List(), + null + ); + } + /** + * Returns pet inventories by status + * Returns a map of status codes to quantities + * @return Map + * @throws Swagger.ApiException if fails to make API call + */ + public Map getInventory() { + List query = new List(); + List form = new List(); + + return (Map) client.invoke( + 'GET', '/store/inventory', '', + query, form, + new Map(), + new Map(), + new List{ 'application/json' }, + new List{ 'application/json' }, + new List { 'api_key' }, + Map.class + ); + } + /** + * Find purchase order by ID + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * @param orderId ID of pet that needs to be fetched (required) + * @return SwagOrder + * @throws Swagger.ApiException if fails to make API call + */ + public SwagOrder getOrderById(Map params) { + client.assertNotNull(params.get('orderId'), 'orderId'); + List query = new List(); + List form = new List(); + + return (SwagOrder) client.invoke( + 'GET', '/store/order/{orderId}', '', + query, form, + new Map{ + 'orderId' => (Long) params.get('orderId') + }, + new Map(), + new List{ 'application/json' }, + new List{ 'application/json' }, + new List(), + SwagOrder.class + ); + } + /** + * Place an order for a pet + * + * @param body order placed for purchasing the pet (required) + * @return SwagOrder + * @throws Swagger.ApiException if fails to make API call + */ + public SwagOrder placeOrder(Map params) { + client.assertNotNull(params.get('body'), 'body'); + List query = new List(); + List form = new List(); + + return (SwagOrder) client.invoke( + 'POST', '/store/order', + (SwagOrder) params.get('body'), + query, form, + new Map(), + new Map(), + new List{ 'application/json' }, + new List{ 'application/json' }, + new List(), + SwagOrder.class + ); + } +} diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApi.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApi.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApi.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApiTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApiTest.cls new file mode 100644 index 00000000000..c79bbd98acc --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApiTest.cls @@ -0,0 +1,115 @@ +@isTest +private class SwagStoreApiTest { + /** + * Delete purchase order by ID + * + * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + */ + @isTest + private static void deleteOrderTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + + Map params = new Map{ + 'orderId' => 'orderId_example' + }; + + SwagClient client; + SwagStoreApi api; + + api = new SwagStoreApi(new SwagClient()); + + api.deleteOrder(params); + } + + /** + * Returns pet inventories by status + * + * Returns a map of status codes to quantities + */ + @isTest + private static void getInventoryTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + + SwagClient client; + SwagStoreApi api; + Map response; + Map expectedResponse; + + client = new SwagClient(); + api = new SwagStoreApi(client); + ((Swagger.ApiKeyAuth) client.getAuthentication('api_key'); + client.setApiKey('foo-bar-api-key'); + + res.setHeader('Content-Type', 'application/json'); + res.setBody('{\n "key" : 0\n}'); + expectedResponse = new Map{'key'=>123}; + response = (Map) api.getInventory(); + System.assertEquals(expectedResponse, response); + } + + /** + * Find purchase order by ID + * + * For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + */ + @isTest + private static void getOrderByIdTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + + Map params = new Map{ + 'orderId' => 2147483648L + }; + + SwagClient client; + SwagStoreApi api; + SwagOrder response; + SwagOrder expectedResponse; + + api = new SwagStoreApi(new SwagClient()); + + res.setHeader('Content-Type', 'application/json'); + res.setBody('{\n "petId" : 6,\n "quantity" : 1,\n "id" : 0,\n "shipDate" : "2000-01-23T04:56:07.000+00:00",\n "complete" : false,\n "status" : "placed"\n}'); + expectedResponse = SwagOrder.getExample(); + response = (SwagOrder) api.getOrderById(params); + System.assertEquals(expectedResponse, response); + } + + /** + * Place an order for a pet + * + * + */ + @isTest + private static void placeOrderTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + + Map params = new Map{ + 'body' => SwagOrder.getExample() + }; + + SwagClient client; + SwagStoreApi api; + SwagOrder response; + SwagOrder expectedResponse; + + api = new SwagStoreApi(new SwagClient()); + + res.setHeader('Content-Type', 'application/json'); + res.setBody('{\n "petId" : 6,\n "quantity" : 1,\n "id" : 0,\n "shipDate" : "2000-01-23T04:56:07.000+00:00",\n "complete" : false,\n "status" : "placed"\n}'); + expectedResponse = SwagOrder.getExample(); + response = (SwagOrder) api.placeOrder(params); + System.assertEquals(expectedResponse, response); + } +} \ No newline at end of file diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApiTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApiTest.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagStoreApiTest.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagTag.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagTag.cls new file mode 100644 index 00000000000..d1348d58db8 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagTag.cls @@ -0,0 +1,52 @@ +/* + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +/** + * A tag for a pet + */ +public class SwagTag { + /** + * Get id + * @return id + */ + public Long id { get; set; } + + /** + * Get name + * @return name + */ + public String name { get; set; } + + public static SwagTag getExample() { + SwagTag tag = new SwagTag(); + tag.id = 123456789L; + tag.name = 'aeiou'; + return tag; + } + + public Boolean equals(Object obj) { + if (obj instanceof SwagTag) { + SwagTag tag = (SwagTag) obj; + return this.id == tag.id + && this.name == tag.name; + } + return false; + } + + public Integer hashCode() { + Integer hashCode = 43; + hashCode = (17 * hashCode) + (id == null ? 0 : System.hashCode(id)); + hashCode = (17 * hashCode) + (name == null ? 0 : System.hashCode(name)); + return hashCode; + } +} + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagTag.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagTag.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagTag.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagTagTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagTagTest.cls new file mode 100644 index 00000000000..beee6690404 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagTagTest.cls @@ -0,0 +1,80 @@ +@isTest +private class SwagTagTest { + @isTest + private static void equalsSameInstance() { + SwagTag tag1 = SwagTag.getExample(); + SwagTag tag2 = tag1; + SwagTag tag3 = new SwagTag(); + SwagTag tag4 = tag3; + + System.assert(tag1.equals(tag2)); + System.assert(tag2.equals(tag1)); + System.assert(tag1.equals(tag1)); + System.assert(tag3.equals(tag4)); + System.assert(tag4.equals(tag3)); + System.assert(tag3.equals(tag3)); + } + + @isTest + private static void equalsIdenticalInstance() { + SwagTag tag1 = SwagTag.getExample(); + SwagTag tag2 = SwagTag.getExample(); + SwagTag tag3 = new SwagTag(); + SwagTag tag4 = new SwagTag(); + + System.assert(tag1.equals(tag2)); + System.assert(tag2.equals(tag1)); + System.assert(tag3.equals(tag4)); + System.assert(tag4.equals(tag3)); + } + + @isTest + private static void notEqualsUnlikeInstance() { + SwagTag tag1 = SwagTag.getExample(); + SwagTag tag2 = new SwagTag(); + + System.assertEquals(false, tag1.equals(tag2)); + System.assertEquals(false, tag2.equals(tag1)); + } + + @isTest + private static void notEqualsDifferentType() { + SwagTag tag1 = SwagTag.getExample(); + SwagTag tag2 = new SwagTag(); + + System.assertEquals(false, tag1.equals('foo')); + System.assertEquals(false, tag2.equals('foo')); + } + + @isTest + private static void notEqualsNull() { + SwagTag tag1 = SwagTag.getExample(); + SwagTag tag2 = new SwagTag(); + SwagTag tag3; + + System.assertEquals(false, tag1.equals(tag3)); + System.assertEquals(false, tag2.equals(tag3)); + } + + @isTest + private static void consistentHashCodeValue() { + SwagTag tag1 = SwagTag.getExample(); + SwagTag tag2 = new SwagTag(); + + System.assertEquals(tag1.hashCode(), tag1.hashCode()); + System.assertEquals(tag2.hashCode(), tag2.hashCode()); + } + + @isTest + private static void equalInstancesHaveSameHashCode() { + SwagTag tag1 = SwagTag.getExample(); + SwagTag tag2 = SwagTag.getExample(); + SwagTag tag3 = new SwagTag(); + SwagTag tag4 = new SwagTag(); + + System.assert(tag1.equals(tag2)); + System.assert(tag3.equals(tag4)); + System.assertEquals(tag1.hashCode(), tag2.hashCode()); + System.assertEquals(tag3.hashCode(), tag4.hashCode()); + } +} diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagTagTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagTagTest.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagTagTest.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagUser.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagUser.cls new file mode 100644 index 00000000000..d8ec7643bb2 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagUser.cls @@ -0,0 +1,106 @@ +/* + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +/** + * A User who is purchasing from the pet store + */ +public class SwagUser { + /** + * Get id + * @return id + */ + public Long id { get; set; } + + /** + * Get username + * @return username + */ + public String username { get; set; } + + /** + * Get firstName + * @return firstName + */ + public String firstName { get; set; } + + /** + * Get lastName + * @return lastName + */ + public String lastName { get; set; } + + /** + * Get email + * @return email + */ + public String email { get; set; } + + /** + * Get password + * @return password + */ + public String password { get; set; } + + /** + * Get phone + * @return phone + */ + public String phone { get; set; } + + /** + * User Status + * @return userStatus + */ + public Integer userStatus { get; set; } + + public static SwagUser getExample() { + SwagUser user = new SwagUser(); + user.id = 123456789L; + user.username = 'aeiou'; + user.firstName = 'aeiou'; + user.lastName = 'aeiou'; + user.email = 'aeiou'; + user.password = 'aeiou'; + user.phone = 'aeiou'; + user.userStatus = 123; + return user; + } + + public Boolean equals(Object obj) { + if (obj instanceof SwagUser) { + SwagUser user = (SwagUser) obj; + return this.id == user.id + && this.username == user.username + && this.firstName == user.firstName + && this.lastName == user.lastName + && this.email == user.email + && this.password == user.password + && this.phone == user.phone + && this.userStatus == user.userStatus; + } + return false; + } + + public Integer hashCode() { + Integer hashCode = 43; + hashCode = (17 * hashCode) + (id == null ? 0 : System.hashCode(id)); + hashCode = (17 * hashCode) + (username == null ? 0 : System.hashCode(username)); + hashCode = (17 * hashCode) + (firstName == null ? 0 : System.hashCode(firstName)); + hashCode = (17 * hashCode) + (lastName == null ? 0 : System.hashCode(lastName)); + hashCode = (17 * hashCode) + (email == null ? 0 : System.hashCode(email)); + hashCode = (17 * hashCode) + (password == null ? 0 : System.hashCode(password)); + hashCode = (17 * hashCode) + (phone == null ? 0 : System.hashCode(phone)); + hashCode = (17 * hashCode) + (userStatus == null ? 0 : System.hashCode(userStatus)); + return hashCode; + } +} + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagUser.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagUser.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagUser.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagUserApi.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagUserApi.cls new file mode 100644 index 00000000000..01d9ebe4013 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagUserApi.cls @@ -0,0 +1,223 @@ +/* + * Swagger Petstore + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + +public class SwagUserApi { + SwagClient client; + + public SwagUserApi(SwagClient client) { + this.client = client; + } + + public SwagUserApi() { + this.client = new SwagClient(); + } + + public SwagClient getClient() { + return this.client; + } + + /** + * Create user + * This can only be done by the logged in user. + * @param body Created user object (required) + * @throws Swagger.ApiException if fails to make API call + */ + public void createUser(Map params) { + client.assertNotNull(params.get('body'), 'body'); + List query = new List(); + List form = new List(); + + client.invoke( + 'POST', '/user', + (SwagUser) params.get('body'), + query, form, + new Map(), + new Map(), + new List{ 'application/json' }, + new List{ 'application/json' }, + new List(), + null + ); + } + /** + * Creates list of users with given input array + * + * @param body List of user object (required) + * @throws Swagger.ApiException if fails to make API call + */ + public void createUsersWithArrayInput(Map params) { + client.assertNotNull(params.get('body'), 'body'); + List query = new List(); + List form = new List(); + + client.invoke( + 'POST', '/user/createWithArray', + (List) params.get('body'), + query, form, + new Map(), + new Map(), + new List{ 'application/json' }, + new List{ 'application/json' }, + new List(), + null + ); + } + /** + * Creates list of users with given input array + * + * @param body List of user object (required) + * @throws Swagger.ApiException if fails to make API call + */ + public void createUsersWithListInput(Map params) { + client.assertNotNull(params.get('body'), 'body'); + List query = new List(); + List form = new List(); + + client.invoke( + 'POST', '/user/createWithList', + (List) params.get('body'), + query, form, + new Map(), + new Map(), + new List{ 'application/json' }, + new List{ 'application/json' }, + new List(), + null + ); + } + /** + * Delete user + * This can only be done by the logged in user. + * @param username The name that needs to be deleted (required) + * @throws Swagger.ApiException if fails to make API call + */ + public void deleteUser(Map params) { + client.assertNotNull(params.get('username'), 'username'); + List query = new List(); + List form = new List(); + + client.invoke( + 'DELETE', '/user/{username}', '', + query, form, + new Map{ + 'username' => (String) params.get('username') + }, + new Map(), + new List{ 'application/json' }, + new List{ 'application/json' }, + new List(), + null + ); + } + /** + * Get user by user name + * + * @param username The name that needs to be fetched. Use user1 for testing. (required) + * @return SwagUser + * @throws Swagger.ApiException if fails to make API call + */ + public SwagUser getUserByName(Map params) { + client.assertNotNull(params.get('username'), 'username'); + List query = new List(); + List form = new List(); + + return (SwagUser) client.invoke( + 'GET', '/user/{username}', '', + query, form, + new Map{ + 'username' => (String) params.get('username') + }, + new Map(), + new List{ 'application/json' }, + new List{ 'application/json' }, + new List(), + SwagUser.class + ); + } + /** + * Logs user into the system + * + * @param username The user name for login (required) + * @param password The password for login in clear text (required) + * @return String + * @throws Swagger.ApiException if fails to make API call + */ + public String loginUser(Map params) { + client.assertNotNull(params.get('username'), 'username'); + client.assertNotNull(params.get('password'), 'password'); + List query = new List(); + + // cast query params to verify their expected type + query.addAll(client.makeParam('username', (String) params.get('username'))); + query.addAll(client.makeParam('password', (String) params.get('password'))); + + List form = new List(); + + return (String) client.invoke( + 'GET', '/user/login', '', + query, form, + new Map(), + new Map(), + new List{ 'application/json' }, + new List{ 'application/json' }, + new List(), + String.class + ); + } + /** + * Logs out current logged in user session + * + * @throws Swagger.ApiException if fails to make API call + */ + public void logoutUser() { + List query = new List(); + List form = new List(); + + client.invoke( + 'GET', '/user/logout', '', + query, form, + new Map(), + new Map(), + new List{ 'application/json' }, + new List{ 'application/json' }, + new List(), + null + ); + } + /** + * Updated user + * This can only be done by the logged in user. + * @param username name that need to be deleted (required) + * @param body Updated user object (required) + * @throws Swagger.ApiException if fails to make API call + */ + public void updateUser(Map params) { + client.assertNotNull(params.get('username'), 'username'); + client.assertNotNull(params.get('body'), 'body'); + List query = new List(); + List form = new List(); + + client.invoke( + 'PUT', '/user/{username}', + (SwagUser) params.get('body'), + query, form, + new Map{ + 'username' => (String) params.get('username') + }, + new Map(), + new List{ 'application/json' }, + new List{ 'application/json' }, + new List(), + null + ); + } +} diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagUserApi.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagUserApi.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagUserApi.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagUserApiTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagUserApiTest.cls new file mode 100644 index 00000000000..637f55bd5a5 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagUserApiTest.cls @@ -0,0 +1,204 @@ +@isTest +private class SwagUserApiTest { + /** + * Create user + * + * This can only be done by the logged in user. + */ + @isTest + private static void createUserTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(201); + res.setStatus('Created'); + Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + + Map params = new Map{ + 'body' => SwagUser.getExample() + }; + + SwagClient client; + SwagUserApi api; + + api = new SwagUserApi(new SwagClient()); + + api.createUser(params); + } + + /** + * Creates list of users with given input array + * + * + */ + @isTest + private static void createUsersWithArrayInputTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + + Map params = new Map{ + 'body' => new List{SwagUser.getExample()} + }; + + SwagClient client; + SwagUserApi api; + + api = new SwagUserApi(new SwagClient()); + + api.createUsersWithArrayInput(params); + } + + /** + * Creates list of users with given input array + * + * + */ + @isTest + private static void createUsersWithListInputTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + + Map params = new Map{ + 'body' => new List{SwagUser.getExample()} + }; + + SwagClient client; + SwagUserApi api; + + api = new SwagUserApi(new SwagClient()); + + api.createUsersWithListInput(params); + } + + /** + * Delete user + * + * This can only be done by the logged in user. + */ + @isTest + private static void deleteUserTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + + Map params = new Map{ + 'username' => 'username_example' + }; + + SwagClient client; + SwagUserApi api; + + api = new SwagUserApi(new SwagClient()); + + api.deleteUser(params); + } + + /** + * Get user by user name + * + * + */ + @isTest + private static void getUserByNameTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + + Map params = new Map{ + 'username' => 'username_example' + }; + + SwagClient client; + SwagUserApi api; + SwagUser response; + SwagUser expectedResponse; + + api = new SwagUserApi(new SwagClient()); + + res.setHeader('Content-Type', 'application/json'); + res.setBody('{\n "firstName" : "aeiou",\n "lastName" : "aeiou",\n "password" : "aeiou",\n "userStatus" : 6,\n "phone" : "aeiou",\n "id" : 0,\n "email" : "aeiou",\n "username" : "aeiou"\n}'); + expectedResponse = SwagUser.getExample(); + response = (SwagUser) api.getUserByName(params); + System.assertEquals(expectedResponse, response); + } + + /** + * Logs user into the system + * + * + */ + @isTest + private static void loginUserTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + + Map params = new Map{ + 'username' => 'username_example', + 'password' => 'password_example' + }; + + SwagClient client; + SwagUserApi api; + String response; + String expectedResponse; + + api = new SwagUserApi(new SwagClient()); + + res.setHeader('Content-Type', 'application/json'); + res.setBody('"aeiou"'); + expectedResponse = 'aeiou'; + response = (String) api.loginUser(params); + System.assertEquals(expectedResponse, response); + } + + /** + * Logs out current logged in user session + * + * + */ + @isTest + private static void logoutUserTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + + SwagClient client; + SwagUserApi api; + + api = new SwagUserApi(new SwagClient()); + + api.logoutUser(); + } + + /** + * Updated user + * + * This can only be done by the logged in user. + */ + @isTest + private static void updateUserTest() { + HttpResponse res = new HttpResponse(); + res.setStatusCode(200); + res.setStatus('OK'); + Test.setMock(HttpCalloutMock.class, new SwaggerResponseMock(res)); + + Map params = new Map{ + 'username' => 'username_example', + 'body' => SwagUser.getExample() + }; + + SwagClient client; + SwagUserApi api; + + api = new SwagUserApi(new SwagClient()); + + api.updateUser(params); + } +} \ No newline at end of file diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagUserApiTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagUserApiTest.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagUserApiTest.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagUserTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwagUserTest.cls new file mode 100644 index 00000000000..ec89e21ac1f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagUserTest.cls @@ -0,0 +1,80 @@ +@isTest +private class SwagUserTest { + @isTest + private static void equalsSameInstance() { + SwagUser user1 = SwagUser.getExample(); + SwagUser user2 = user1; + SwagUser user3 = new SwagUser(); + SwagUser user4 = user3; + + System.assert(user1.equals(user2)); + System.assert(user2.equals(user1)); + System.assert(user1.equals(user1)); + System.assert(user3.equals(user4)); + System.assert(user4.equals(user3)); + System.assert(user3.equals(user3)); + } + + @isTest + private static void equalsIdenticalInstance() { + SwagUser user1 = SwagUser.getExample(); + SwagUser user2 = SwagUser.getExample(); + SwagUser user3 = new SwagUser(); + SwagUser user4 = new SwagUser(); + + System.assert(user1.equals(user2)); + System.assert(user2.equals(user1)); + System.assert(user3.equals(user4)); + System.assert(user4.equals(user3)); + } + + @isTest + private static void notEqualsUnlikeInstance() { + SwagUser user1 = SwagUser.getExample(); + SwagUser user2 = new SwagUser(); + + System.assertEquals(false, user1.equals(user2)); + System.assertEquals(false, user2.equals(user1)); + } + + @isTest + private static void notEqualsDifferentType() { + SwagUser user1 = SwagUser.getExample(); + SwagUser user2 = new SwagUser(); + + System.assertEquals(false, user1.equals('foo')); + System.assertEquals(false, user2.equals('foo')); + } + + @isTest + private static void notEqualsNull() { + SwagUser user1 = SwagUser.getExample(); + SwagUser user2 = new SwagUser(); + SwagUser user3; + + System.assertEquals(false, user1.equals(user3)); + System.assertEquals(false, user2.equals(user3)); + } + + @isTest + private static void consistentHashCodeValue() { + SwagUser user1 = SwagUser.getExample(); + SwagUser user2 = new SwagUser(); + + System.assertEquals(user1.hashCode(), user1.hashCode()); + System.assertEquals(user2.hashCode(), user2.hashCode()); + } + + @isTest + private static void equalInstancesHaveSameHashCode() { + SwagUser user1 = SwagUser.getExample(); + SwagUser user2 = SwagUser.getExample(); + SwagUser user3 = new SwagUser(); + SwagUser user4 = new SwagUser(); + + System.assert(user1.equals(user2)); + System.assert(user3.equals(user4)); + System.assertEquals(user1.hashCode(), user2.hashCode()); + System.assertEquals(user3.hashCode(), user4.hashCode()); + } +} diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwagUserTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwagUserTest.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwagUserTest.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/Swagger.cls b/samples/client/petstore/apex/force-app/main/default/classes/Swagger.cls new file mode 100644 index 00000000000..172c3038111 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/Swagger.cls @@ -0,0 +1,313 @@ +public class Swagger { + private static final String HEADER_CONTENT_TYPE = 'Content-Type'; + private static final String HEADER_ACCEPT = 'Accept'; + private static final String HEADER_ACCEPT_DELIMITER = ','; + private static final Map DELIMITERS = new Map { + 'csv' => ',', + 'ssv' => ' ', + 'tsv' => '\t', + 'pipes' => '|' + }; + + public class Param { + private String name, value; + + public Param(String name, String value) { + this.name = name; + this.value = value; + } + + public override String toString() { + return EncodingUtil.urlEncode(name, 'UTF-8') + '=' + + EncodingUtil.urlEncode(value, 'UTF-8'); + } + } + + public interface Authentication { + void apply(Map headers, List query); + } + + public interface MappedProperties { + Map getPropertyMappings(); + } + + public abstract class ApiKeyAuth implements Authentication { + protected final String paramName; + protected String key = ''; + + public void setApiKey(String key) { + this.key = key; + } + + @TestVisible + private String getApiKey() { + return key; + } + } + + public class ApiKeyQueryAuth extends ApiKeyAuth { + public ApiKeyQueryAuth(String paramName) { + this.paramName = paramName; + } + + public void apply(Map headers, List query) { + query.add(new Param(paramName, key)); + } + } + + public class ApiKeyHeaderAuth extends ApiKeyAuth { + public ApiKeyHeaderAuth(String paramName) { + this.paramName = paramName; + } + + public void apply(Map headers, List query) { + headers.put(paramName, key); + } + } + + + public class ApiException extends Exception { + private final Integer code; + private final String status; + private final Map headers; + private final String body; + + public ApiException(Integer code, String status, Map headers, String body) { + this('API returned HTTP ' + code + ': ' + status); + this.code = code; + this.status = status; + this.headers = headers; + this.body = body; + } + + public Integer getStatusCode() { + return code; + } + + public String getStatus() { + return status; + } + + public Map getHeaders() { + return headers; + } + + public String getBody() { + return body; + } + } + + public virtual class ApiClient { + protected String preferredContentType = 'application/json'; + protected String preferredAccept = 'application/json'; + protected final String basePath; + protected final String calloutName; + + @TestVisible + protected final Map authentications = new Map(); + + public virtual Authentication getAuthentication(String authName) { + return authentications.get(authName); + } + + public virtual void setApiKey(String apiKey) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKey(apiKey); + return; + } + } + throw new NoSuchElementException('No API key authentication configured!'); + } + + public List makeParams(String name, List values) { + List pairs = new List(); + for (Object value : new List(values)) { + pairs.add(new Param(name, String.valueOf(value))); + } + return pairs; + } + + public List makeParam(String name, List values, String format) { + List pairs = new List(); + if (values != null) { + String delimiter = DELIMITERS.get(format); + pairs.add(new Param(name, String.join(values, delimiter))); + } + return pairs; + } + + public List makeParam(String name, Object value) { + List pairs = new List(); + if (value != null) { + pairs.add(new Param(name, String.valueOf(value))); + } + return pairs; + } + + public virtual void assertNotNull(Object required, String parameterName) { + if (required == null) { + Exception e = new NullPointerException(); + e.setMessage('Argument cannot be null: ' + parameterName); + throw e; + } + } + + public virtual Object invoke( + String method, String path, Object body, List query, List form, + Map pathParams, Map headers, List accepts, + List contentTypes, List authMethods, Type returnType) { + + HttpResponse res = getResponse(method, path, body, query, form, pathParams, headers, + accepts, contentTypes, authMethods); + + Integer code = res.getStatusCode(); + Boolean isFailure = code / 100 != 2; + if (isFailure) { + throw new ApiException(code, res.getStatus(), getHeaders(res), res.getBody()); + } else if (returnType != null) { + return toReturnValue(res.getBody(), returnType, res.getHeader('Content-Type')); + } + return null; + } + + @TestVisible + protected virtual Map getHeaders(HttpResponse res) { + Map headers = new Map(); + List headerKeys = res.getHeaderKeys(); + for (String headerKey : headerKeys) { + headers.put(headerKey, res.getHeader(headerKey)); + } + return headers; + } + + @TestVisible + protected virtual Object toReturnValue(String body, Type returnType, String contentType) { + if (contentType == 'application/json') { + Object o = returnType.newInstance(); + if (o instanceof MappedProperties) { + Map propertyMappings = ((MappedProperties) o).getPropertyMappings(); + for (String baseName : propertyMappings.keySet()) { + body = body.replaceAll('"' + baseName + '"\\s*:', + '"' + propertyMappings.get(baseName) + '":'); + } + } + JsonParser parser = Json.createParser(body); + parser.nextToken(); + return parser.readValueAs(returnType); + } + return body; + } + + @TestVisible + protected virtual HttpResponse getResponse( + String method, String path, Object body, List query, List form, + Map pathParams, Map headers, List accepts, + List contentTypes, List authMethods) { + + HttpRequest req = new HttpRequest(); + applyAuthentication(authMethods, headers, query); + req.setMethod(method); + req.setEndpoint(toEndpoint(path, pathParams, query)); + String contentType = setContentTypeHeader(contentTypes, headers); + setAcceptHeader(accepts, headers); + setHeaders(req, headers); + + if (method != 'GET') { + req.setBody(toBody(contentType, body, form)); + } + + return new Http().send(req); + } + + @TestVisible + protected virtual void setHeaders(HttpRequest req, Map headers) { + for (String headerName : headers.keySet()) { + req.setHeader(headerName, String.valueOf(headers.get(headerName))); + } + } + + @TestVisible + protected virtual String toBody(String contentType, Object body, List form) { + if (contentType.contains('application/x-www-form-urlencoded')) { + return paramsToString(form); + } else if (contentType.contains('application/json')) { + return Json.serialize(body); + } + return String.valueOf(body); + } + + @TestVisible + protected virtual String setContentTypeHeader(List contentTypes, + Map headers) { + if (contentTypes.isEmpty()) { + headers.put(HEADER_CONTENT_TYPE, preferredContentType); + return preferredContentType; + } + for (String contentType : contentTypes) { + if (preferredContentType == contentType) { + headers.put(HEADER_CONTENT_TYPE, contentType); + return contentType; + } + } + String contentType = contentTypes.get(0); + headers.put(HEADER_CONTENT_TYPE, contentType); + return contentType; + } + + @TestVisible + protected virtual void setAcceptHeader(List accepts, Map headers) { + for (String accept : accepts) { + if (preferredAccept == accept) { + headers.put(HEADER_ACCEPT, accept); + return; + } + } + if (!accepts.isEmpty()) { + headers.put(HEADER_ACCEPT, String.join(accepts, HEADER_ACCEPT_DELIMITER)); + } + } + + @TestVisible + protected virtual void applyAuthentication(List names, Map headers, + List query) { + for (Authentication auth : getAuthMethods(names)) { + auth.apply(headers, query); + } + } + + @TestVisible + protected virtual List getAuthMethods(List names) { + List authMethods = new List(); + for (String name : names) { + authMethods.add(authentications.get(name)); + } + return authMethods; + } + + @TestVisible + protected virtual String toPath(String path, Map params) { + String formatted = path; + for (String key : params.keySet()) { + formatted = formatted.replace('{' + key + '}', String.valueOf(params.get(key))); + } + return formatted; + } + + @TestVisible + protected virtual String toEndpoint(String path, Map params, + List queryParams) { + String query = '?' + paramsToString(queryParams); + return '"callout:' + calloutName + toPath(path, params) + query.removeEnd('?') + '""'; + } + + @TestVisible + protected virtual String paramsToString(List params) { + String s = ''; + for (Param p : params) { + s += '&' + p; + } + return s.removeStart('&'); + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/apex/force-app/main/default/classes/Swagger.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/Swagger.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/Swagger.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwaggerResponseMock.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwaggerResponseMock.cls new file mode 100644 index 00000000000..7d3acb1a91f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwaggerResponseMock.cls @@ -0,0 +1,18 @@ +@isTest +public class SwaggerResponseMock implements HttpCalloutMock { + private final HttpResponse response; + private HttpRequest request; + + public SwaggerResponseMock(HttpResponse response) { + this.response = response; + } + + public HttpResponse respond(HttpRequest request) { + this.request = request; + return response; + } + + public HttpRequest getRequest() { + return request; + } +} \ No newline at end of file diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwaggerResponseMock.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwaggerResponseMock.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwaggerResponseMock.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwaggerTest.cls b/samples/client/petstore/apex/force-app/main/default/classes/SwaggerTest.cls new file mode 100644 index 00000000000..e3cec8831c6 --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwaggerTest.cls @@ -0,0 +1,366 @@ +@isTest +private class SwaggerTest { + @isTest + private static void Param_urlEncodeKeyValuePairUtf8() { + String toEncodeLeft = 'Hello +%-_.!~*\'()@'; + String toEncodeRight = 'World +%-_.!~*\'()@'; + String expected = 'Hello+%2B%25-_.%21%7E*%27%28%29%40=World+%2B%25-_.%21%7E*%27%28%29%40'; + String result = new Swagger.Param(toEncodeLeft, toEncodeRight).toString(); + System.assertEquals(expected, result); + } + + @isTest + private static void ApiKeyHeaderAuth_keyInHeaderWithGivenName() { + Map headers = new Map(); + List query = new List(); + Swagger.ApiKeyHeaderAuth auth = new Swagger.ApiKeyHeaderAuth('X-Authenticate'); + auth.setApiKey('foo-bar-api-key'); + auth.apply(headers, query); + + System.assert(query.isEmpty()); + System.assertEquals(1, headers.size()); + System.assertEquals('foo-bar-api-key', headers.get('X-Authenticate')); + } + + @isTest + private static void ApiKeyQueryAuth_keyInQueryParamWithGivenName() { + Map headers = new Map(); + List query = new List(); + Swagger.ApiKeyQueryAuth auth = new Swagger.ApiKeyQueryAuth('auth_token'); + auth.setApiKey('foo-bar-api-key'); + auth.apply(headers, query); + + System.assert(headers.isEmpty()); + System.assertEquals(1, query.size()); + System.assertEquals('auth_token=foo-bar-api-key', query.get(0).toString()); + } + + @isTest + private static void ApiClient_returnAuthenticationMatchingInput() { + MockApiClient client = new MockApiClient(); + Swagger.ApiKeyHeaderAuth auth1 = new Swagger.ApiKeyHeaderAuth('foo'); + Swagger.ApiKeyQueryAuth auth2 = new Swagger.ApiKeyQueryAuth('foo'); + + client.authentications.put('auth1', auth1); + client.authentications.put('auth2', auth2); + + System.assertEquals(auth1, client.getAuthentication('auth1')); + System.assertEquals(auth2, client.getAuthentication('auth2')); + } + + @isTest + private static void ApiClient_oneKeyValuePairForEachValueInList() { + List values = new List{'bar', 4, false, 12.4, ''}; + Swagger.ApiClient client = new Swagger.ApiClient(); + List params = client.makeParams('foo', values); + + System.assertEquals(5, params.size()); + System.assertEquals('foo=bar', params.get(0).toString()); + System.assertEquals('foo=4', params.get(1).toString()); + System.assertEquals('foo=false', params.get(2).toString()); + System.assertEquals('foo=12.4', params.get(3).toString()); + System.assertEquals('foo=', params.get(4).toString()); + } + + @isTest + private static void ApiClient_nullMultiValuesListToEmptyParamsList() { + Swagger.ApiClient client = new Swagger.ApiClient(); + List params = client.makeParams('foo', null); + + System.assert(params.isEmpty()); + } + + @isTest + private static void ApiClient_valuesListToSingleCsvKeyValuePair() { + List values = new List{'bar', 4, false, 12.4, ''}; + Swagger.ApiClient client = new Swagger.ApiClient(); + List params = client.makeParam('foo', values, 'csv'); + + System.assertEquals(1, params.size()); + System.assertEquals('foo=bar%2C4%2Cfalse%2C12.4%2C', params.get(0).toString()); + } + + @isTest + private static void ApiClient_valuesListToSingleSsvKeyValuePair() { + List values = new List{'bar', 4, false, 12.4, ''}; + Swagger.ApiClient client = new Swagger.ApiClient(); + List params = client.makeParam('foo', values, 'ssv'); + + System.assertEquals(1, params.size()); + System.assertEquals('foo=bar+4+false+12.4+', params.get(0).toString()); + } + + @isTest + private static void ApiClient_valuesListToSingleTsvKeyValuePair() { + List values = new List{'bar', 4, false, 12.4, ''}; + Swagger.ApiClient client = new Swagger.ApiClient(); + List params = client.makeParam('foo', values, 'tsv'); + + System.assertEquals(1, params.size()); + System.assertEquals('foo=bar%094%09false%0912.4%09', params.get(0).toString()); + } + + @isTest + private static void ApiClient_valuesListToSinglePipeSeparatedKeyValuePair() { + List values = new List{'bar', 4, false, 12.4, ''}; + Swagger.ApiClient client = new Swagger.ApiClient(); + List params = client.makeParam('foo', values, 'pipes'); + + System.assertEquals(1, params.size()); + System.assertEquals('foo=bar%7C4%7Cfalse%7C12.4%7C', params.get(0).toString()); + } + + @isTest + private static void ApiClient_nullValuesListToEmptyParamsList() { + Swagger.ApiClient client = new Swagger.ApiClient(); + List params = client.makeParam('foo', null, 'csv'); + + System.assert(params.isEmpty()); + } + + @isTest + private static void ApiClient_paramsFromAnyPrimitiveTypeDiscardNull() { + Swagger.ApiClient client = new Swagger.ApiClient(); + List params = new List(); + params.addAll(client.makeParam('foo', 'bar')); + params.addAll(client.makeParam('foo', 10)); + params.addAll(client.makeParam('foo', 12.6)); + params.addAll(client.makeParam('foo', true)); + params.addAll(client.makeParam('foo', '')); + params.addAll(client.makeParam('foo', Datetime.newInstanceGmt(2017, 1, 1, 15, 0, 0))); + params.addAll(client.makeParam('foo', null)); + + System.assertEquals(6, params.size()); + System.assertEquals('foo=bar', params.get(0).toString()); + System.assertEquals('foo=10', params.get(1).toString()); + System.assertEquals('foo=12.6', params.get(2).toString()); + System.assertEquals('foo=true', params.get(3).toString()); + System.assertEquals('foo=', params.get(4).toString()); + System.assertEquals('foo=2017-01-01+15%3A00%3A00', params.get(5).toString()); + } + + @isTest + private static void ApiClient_requiredParameterPasses() { + Swagger.ApiClient client = new Swagger.ApiClient(); + client.assertNotNull('foo', 'bar'); + } + + @isTest + private static void ApiClient_requiredParameterFails() { + Swagger.ApiClient client = new Swagger.ApiClient(); + try { + client.assertNotNull(null, 'bar'); + } catch (NullPointerException e) { + System.assertEquals('Argument cannot be null: bar', e.getMessage()); + return; + } + System.assert(false); + } + + @isTest + private static void ApiClient_extractHeadersFromResponse() { + HttpResponse res = new HttpResponse(); + res.setHeader('Content-Type', 'application/json'); + res.setHeader('Cache-Control', 'private, max-age=0'); + Map headers = new MockApiClient().getHeaders(res); + + System.assertEquals(2, headers.size()); + System.assertEquals('application/json', headers.get('Content-Type')); + System.assertEquals('private, max-age=0', headers.get('Cache-Control')); + } + + @isTest + private static void ApiClient_deserializeResponseBodyByContentType() { + MockApiClient client = new MockApiClient(); + String jsonBody = '{"red":"apple","yellow":"banana","orange":"orange"}'; + Map result1 = (Map) client + .toReturnValue(jsonBody, Map.class, 'application/json'); + + System.assertEquals(3, result1.size()); + System.assertEquals('apple', result1.get('red')); + System.assertEquals('banana', result1.get('yellow')); + System.assertEquals('orange', result1.get('orange')); + + String result2 = (String) client + .toReturnValue('Hello, World!', String.class, 'text/plain'); + + System.assertEquals('Hello, World!', result2); + } + + @isTest + private static void ApiClient_addStringifiedHeadersToRequest() { + MockApiClient client = new MockApiClient(); + Map headers = new Map{ + 'Content-Type' => 'application/json', + 'Max-Forwards' => 10 + }; + HttpRequest req = new HttpRequest(); + client.setHeaders(req, headers); + + System.assertEquals('application/json', req.getHeader('Content-Type')); + System.assertEquals('10', req.getHeader('Max-Forwards')); + } + + @isTest + private static void ApiClient_serializeRequestBodyOrFormByContentType() { + MockApiClient client = new MockApiClient(); + Map body1 = new Map{ + 'hello' => 'world', + 'foo' => 15, + 'bar' => Datetime.newInstanceGmt(2017, 1, 1, 15, 0, 0), + 'bat' => false + }; + Set expected1 = new Set{ + '"hello":"world"', + '"foo":15', + '"bar":"2017-01-01T15:00:00.000Z"', + '"bat":false' + }; + Set actual1 = new Set(client + .toBody('application/json', body1, new List()) + .removeStart('{') + .removeEnd('}') + .split(',') + ); + System.assertEquals(expected1, actual1); + + String body2 = 'Hello, World!'; + String actual2 = client.toBody('text/plain', body2, new List()); + System.assertEquals(body2, actual2); + + List form = new List{ + new Swagger.Param('hello', 'world'), + new Swagger.Param('date', '2017-01-01 15:00:00') + }; + String expected3 = 'hello=world&date=2017-01-01+15%3A00%3A00'; + String actual3 = client.toBody('application/x-www-form-urlencoded', '', form); + System.assertEquals(expected3, actual3); + } + + @isTest + private static void ApiClient_usePreferredContentTypeOrFirstInList() { + MockApiClient client = new MockApiClient(); + + Map headers1 = new Map(); + List types1 = new List{'application/xml', 'application/json', 'text/plain'}; + String result1 = client.setContentTypeHeader(types1, headers1); + System.assertEquals(1, headers1.size()); + System.assertEquals('application/json', headers1.get('Content-Type')); + System.assertEquals('application/json', result1); + + Map headers2 = new Map(); + List types2 = new List{'application/xml', 'text/plain'}; + String result2 = client.setContentTypeHeader(types2, headers2); + System.assertEquals(1, headers2.size()); + System.assertEquals('application/xml', headers2.get('Content-Type')); + System.assertEquals('application/xml', result2); + + Map headers3 = new Map(); + String result3 = client.setContentTypeHeader(new List(), headers3); + System.assertEquals(1, headers3.size()); + System.assertEquals('application/json', headers3.get('Content-Type')); + System.assertEquals('application/json', result3); + } + + @isTest + private static void ApiClient_usePreferredAcceptOrAllInListNoDefault() { + MockApiClient client = new MockApiClient(); + + Map headers1 = new Map(); + List types1 = new List{'application/xml', 'application/json', 'text/plain'}; + client.setAcceptHeader(types1, headers1); + System.assertEquals(1, headers1.size()); + System.assertEquals('application/json', headers1.get('Accept')); + + Map headers2 = new Map(); + List types2 = new List{'application/xml', 'text/plain'}; + client.setAcceptHeader(types2, headers2); + System.assertEquals(1, headers2.size()); + System.assertEquals('application/xml,text/plain', headers2.get('Accept')); + + Map headers3 = new Map(); + client.setAcceptHeader(new List(), headers3); + System.assert(headers3.isEmpty()); + } + + @isTest + private static void ApiClient_formUrlWithQueryParamsPathParams() { + MockApiClient client = new MockApiClient(); + String path = '/departments/{department}'; + Map params = new Map{'department' => 'finance'}; + List queryParams = new List{ + new Swagger.Param('foo', 'bar'), + new Swagger.Param('bat', '123') + }; + String expected = 'https://www.mccombs.utexas.edu/departments/finance?foo=bar&bat=123'; + String actual = client.toEndpoint(path, params, queryParams); + System.assertEquals(expected, actual); + } + + @isTest + private static void ApiClient_returnParsedBody() { + MockApiClient client = new MockApiClient(); + HttpResponse res = new HttpResponse(); + SwaggerResponseMock mock = new SwaggerResponseMock(res); + Test.setMock(HttpCalloutMock.class, mock); + + res.setStatus('OK'); + res.setStatusCode(200); + res.setHeader('Content-Type', 'application/json'); + res.setBody('{' + + '"city":"Austin","country":"United States","latitude":30.28403639999999,' + + '"longitude":-97.73789449999998,"postalCode":"78705","state":"Texas",' + + '"street":"2110 Speedway"}'); + + Address a = (Address) client.invoke( + 'GET', '/address', '', + new List(), + new List(), + new Map(), + new Map(), + new List{'application/json'}, + new List{'text/plain'}, + new List(), + Address.class + ); + + System.assertEquals('Austin', a.getCity()); + System.assertEquals('United States', a.getCountry()); + System.assertEquals(30.28403639999999, a.getLatitude()); + System.assertEquals(-97.73789449999998, a.getLongitude()); + System.assertEquals('78705', a.getPostalCode()); + System.assertEquals('Texas', a.getState()); + System.assertEquals('2110 Speedway', a.getStreet()); + } + + @isTest + private static void ApiClient_noReturnTypeReturnsNull() { + MockApiClient client = new MockApiClient(); + HttpResponse res = new HttpResponse(); + SwaggerResponseMock mock = new SwaggerResponseMock(res); + Test.setMock(HttpCalloutMock.class, mock); + + res.setStatus('OK'); + res.setStatusCode(200); + + Object o = client.invoke( + 'POST', '/address', '', + new List(), + new List(), + new Map(), + new Map(), + new List{'application/json'}, + new List{'text/plain'}, + new List(), + null + ); + + System.assertEquals(null, o); + } + + private class MockApiClient extends Swagger.ApiClient { + public MockApiClient() { + basePath = 'https://www.mccombs.utexas.edu'; + } + } +} \ No newline at end of file diff --git a/samples/client/petstore/apex/force-app/main/default/classes/SwaggerTest.cls-meta.xml b/samples/client/petstore/apex/force-app/main/default/classes/SwaggerTest.cls-meta.xml new file mode 100644 index 00000000000..8b061c82b6f --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/classes/SwaggerTest.cls-meta.xml @@ -0,0 +1,5 @@ + + + 39.0 + Active + diff --git a/samples/client/petstore/apex/force-app/main/default/namedCredentials/Swagger_Petstore.namedCredential b/samples/client/petstore/apex/force-app/main/default/namedCredentials/Swagger_Petstore.namedCredential new file mode 100644 index 00000000000..e7d8d71ac1c --- /dev/null +++ b/samples/client/petstore/apex/force-app/main/default/namedCredentials/Swagger_Petstore.namedCredential @@ -0,0 +1,7 @@ + + + http://petstore.swagger.io/v2 + Anonymous + NoAuthentication + + \ No newline at end of file From ef35b80bd873281266389941382a6ecea65eb17a Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 29 May 2017 11:45:28 +0800 Subject: [PATCH 07/10] Fixed missing isWildcard method used in templates --- .../src/main/java/io/swagger/codegen/CodegenResponse.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenResponse.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenResponse.java index b2a734fc9b2..05901ba7236 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenResponse.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenResponse.java @@ -23,6 +23,10 @@ public class CodegenResponse { public String jsonSchema; public Map vendorExtensions; + public boolean isWildcard() { + return "0".equals(code) || "default".equals(code); + } + @Override public String toString() { return String.format("%s(%s)", code, containerType); From ea30a4a7f84b020bddde06ef7e81468a0fb96316 Mon Sep 17 00:00:00 2001 From: Cliffano Subagio Date: Mon, 29 May 2017 16:56:48 +1000 Subject: [PATCH 08/10] [Ruby] Chunked file download (#5718) * [Ruby] Modify file download to be written in chunks in order to handle large files. #5704 * [Ruby] Update Ruby Petstore with file download improvement. #5704 --- .../main/resources/ruby/api_client.mustache | 60 +++++++++++-------- samples/client/petstore/ruby/README.md | 4 +- samples/client/petstore/ruby/lib/petstore.rb | 4 +- .../petstore/ruby/lib/petstore/api_client.rb | 60 +++++++++++-------- .../ruby/lib/petstore/models/outer_boolean.rb | 1 + .../lib/petstore/models/outer_composite.rb | 1 + .../ruby/lib/petstore/models/outer_number.rb | 1 + .../ruby/lib/petstore/models/outer_string.rb | 1 + 8 files changed, 80 insertions(+), 52 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache b/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache index cf03f368075..f2a71385cb4 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/api_client.mustache @@ -117,7 +117,9 @@ module {{moduleName}} end end - Typhoeus::Request.new(url, req_opts) + request = Typhoeus::Request.new(url, req_opts) + download_file(request) if opts[:return_type] == 'File' + request end # Check if the given MIME is a JSON MIME. @@ -138,14 +140,16 @@ module {{moduleName}} # @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]" def deserialize(response, return_type) body = response.body + + # handle file downloading - return the File instance processed in request callbacks + # note that response body is empty when the file is written in chunks in request on_body callback + return @tempfile if return_type == 'File' + return nil if body.nil? || body.empty? # return response body directly for String return type return body if return_type == 'String' - # handle file downloading - save response body into a tmp file and return the File instance - return download_file(response) if return_type == 'File' - # ensuring a default content type content_type = response.headers['Content-Type'] || 'application/json' @@ -208,30 +212,38 @@ module {{moduleName}} # Save response body into a file in (the defined) temporary folder, using the filename # from the "Content-Disposition" header if provided, otherwise a random filename. + # The response body is written to the file in chunks in order to handle files which + # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby + # process can use. # # @see Configuration#temp_folder_path - # @return [Tempfile] the file downloaded - def download_file(response) - content_disposition = response.headers['Content-Disposition'] - if content_disposition and content_disposition =~ /filename=/i - filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1] - prefix = sanitize_filename(filename) - else - prefix = 'download-' - end - prefix = prefix + '-' unless prefix.end_with?('-') - + def download_file(request) tempfile = nil - encoding = response.body.encoding - Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding) do |file| - file.write(response.body) - tempfile = file + encoding = nil + request.on_headers do |response| + content_disposition = response.headers['Content-Disposition'] + if content_disposition and content_disposition =~ /filename=/i + filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1] + prefix = sanitize_filename(filename) + else + prefix = 'download-' + end + prefix = prefix + '-' unless prefix.end_with?('-') + encoding = response.body.encoding + tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding) + @tempfile = tempfile + end + request.on_body do |chunk| + chunk.force_encoding(encoding) + tempfile.write(chunk) + end + request.on_complete do |response| + tempfile.close + @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\ + "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\ + "will be deleted automatically with GC. It's also recommended to delete the temp file "\ + "explicitly with `tempfile.delete`" end - @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\ - "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\ - "will be deleted automatically with GC. It's also recommended to delete the temp file "\ - "explicitly with `tempfile.delete`" - tempfile end # Sanitize filename by removing path. diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 65217541997..74a6ba22182 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -114,11 +114,9 @@ Class | Method | HTTP request | Description - [Petstore::ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [Petstore::ArrayTest](docs/ArrayTest.md) - [Petstore::Capitalization](docs/Capitalization.md) - - [Petstore::Cat](docs/Cat.md) - [Petstore::Category](docs/Category.md) - [Petstore::ClassModel](docs/ClassModel.md) - [Petstore::Client](docs/Client.md) - - [Petstore::Dog](docs/Dog.md) - [Petstore::EnumArrays](docs/EnumArrays.md) - [Petstore::EnumClass](docs/EnumClass.md) - [Petstore::EnumTest](docs/EnumTest.md) @@ -142,6 +140,8 @@ Class | Method | HTTP request | Description - [Petstore::SpecialModelName](docs/SpecialModelName.md) - [Petstore::Tag](docs/Tag.md) - [Petstore::User](docs/User.md) + - [Petstore::Cat](docs/Cat.md) + - [Petstore::Dog](docs/Dog.md) ## Documentation for Authorization diff --git a/samples/client/petstore/ruby/lib/petstore.rb b/samples/client/petstore/ruby/lib/petstore.rb index a8a5d88e087..139cff5f94b 100644 --- a/samples/client/petstore/ruby/lib/petstore.rb +++ b/samples/client/petstore/ruby/lib/petstore.rb @@ -25,11 +25,9 @@ require 'petstore/models/array_of_array_of_number_only' require 'petstore/models/array_of_number_only' require 'petstore/models/array_test' require 'petstore/models/capitalization' -require 'petstore/models/cat' require 'petstore/models/category' require 'petstore/models/class_model' require 'petstore/models/client' -require 'petstore/models/dog' require 'petstore/models/enum_arrays' require 'petstore/models/enum_class' require 'petstore/models/enum_test' @@ -53,6 +51,8 @@ require 'petstore/models/read_only_first' require 'petstore/models/special_model_name' require 'petstore/models/tag' require 'petstore/models/user' +require 'petstore/models/cat' +require 'petstore/models/dog' # APIs require 'petstore/api/fake_api' diff --git a/samples/client/petstore/ruby/lib/petstore/api_client.rb b/samples/client/petstore/ruby/lib/petstore/api_client.rb index 9987fead008..6be0bf6f571 100644 --- a/samples/client/petstore/ruby/lib/petstore/api_client.rb +++ b/samples/client/petstore/ruby/lib/petstore/api_client.rb @@ -123,7 +123,9 @@ module Petstore end end - Typhoeus::Request.new(url, req_opts) + request = Typhoeus::Request.new(url, req_opts) + download_file(request) if opts[:return_type] == 'File' + request end # Check if the given MIME is a JSON MIME. @@ -144,14 +146,16 @@ module Petstore # @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]" def deserialize(response, return_type) body = response.body + + # handle file downloading - return the File instance processed in request callbacks + # note that response body is empty when the file is written in chunks in request on_body callback + return @tempfile if return_type == 'File' + return nil if body.nil? || body.empty? # return response body directly for String return type return body if return_type == 'String' - # handle file downloading - save response body into a tmp file and return the File instance - return download_file(response) if return_type == 'File' - # ensuring a default content type content_type = response.headers['Content-Type'] || 'application/json' @@ -214,30 +218,38 @@ module Petstore # Save response body into a file in (the defined) temporary folder, using the filename # from the "Content-Disposition" header if provided, otherwise a random filename. + # The response body is written to the file in chunks in order to handle files which + # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby + # process can use. # # @see Configuration#temp_folder_path - # @return [Tempfile] the file downloaded - def download_file(response) - content_disposition = response.headers['Content-Disposition'] - if content_disposition and content_disposition =~ /filename=/i - filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1] - prefix = sanitize_filename(filename) - else - prefix = 'download-' - end - prefix = prefix + '-' unless prefix.end_with?('-') - + def download_file(request) tempfile = nil - encoding = response.body.encoding - Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding) do |file| - file.write(response.body) - tempfile = file + encoding = nil + request.on_headers do |response| + content_disposition = response.headers['Content-Disposition'] + if content_disposition and content_disposition =~ /filename=/i + filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1] + prefix = sanitize_filename(filename) + else + prefix = 'download-' + end + prefix = prefix + '-' unless prefix.end_with?('-') + encoding = response.body.encoding + tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding) + @tempfile = tempfile + end + request.on_body do |chunk| + chunk.force_encoding(encoding) + tempfile.write(chunk) + end + request.on_complete do |response| + tempfile.close + @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\ + "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\ + "will be deleted automatically with GC. It's also recommended to delete the temp file "\ + "explicitly with `tempfile.delete`" end - @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\ - "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\ - "will be deleted automatically with GC. It's also recommended to delete the temp file "\ - "explicitly with `tempfile.delete`" - tempfile end # Sanitize filename by removing path. diff --git a/samples/client/petstore/ruby/lib/petstore/models/outer_boolean.rb b/samples/client/petstore/ruby/lib/petstore/models/outer_boolean.rb index a5c47be992e..c94636a6d5a 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_boolean.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_boolean.rb @@ -6,6 +6,7 @@ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 2.2.3-SNAPSHOT =end diff --git a/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb b/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb index 0d642a575c5..5e7765b4521 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_composite.rb @@ -6,6 +6,7 @@ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 2.2.3-SNAPSHOT =end diff --git a/samples/client/petstore/ruby/lib/petstore/models/outer_number.rb b/samples/client/petstore/ruby/lib/petstore/models/outer_number.rb index 07b7abe64ba..6e81499d8df 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_number.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_number.rb @@ -6,6 +6,7 @@ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 2.2.3-SNAPSHOT =end diff --git a/samples/client/petstore/ruby/lib/petstore/models/outer_string.rb b/samples/client/petstore/ruby/lib/petstore/models/outer_string.rb index 26ba9e52298..adb83e55f42 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/outer_string.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/outer_string.rb @@ -6,6 +6,7 @@ OpenAPI spec version: 1.0.0 Contact: apiteam@swagger.io Generated by: https://github.com/swagger-api/swagger-codegen.git +Swagger Codegen version: 2.2.3-SNAPSHOT =end From 3df5b6f30373677343564b92c7ead673943b67cd Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 29 May 2017 19:34:04 +0800 Subject: [PATCH 09/10] [Java] Fix float enum value by adding "f" (#5724) * fix java float enum value * update java petstore samples * add comment explaining the fix --- .../languages/AbstractJavaCodegen.java | 5 +- .../gen/io/swagger/client/BuildConfig.java | 8 - .../main/gen/io/swagger/client/Manifest.java | 7 - .../src/main/gen/io/swagger/client/R.java | 7 - .../swagger/client/model/OuterComposite.java | 1 + .../gen/io/swagger/client/BuildConfig.java | 8 - .../main/gen/io/swagger/client/Manifest.java | 7 - .../src/main/gen/io/swagger/client/R.java | 7 - .../swagger/client/model/OuterComposite.java | 1 + .../gen/io/swagger/client/BuildConfig.java | 8 - .../main/gen/io/swagger/client/Manifest.java | 7 - .../src/main/gen/io/swagger/client/R.java | 7 - .../gen/io/swagger/client/BuildConfig.java | 8 - .../main/gen/io/swagger/client/Manifest.java | 7 - .../src/main/gen/io/swagger/client/R.java | 7 - .../java/io/swagger/client/ApiClient.java | 3 +- .../swagger/client/model/OuterComposite.java | 1 + .../gen/io/swagger/client/BuildConfig.java | 8 - .../main/gen/io/swagger/client/Manifest.java | 7 - .../src/main/gen/io/swagger/client/R.java | 7 - .../gen/io/swagger/client/BuildConfig.java | 8 - .../main/gen/io/swagger/client/Manifest.java | 7 - .../src/main/gen/io/swagger/client/R.java | 7 - .../java/io/swagger/client/ApiClient.java | 22 ++- .../swagger/client/model/OuterComposite.java | 2 +- .../petstore/java/resteasy/docs/FakeApi.md | 184 ++++++++++++++++++ .../java/resteasy/docs/OuterComposite.md | 12 ++ .../gen/io/swagger/client/BuildConfig.java | 8 - .../main/gen/io/swagger/client/Manifest.java | 7 - .../src/main/gen/io/swagger/client/R.java | 7 - .../java/io/swagger/client/api/FakeApi.java | 145 ++++++++++++++ .../swagger/client/model/OuterComposite.java | 137 +++++++++++++ .../java/resttemplate/docs/FakeApi.md | 184 ++++++++++++++++++ .../java/resttemplate/docs/OuterComposite.md | 12 ++ .../gen/io/swagger/client/BuildConfig.java | 8 - .../main/gen/io/swagger/client/Manifest.java | 7 - .../src/main/gen/io/swagger/client/R.java | 7 - .../java/io/swagger/client/api/FakeApi.java | 109 +++++++++++ .../swagger/client/model/OuterComposite.java | 137 +++++++++++++ .../gen/io/swagger/client/BuildConfig.java | 8 - .../main/gen/io/swagger/client/Manifest.java | 7 - .../src/main/gen/io/swagger/client/R.java | 7 - .../gen/io/swagger/client/BuildConfig.java | 8 - .../main/gen/io/swagger/client/Manifest.java | 7 - .../src/main/gen/io/swagger/client/R.java | 7 - .../swagger/client/model/OuterComposite.java | 3 + .../gen/io/swagger/client/BuildConfig.java | 8 - .../main/gen/io/swagger/client/Manifest.java | 7 - .../src/main/gen/io/swagger/client/R.java | 7 - .../gen/io/swagger/client/BuildConfig.java | 8 - .../main/gen/io/swagger/client/Manifest.java | 7 - .../src/main/gen/io/swagger/client/R.java | 7 - .../gen/io/swagger/client/BuildConfig.java | 8 - .../main/gen/io/swagger/client/Manifest.java | 7 - .../src/main/gen/io/swagger/client/R.java | 7 - 55 files changed, 954 insertions(+), 290 deletions(-) delete mode 100644 samples/client/petstore/java/feign/src/main/gen/io/swagger/client/BuildConfig.java delete mode 100644 samples/client/petstore/java/feign/src/main/gen/io/swagger/client/Manifest.java delete mode 100644 samples/client/petstore/java/feign/src/main/gen/io/swagger/client/R.java delete mode 100644 samples/client/petstore/java/jersey1/src/main/gen/io/swagger/client/BuildConfig.java delete mode 100644 samples/client/petstore/java/jersey1/src/main/gen/io/swagger/client/Manifest.java delete mode 100644 samples/client/petstore/java/jersey1/src/main/gen/io/swagger/client/R.java delete mode 100644 samples/client/petstore/java/jersey2-java6/src/main/gen/io/swagger/client/BuildConfig.java delete mode 100644 samples/client/petstore/java/jersey2-java6/src/main/gen/io/swagger/client/Manifest.java delete mode 100644 samples/client/petstore/java/jersey2-java6/src/main/gen/io/swagger/client/R.java delete mode 100644 samples/client/petstore/java/jersey2-java8/src/main/gen/io/swagger/client/BuildConfig.java delete mode 100644 samples/client/petstore/java/jersey2-java8/src/main/gen/io/swagger/client/Manifest.java delete mode 100644 samples/client/petstore/java/jersey2-java8/src/main/gen/io/swagger/client/R.java delete mode 100644 samples/client/petstore/java/jersey2/src/main/gen/io/swagger/client/BuildConfig.java delete mode 100644 samples/client/petstore/java/jersey2/src/main/gen/io/swagger/client/Manifest.java delete mode 100644 samples/client/petstore/java/jersey2/src/main/gen/io/swagger/client/R.java delete mode 100644 samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/gen/io/swagger/client/BuildConfig.java delete mode 100644 samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/gen/io/swagger/client/Manifest.java delete mode 100644 samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/gen/io/swagger/client/R.java create mode 100644 samples/client/petstore/java/resteasy/docs/OuterComposite.md delete mode 100644 samples/client/petstore/java/resteasy/src/main/gen/io/swagger/client/BuildConfig.java delete mode 100644 samples/client/petstore/java/resteasy/src/main/gen/io/swagger/client/Manifest.java delete mode 100644 samples/client/petstore/java/resteasy/src/main/gen/io/swagger/client/R.java create mode 100644 samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/model/OuterComposite.java create mode 100644 samples/client/petstore/java/resttemplate/docs/OuterComposite.md delete mode 100644 samples/client/petstore/java/resttemplate/src/main/gen/io/swagger/client/BuildConfig.java delete mode 100644 samples/client/petstore/java/resttemplate/src/main/gen/io/swagger/client/Manifest.java delete mode 100644 samples/client/petstore/java/resttemplate/src/main/gen/io/swagger/client/R.java create mode 100644 samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/model/OuterComposite.java delete mode 100644 samples/client/petstore/java/retrofit/src/main/gen/io/swagger/client/BuildConfig.java delete mode 100644 samples/client/petstore/java/retrofit/src/main/gen/io/swagger/client/Manifest.java delete mode 100644 samples/client/petstore/java/retrofit/src/main/gen/io/swagger/client/R.java delete mode 100644 samples/client/petstore/java/retrofit2-play24/src/main/gen/io/swagger/client/BuildConfig.java delete mode 100644 samples/client/petstore/java/retrofit2-play24/src/main/gen/io/swagger/client/Manifest.java delete mode 100644 samples/client/petstore/java/retrofit2-play24/src/main/gen/io/swagger/client/R.java delete mode 100644 samples/client/petstore/java/retrofit2/src/main/gen/io/swagger/client/BuildConfig.java delete mode 100644 samples/client/petstore/java/retrofit2/src/main/gen/io/swagger/client/Manifest.java delete mode 100644 samples/client/petstore/java/retrofit2/src/main/gen/io/swagger/client/R.java delete mode 100644 samples/client/petstore/java/retrofit2rx/src/main/gen/io/swagger/client/BuildConfig.java delete mode 100644 samples/client/petstore/java/retrofit2rx/src/main/gen/io/swagger/client/Manifest.java delete mode 100644 samples/client/petstore/java/retrofit2rx/src/main/gen/io/swagger/client/R.java delete mode 100644 samples/client/petstore/java/retrofit2rx2/src/main/gen/io/swagger/client/BuildConfig.java delete mode 100644 samples/client/petstore/java/retrofit2rx2/src/main/gen/io/swagger/client/Manifest.java delete mode 100644 samples/client/petstore/java/retrofit2rx2/src/main/gen/io/swagger/client/R.java diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaCodegen.java index c3d8d2e4a57..4ec6bf31202 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaCodegen.java @@ -952,8 +952,11 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code @Override public String toEnumValue(String value, String datatype) { if ("Integer".equals(datatype) || "Long".equals(datatype) || - "Float".equals(datatype) || "Double".equals(datatype)) { + "Double".equals(datatype)) { return value; + } else if ("Float".equals(datatype)) { + // add f to number, e.g. 3.14 => 3.14f + return value + "f"; } else { return "\"" + escapeText(value) + "\""; } diff --git a/samples/client/petstore/java/feign/src/main/gen/io/swagger/client/BuildConfig.java b/samples/client/petstore/java/feign/src/main/gen/io/swagger/client/BuildConfig.java deleted file mode 100644 index 720765940d3..00000000000 --- a/samples/client/petstore/java/feign/src/main/gen/io/swagger/client/BuildConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */ -public final class BuildConfig { - public final static boolean DEBUG = Boolean.parseBoolean(null); -} \ No newline at end of file diff --git a/samples/client/petstore/java/feign/src/main/gen/io/swagger/client/Manifest.java b/samples/client/petstore/java/feign/src/main/gen/io/swagger/client/Manifest.java deleted file mode 100644 index 41e0523a208..00000000000 --- a/samples/client/petstore/java/feign/src/main/gen/io/swagger/client/Manifest.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */ -public final class Manifest { -} \ No newline at end of file diff --git a/samples/client/petstore/java/feign/src/main/gen/io/swagger/client/R.java b/samples/client/petstore/java/feign/src/main/gen/io/swagger/client/R.java deleted file mode 100644 index cd0683364d5..00000000000 --- a/samples/client/petstore/java/feign/src/main/gen/io/swagger/client/R.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */ -public final class R { -} \ No newline at end of file diff --git a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/OuterComposite.java b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/OuterComposite.java index 65d370c72f2..7b1786ea96d 100644 --- a/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/OuterComposite.java +++ b/samples/client/petstore/java/feign/src/main/java/io/swagger/client/model/OuterComposite.java @@ -16,6 +16,7 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; diff --git a/samples/client/petstore/java/jersey1/src/main/gen/io/swagger/client/BuildConfig.java b/samples/client/petstore/java/jersey1/src/main/gen/io/swagger/client/BuildConfig.java deleted file mode 100644 index 720765940d3..00000000000 --- a/samples/client/petstore/java/jersey1/src/main/gen/io/swagger/client/BuildConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */ -public final class BuildConfig { - public final static boolean DEBUG = Boolean.parseBoolean(null); -} \ No newline at end of file diff --git a/samples/client/petstore/java/jersey1/src/main/gen/io/swagger/client/Manifest.java b/samples/client/petstore/java/jersey1/src/main/gen/io/swagger/client/Manifest.java deleted file mode 100644 index 41e0523a208..00000000000 --- a/samples/client/petstore/java/jersey1/src/main/gen/io/swagger/client/Manifest.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */ -public final class Manifest { -} \ No newline at end of file diff --git a/samples/client/petstore/java/jersey1/src/main/gen/io/swagger/client/R.java b/samples/client/petstore/java/jersey1/src/main/gen/io/swagger/client/R.java deleted file mode 100644 index cd0683364d5..00000000000 --- a/samples/client/petstore/java/jersey1/src/main/gen/io/swagger/client/R.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */ -public final class R { -} \ No newline at end of file diff --git a/samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/model/OuterComposite.java b/samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/model/OuterComposite.java index 65d370c72f2..7b1786ea96d 100644 --- a/samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/model/OuterComposite.java +++ b/samples/client/petstore/java/jersey1/src/main/java/io/swagger/client/model/OuterComposite.java @@ -16,6 +16,7 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; diff --git a/samples/client/petstore/java/jersey2-java6/src/main/gen/io/swagger/client/BuildConfig.java b/samples/client/petstore/java/jersey2-java6/src/main/gen/io/swagger/client/BuildConfig.java deleted file mode 100644 index 720765940d3..00000000000 --- a/samples/client/petstore/java/jersey2-java6/src/main/gen/io/swagger/client/BuildConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */ -public final class BuildConfig { - public final static boolean DEBUG = Boolean.parseBoolean(null); -} \ No newline at end of file diff --git a/samples/client/petstore/java/jersey2-java6/src/main/gen/io/swagger/client/Manifest.java b/samples/client/petstore/java/jersey2-java6/src/main/gen/io/swagger/client/Manifest.java deleted file mode 100644 index 41e0523a208..00000000000 --- a/samples/client/petstore/java/jersey2-java6/src/main/gen/io/swagger/client/Manifest.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */ -public final class Manifest { -} \ No newline at end of file diff --git a/samples/client/petstore/java/jersey2-java6/src/main/gen/io/swagger/client/R.java b/samples/client/petstore/java/jersey2-java6/src/main/gen/io/swagger/client/R.java deleted file mode 100644 index cd0683364d5..00000000000 --- a/samples/client/petstore/java/jersey2-java6/src/main/gen/io/swagger/client/R.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */ -public final class R { -} \ No newline at end of file diff --git a/samples/client/petstore/java/jersey2-java8/src/main/gen/io/swagger/client/BuildConfig.java b/samples/client/petstore/java/jersey2-java8/src/main/gen/io/swagger/client/BuildConfig.java deleted file mode 100644 index 720765940d3..00000000000 --- a/samples/client/petstore/java/jersey2-java8/src/main/gen/io/swagger/client/BuildConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */ -public final class BuildConfig { - public final static boolean DEBUG = Boolean.parseBoolean(null); -} \ No newline at end of file diff --git a/samples/client/petstore/java/jersey2-java8/src/main/gen/io/swagger/client/Manifest.java b/samples/client/petstore/java/jersey2-java8/src/main/gen/io/swagger/client/Manifest.java deleted file mode 100644 index 41e0523a208..00000000000 --- a/samples/client/petstore/java/jersey2-java8/src/main/gen/io/swagger/client/Manifest.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */ -public final class Manifest { -} \ No newline at end of file diff --git a/samples/client/petstore/java/jersey2-java8/src/main/gen/io/swagger/client/R.java b/samples/client/petstore/java/jersey2-java8/src/main/gen/io/swagger/client/R.java deleted file mode 100644 index cd0683364d5..00000000000 --- a/samples/client/petstore/java/jersey2-java8/src/main/gen/io/swagger/client/R.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */ -public final class R { -} \ No newline at end of file diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/ApiClient.java index 2878363c980..d3e9924e8eb 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/ApiClient.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; +import java.nio.file.StandardCopyOption; import java.util.Collection; import java.util.Collections; import java.util.Map; @@ -575,7 +576,7 @@ public class ApiClient { public File downloadFileFromResponse(Response response) throws ApiException { try { File file = prepareDownloadFile(response); - Files.copy(response.readEntity(InputStream.class), file.toPath()); + Files.copy(response.readEntity(InputStream.class), file.toPath(), StandardCopyOption.REPLACE_EXISTING); return file; } catch (IOException e) { throw new ApiException(e); diff --git a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/OuterComposite.java b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/OuterComposite.java index 65d370c72f2..7b1786ea96d 100644 --- a/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/OuterComposite.java +++ b/samples/client/petstore/java/jersey2-java8/src/main/java/io/swagger/client/model/OuterComposite.java @@ -16,6 +16,7 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; diff --git a/samples/client/petstore/java/jersey2/src/main/gen/io/swagger/client/BuildConfig.java b/samples/client/petstore/java/jersey2/src/main/gen/io/swagger/client/BuildConfig.java deleted file mode 100644 index 720765940d3..00000000000 --- a/samples/client/petstore/java/jersey2/src/main/gen/io/swagger/client/BuildConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */ -public final class BuildConfig { - public final static boolean DEBUG = Boolean.parseBoolean(null); -} \ No newline at end of file diff --git a/samples/client/petstore/java/jersey2/src/main/gen/io/swagger/client/Manifest.java b/samples/client/petstore/java/jersey2/src/main/gen/io/swagger/client/Manifest.java deleted file mode 100644 index 41e0523a208..00000000000 --- a/samples/client/petstore/java/jersey2/src/main/gen/io/swagger/client/Manifest.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */ -public final class Manifest { -} \ No newline at end of file diff --git a/samples/client/petstore/java/jersey2/src/main/gen/io/swagger/client/R.java b/samples/client/petstore/java/jersey2/src/main/gen/io/swagger/client/R.java deleted file mode 100644 index cd0683364d5..00000000000 --- a/samples/client/petstore/java/jersey2/src/main/gen/io/swagger/client/R.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */ -public final class R { -} \ No newline at end of file diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/gen/io/swagger/client/BuildConfig.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/gen/io/swagger/client/BuildConfig.java deleted file mode 100644 index 720765940d3..00000000000 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/gen/io/swagger/client/BuildConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */ -public final class BuildConfig { - public final static boolean DEBUG = Boolean.parseBoolean(null); -} \ No newline at end of file diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/gen/io/swagger/client/Manifest.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/gen/io/swagger/client/Manifest.java deleted file mode 100644 index 41e0523a208..00000000000 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/gen/io/swagger/client/Manifest.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */ -public final class Manifest { -} \ No newline at end of file diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/gen/io/swagger/client/R.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/gen/io/swagger/client/R.java deleted file mode 100644 index cd0683364d5..00000000000 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/gen/io/swagger/client/R.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */ -public final class R { -} \ No newline at end of file diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/ApiClient.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/ApiClient.java index e3dd992294d..7af43d0eafc 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/ApiClient.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/ApiClient.java @@ -1092,6 +1092,26 @@ public class ApiClient { * @throws ApiException If fail to serialize the request body object */ public Call buildCall(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { + Request request = buildRequest(path, method, queryParams, body, headerParams, formParams, authNames, progressRequestListener); + + return httpClient.newCall(request); + } + + /** + * Build an HTTP request with the given options. + * + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and "DELETE" + * @param queryParams The query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param progressRequestListener Progress request listener + * @return The HTTP request + * @throws ApiException If fail to serialize the request body object + */ + public Request buildRequest(String path, String method, List queryParams, Object body, Map headerParams, Map formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException { updateParamsForAuth(authNames, queryParams, headerParams); final String url = buildUrl(path, queryParams); @@ -1132,7 +1152,7 @@ public class ApiClient { request = reqBuilder.method(method, reqBody).build(); } - return httpClient.newCall(request); + return request; } /** diff --git a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/model/OuterComposite.java b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/model/OuterComposite.java index 109b7793d31..7bf953b41d6 100644 --- a/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/model/OuterComposite.java +++ b/samples/client/petstore/java/okhttp-gson-parcelableModel/src/main/java/io/swagger/client/model/OuterComposite.java @@ -148,7 +148,7 @@ public class OuterComposite implements Parcelable { OuterComposite(Parcel in) { - myNumber = (BigDecimal)in.readValue(null); + myNumber = (BigDecimal)in.readValue(BigDecimal.class.getClassLoader()); myString = (String)in.readValue(null); myBoolean = (Boolean)in.readValue(null); } diff --git a/samples/client/petstore/java/resteasy/docs/FakeApi.md b/samples/client/petstore/java/resteasy/docs/FakeApi.md index f4a6d1c0eb3..5219c541159 100644 --- a/samples/client/petstore/java/resteasy/docs/FakeApi.md +++ b/samples/client/petstore/java/resteasy/docs/FakeApi.md @@ -4,11 +4,195 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Method | HTTP request | Description ------------- | ------------- | ------------- +[**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | +[**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | +[**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | +[**fakeOuterStringSerialize**](FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string | [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters + +# **fakeOuterBooleanSerialize** +> Boolean fakeOuterBooleanSerialize(body) + + + +Test serialization of outer boolean types + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +Boolean body = true; // Boolean | Input boolean as post body +try { + Boolean result = apiInstance.fakeOuterBooleanSerialize(body); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#fakeOuterBooleanSerialize"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Boolean**](Boolean.md)| Input boolean as post body | [optional] + +### Return type + +**Boolean** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +# **fakeOuterCompositeSerialize** +> OuterComposite fakeOuterCompositeSerialize(body) + + + +Test serialization of object with outer number type + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +OuterComposite body = new OuterComposite(); // OuterComposite | Input composite as post body +try { + OuterComposite result = apiInstance.fakeOuterCompositeSerialize(body); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#fakeOuterCompositeSerialize"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**OuterComposite**](OuterComposite.md)| Input composite as post body | [optional] + +### Return type + +[**OuterComposite**](OuterComposite.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +# **fakeOuterNumberSerialize** +> BigDecimal fakeOuterNumberSerialize(body) + + + +Test serialization of outer number types + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +BigDecimal body = new BigDecimal(); // BigDecimal | Input number as post body +try { + BigDecimal result = apiInstance.fakeOuterNumberSerialize(body); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#fakeOuterNumberSerialize"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**BigDecimal**](BigDecimal.md)| Input number as post body | [optional] + +### Return type + +[**BigDecimal**](BigDecimal.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +# **fakeOuterStringSerialize** +> String fakeOuterStringSerialize(body) + + + +Test serialization of outer string types + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +String body = "body_example"; // String | Input string as post body +try { + String result = apiInstance.fakeOuterStringSerialize(body); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#fakeOuterStringSerialize"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**String**](String.md)| Input string as post body | [optional] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + # **testClientModel** > Client testClientModel(body) diff --git a/samples/client/petstore/java/resteasy/docs/OuterComposite.md b/samples/client/petstore/java/resteasy/docs/OuterComposite.md new file mode 100644 index 00000000000..3f5a633c998 --- /dev/null +++ b/samples/client/petstore/java/resteasy/docs/OuterComposite.md @@ -0,0 +1,12 @@ + +# OuterComposite + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**myNumber** | [**BigDecimal**](BigDecimal.md) | | [optional] +**myString** | **String** | | [optional] +**myBoolean** | **Boolean** | | [optional] + + + diff --git a/samples/client/petstore/java/resteasy/src/main/gen/io/swagger/client/BuildConfig.java b/samples/client/petstore/java/resteasy/src/main/gen/io/swagger/client/BuildConfig.java deleted file mode 100644 index 720765940d3..00000000000 --- a/samples/client/petstore/java/resteasy/src/main/gen/io/swagger/client/BuildConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */ -public final class BuildConfig { - public final static boolean DEBUG = Boolean.parseBoolean(null); -} \ No newline at end of file diff --git a/samples/client/petstore/java/resteasy/src/main/gen/io/swagger/client/Manifest.java b/samples/client/petstore/java/resteasy/src/main/gen/io/swagger/client/Manifest.java deleted file mode 100644 index 41e0523a208..00000000000 --- a/samples/client/petstore/java/resteasy/src/main/gen/io/swagger/client/Manifest.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */ -public final class Manifest { -} \ No newline at end of file diff --git a/samples/client/petstore/java/resteasy/src/main/gen/io/swagger/client/R.java b/samples/client/petstore/java/resteasy/src/main/gen/io/swagger/client/R.java deleted file mode 100644 index cd0683364d5..00000000000 --- a/samples/client/petstore/java/resteasy/src/main/gen/io/swagger/client/R.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */ -public final class R { -} \ No newline at end of file diff --git a/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/api/FakeApi.java index 1bc9d46a7b6..d38b8980fb2 100644 --- a/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/api/FakeApi.java @@ -11,6 +11,7 @@ import java.math.BigDecimal; import io.swagger.client.model.Client; import org.joda.time.DateTime; import org.joda.time.LocalDate; +import io.swagger.client.model.OuterComposite; import java.util.ArrayList; import java.util.HashMap; @@ -37,6 +38,150 @@ public class FakeApi { this.apiClient = apiClient; } + /** + * + * Test serialization of outer boolean types + * @param body Input boolean as post body (optional) + * @return Boolean + * @throws ApiException if fails to make API call + */ + public Boolean fakeOuterBooleanSerialize(Boolean body) throws ApiException { + Object localVarPostBody = body; + + // create path and map variables + String localVarPath = "/fake/outer/boolean".replaceAll("\\{format\\}","json"); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + final String[] localVarAccepts = { + + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + /** + * + * Test serialization of object with outer number type + * @param body Input composite as post body (optional) + * @return OuterComposite + * @throws ApiException if fails to make API call + */ + public OuterComposite fakeOuterCompositeSerialize(OuterComposite body) throws ApiException { + Object localVarPostBody = body; + + // create path and map variables + String localVarPath = "/fake/outer/composite".replaceAll("\\{format\\}","json"); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + final String[] localVarAccepts = { + + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + /** + * + * Test serialization of outer number types + * @param body Input number as post body (optional) + * @return BigDecimal + * @throws ApiException if fails to make API call + */ + public BigDecimal fakeOuterNumberSerialize(BigDecimal body) throws ApiException { + Object localVarPostBody = body; + + // create path and map variables + String localVarPath = "/fake/outer/number".replaceAll("\\{format\\}","json"); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + final String[] localVarAccepts = { + + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } + /** + * + * Test serialization of outer string types + * @param body Input string as post body (optional) + * @return String + * @throws ApiException if fails to make API call + */ + public String fakeOuterStringSerialize(String body) throws ApiException { + Object localVarPostBody = body; + + // create path and map variables + String localVarPath = "/fake/outer/string".replaceAll("\\{format\\}","json"); + + // query params + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + + + + final String[] localVarAccepts = { + + }; + final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts); + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); + + String[] localVarAuthNames = new String[] { }; + + GenericType localVarReturnType = new GenericType() {}; + return apiClient.invokeAPI(localVarPath, "POST", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAccept, localVarContentType, localVarAuthNames, localVarReturnType); + } /** * To test \"client\" model * To test \"client\" model diff --git a/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/model/OuterComposite.java b/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/model/OuterComposite.java new file mode 100644 index 00000000000..7b1786ea96d --- /dev/null +++ b/samples/client/petstore/java/resteasy/src/main/java/io/swagger/client/model/OuterComposite.java @@ -0,0 +1,137 @@ +/* + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.math.BigDecimal; + +/** + * OuterComposite + */ + +public class OuterComposite { + @JsonProperty("my_number") + private BigDecimal myNumber = null; + + @JsonProperty("my_string") + private String myString = null; + + @JsonProperty("my_boolean") + private Boolean myBoolean = null; + + public OuterComposite myNumber(BigDecimal myNumber) { + this.myNumber = myNumber; + return this; + } + + /** + * Get myNumber + * @return myNumber + **/ + @ApiModelProperty(value = "") + public BigDecimal getMyNumber() { + return myNumber; + } + + public void setMyNumber(BigDecimal myNumber) { + this.myNumber = myNumber; + } + + public OuterComposite myString(String myString) { + this.myString = myString; + return this; + } + + /** + * Get myString + * @return myString + **/ + @ApiModelProperty(value = "") + public String getMyString() { + return myString; + } + + public void setMyString(String myString) { + this.myString = myString; + } + + public OuterComposite myBoolean(Boolean myBoolean) { + this.myBoolean = myBoolean; + return this; + } + + /** + * Get myBoolean + * @return myBoolean + **/ + @ApiModelProperty(value = "") + public Boolean getMyBoolean() { + return myBoolean; + } + + public void setMyBoolean(Boolean myBoolean) { + this.myBoolean = myBoolean; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OuterComposite outerComposite = (OuterComposite) o; + return Objects.equals(this.myNumber, outerComposite.myNumber) && + Objects.equals(this.myString, outerComposite.myString) && + Objects.equals(this.myBoolean, outerComposite.myBoolean); + } + + @Override + public int hashCode() { + return Objects.hash(myNumber, myString, myBoolean); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OuterComposite {\n"); + + sb.append(" myNumber: ").append(toIndentedString(myNumber)).append("\n"); + sb.append(" myString: ").append(toIndentedString(myString)).append("\n"); + sb.append(" myBoolean: ").append(toIndentedString(myBoolean)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/resttemplate/docs/FakeApi.md b/samples/client/petstore/java/resttemplate/docs/FakeApi.md index f4a6d1c0eb3..5219c541159 100644 --- a/samples/client/petstore/java/resttemplate/docs/FakeApi.md +++ b/samples/client/petstore/java/resttemplate/docs/FakeApi.md @@ -4,11 +4,195 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Method | HTTP request | Description ------------- | ------------- | ------------- +[**fakeOuterBooleanSerialize**](FakeApi.md#fakeOuterBooleanSerialize) | **POST** /fake/outer/boolean | +[**fakeOuterCompositeSerialize**](FakeApi.md#fakeOuterCompositeSerialize) | **POST** /fake/outer/composite | +[**fakeOuterNumberSerialize**](FakeApi.md#fakeOuterNumberSerialize) | **POST** /fake/outer/number | +[**fakeOuterStringSerialize**](FakeApi.md#fakeOuterStringSerialize) | **POST** /fake/outer/string | [**testClientModel**](FakeApi.md#testClientModel) | **PATCH** /fake | To test \"client\" model [**testEndpointParameters**](FakeApi.md#testEndpointParameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**testEnumParameters**](FakeApi.md#testEnumParameters) | **GET** /fake | To test enum parameters + +# **fakeOuterBooleanSerialize** +> Boolean fakeOuterBooleanSerialize(body) + + + +Test serialization of outer boolean types + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +Boolean body = true; // Boolean | Input boolean as post body +try { + Boolean result = apiInstance.fakeOuterBooleanSerialize(body); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#fakeOuterBooleanSerialize"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Boolean**](Boolean.md)| Input boolean as post body | [optional] + +### Return type + +**Boolean** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +# **fakeOuterCompositeSerialize** +> OuterComposite fakeOuterCompositeSerialize(body) + + + +Test serialization of object with outer number type + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +OuterComposite body = new OuterComposite(); // OuterComposite | Input composite as post body +try { + OuterComposite result = apiInstance.fakeOuterCompositeSerialize(body); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#fakeOuterCompositeSerialize"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**OuterComposite**](OuterComposite.md)| Input composite as post body | [optional] + +### Return type + +[**OuterComposite**](OuterComposite.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +# **fakeOuterNumberSerialize** +> BigDecimal fakeOuterNumberSerialize(body) + + + +Test serialization of outer number types + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +BigDecimal body = new BigDecimal(); // BigDecimal | Input number as post body +try { + BigDecimal result = apiInstance.fakeOuterNumberSerialize(body); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#fakeOuterNumberSerialize"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**BigDecimal**](BigDecimal.md)| Input number as post body | [optional] + +### Return type + +[**BigDecimal**](BigDecimal.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + + +# **fakeOuterStringSerialize** +> String fakeOuterStringSerialize(body) + + + +Test serialization of outer string types + +### Example +```java +// Import classes: +//import io.swagger.client.ApiException; +//import io.swagger.client.api.FakeApi; + + +FakeApi apiInstance = new FakeApi(); +String body = "body_example"; // String | Input string as post body +try { + String result = apiInstance.fakeOuterStringSerialize(body); + System.out.println(result); +} catch (ApiException e) { + System.err.println("Exception when calling FakeApi#fakeOuterStringSerialize"); + e.printStackTrace(); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**String**](String.md)| Input string as post body | [optional] + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + # **testClientModel** > Client testClientModel(body) diff --git a/samples/client/petstore/java/resttemplate/docs/OuterComposite.md b/samples/client/petstore/java/resttemplate/docs/OuterComposite.md new file mode 100644 index 00000000000..3f5a633c998 --- /dev/null +++ b/samples/client/petstore/java/resttemplate/docs/OuterComposite.md @@ -0,0 +1,12 @@ + +# OuterComposite + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**myNumber** | [**BigDecimal**](BigDecimal.md) | | [optional] +**myString** | **String** | | [optional] +**myBoolean** | **Boolean** | | [optional] + + + diff --git a/samples/client/petstore/java/resttemplate/src/main/gen/io/swagger/client/BuildConfig.java b/samples/client/petstore/java/resttemplate/src/main/gen/io/swagger/client/BuildConfig.java deleted file mode 100644 index 720765940d3..00000000000 --- a/samples/client/petstore/java/resttemplate/src/main/gen/io/swagger/client/BuildConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */ -public final class BuildConfig { - public final static boolean DEBUG = Boolean.parseBoolean(null); -} \ No newline at end of file diff --git a/samples/client/petstore/java/resttemplate/src/main/gen/io/swagger/client/Manifest.java b/samples/client/petstore/java/resttemplate/src/main/gen/io/swagger/client/Manifest.java deleted file mode 100644 index 41e0523a208..00000000000 --- a/samples/client/petstore/java/resttemplate/src/main/gen/io/swagger/client/Manifest.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */ -public final class Manifest { -} \ No newline at end of file diff --git a/samples/client/petstore/java/resttemplate/src/main/gen/io/swagger/client/R.java b/samples/client/petstore/java/resttemplate/src/main/gen/io/swagger/client/R.java deleted file mode 100644 index cd0683364d5..00000000000 --- a/samples/client/petstore/java/resttemplate/src/main/gen/io/swagger/client/R.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */ -public final class R { -} \ No newline at end of file diff --git a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeApi.java b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeApi.java index add04d01dee..8461c663e4f 100644 --- a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeApi.java +++ b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/api/FakeApi.java @@ -6,6 +6,7 @@ import java.math.BigDecimal; import io.swagger.client.model.Client; import org.joda.time.DateTime; import org.joda.time.LocalDate; +import io.swagger.client.model.OuterComposite; import java.util.ArrayList; import java.util.HashMap; @@ -48,6 +49,114 @@ public class FakeApi { this.apiClient = apiClient; } + /** + * + * Test serialization of outer boolean types + *

200 - Output boolean + * @param body Input boolean as post body + * @return Boolean + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public Boolean fakeOuterBooleanSerialize(Boolean body) throws RestClientException { + Object postBody = body; + + String path = UriComponentsBuilder.fromPath("/fake/outer/boolean").build().toUriString(); + + final MultiValueMap queryParams = new LinkedMultiValueMap(); + final HttpHeaders headerParams = new HttpHeaders(); + final MultiValueMap formParams = new LinkedMultiValueMap(); + + final String[] accepts = { }; + final List accept = apiClient.selectHeaderAccept(accepts); + final String[] contentTypes = { }; + final MediaType contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; + return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + } + /** + * + * Test serialization of object with outer number type + *

200 - Output composite + * @param body Input composite as post body + * @return OuterComposite + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public OuterComposite fakeOuterCompositeSerialize(OuterComposite body) throws RestClientException { + Object postBody = body; + + String path = UriComponentsBuilder.fromPath("/fake/outer/composite").build().toUriString(); + + final MultiValueMap queryParams = new LinkedMultiValueMap(); + final HttpHeaders headerParams = new HttpHeaders(); + final MultiValueMap formParams = new LinkedMultiValueMap(); + + final String[] accepts = { }; + final List accept = apiClient.selectHeaderAccept(accepts); + final String[] contentTypes = { }; + final MediaType contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; + return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + } + /** + * + * Test serialization of outer number types + *

200 - Output number + * @param body Input number as post body + * @return BigDecimal + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public BigDecimal fakeOuterNumberSerialize(BigDecimal body) throws RestClientException { + Object postBody = body; + + String path = UriComponentsBuilder.fromPath("/fake/outer/number").build().toUriString(); + + final MultiValueMap queryParams = new LinkedMultiValueMap(); + final HttpHeaders headerParams = new HttpHeaders(); + final MultiValueMap formParams = new LinkedMultiValueMap(); + + final String[] accepts = { }; + final List accept = apiClient.selectHeaderAccept(accepts); + final String[] contentTypes = { }; + final MediaType contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; + return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + } + /** + * + * Test serialization of outer string types + *

200 - Output string + * @param body Input string as post body + * @return String + * @throws RestClientException if an error occurs while attempting to invoke the API + */ + public String fakeOuterStringSerialize(String body) throws RestClientException { + Object postBody = body; + + String path = UriComponentsBuilder.fromPath("/fake/outer/string").build().toUriString(); + + final MultiValueMap queryParams = new LinkedMultiValueMap(); + final HttpHeaders headerParams = new HttpHeaders(); + final MultiValueMap formParams = new LinkedMultiValueMap(); + + final String[] accepts = { }; + final List accept = apiClient.selectHeaderAccept(accepts); + final String[] contentTypes = { }; + final MediaType contentType = apiClient.selectHeaderContentType(contentTypes); + + String[] authNames = new String[] { }; + + ParameterizedTypeReference returnType = new ParameterizedTypeReference() {}; + return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType); + } /** * To test \"client\" model * To test \"client\" model diff --git a/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/model/OuterComposite.java b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/model/OuterComposite.java new file mode 100644 index 00000000000..7b1786ea96d --- /dev/null +++ b/samples/client/petstore/java/resttemplate/src/main/java/io/swagger/client/model/OuterComposite.java @@ -0,0 +1,137 @@ +/* + * Swagger Petstore + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ + + +package io.swagger.client.model; + +import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.math.BigDecimal; + +/** + * OuterComposite + */ + +public class OuterComposite { + @JsonProperty("my_number") + private BigDecimal myNumber = null; + + @JsonProperty("my_string") + private String myString = null; + + @JsonProperty("my_boolean") + private Boolean myBoolean = null; + + public OuterComposite myNumber(BigDecimal myNumber) { + this.myNumber = myNumber; + return this; + } + + /** + * Get myNumber + * @return myNumber + **/ + @ApiModelProperty(value = "") + public BigDecimal getMyNumber() { + return myNumber; + } + + public void setMyNumber(BigDecimal myNumber) { + this.myNumber = myNumber; + } + + public OuterComposite myString(String myString) { + this.myString = myString; + return this; + } + + /** + * Get myString + * @return myString + **/ + @ApiModelProperty(value = "") + public String getMyString() { + return myString; + } + + public void setMyString(String myString) { + this.myString = myString; + } + + public OuterComposite myBoolean(Boolean myBoolean) { + this.myBoolean = myBoolean; + return this; + } + + /** + * Get myBoolean + * @return myBoolean + **/ + @ApiModelProperty(value = "") + public Boolean getMyBoolean() { + return myBoolean; + } + + public void setMyBoolean(Boolean myBoolean) { + this.myBoolean = myBoolean; + } + + + @Override + public boolean equals(java.lang.Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OuterComposite outerComposite = (OuterComposite) o; + return Objects.equals(this.myNumber, outerComposite.myNumber) && + Objects.equals(this.myString, outerComposite.myString) && + Objects.equals(this.myBoolean, outerComposite.myBoolean); + } + + @Override + public int hashCode() { + return Objects.hash(myNumber, myString, myBoolean); + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OuterComposite {\n"); + + sb.append(" myNumber: ").append(toIndentedString(myNumber)).append("\n"); + sb.append(" myString: ").append(toIndentedString(myString)).append("\n"); + sb.append(" myBoolean: ").append(toIndentedString(myBoolean)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/samples/client/petstore/java/retrofit/src/main/gen/io/swagger/client/BuildConfig.java b/samples/client/petstore/java/retrofit/src/main/gen/io/swagger/client/BuildConfig.java deleted file mode 100644 index 720765940d3..00000000000 --- a/samples/client/petstore/java/retrofit/src/main/gen/io/swagger/client/BuildConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */ -public final class BuildConfig { - public final static boolean DEBUG = Boolean.parseBoolean(null); -} \ No newline at end of file diff --git a/samples/client/petstore/java/retrofit/src/main/gen/io/swagger/client/Manifest.java b/samples/client/petstore/java/retrofit/src/main/gen/io/swagger/client/Manifest.java deleted file mode 100644 index 41e0523a208..00000000000 --- a/samples/client/petstore/java/retrofit/src/main/gen/io/swagger/client/Manifest.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */ -public final class Manifest { -} \ No newline at end of file diff --git a/samples/client/petstore/java/retrofit/src/main/gen/io/swagger/client/R.java b/samples/client/petstore/java/retrofit/src/main/gen/io/swagger/client/R.java deleted file mode 100644 index cd0683364d5..00000000000 --- a/samples/client/petstore/java/retrofit/src/main/gen/io/swagger/client/R.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */ -public final class R { -} \ No newline at end of file diff --git a/samples/client/petstore/java/retrofit2-play24/src/main/gen/io/swagger/client/BuildConfig.java b/samples/client/petstore/java/retrofit2-play24/src/main/gen/io/swagger/client/BuildConfig.java deleted file mode 100644 index 720765940d3..00000000000 --- a/samples/client/petstore/java/retrofit2-play24/src/main/gen/io/swagger/client/BuildConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */ -public final class BuildConfig { - public final static boolean DEBUG = Boolean.parseBoolean(null); -} \ No newline at end of file diff --git a/samples/client/petstore/java/retrofit2-play24/src/main/gen/io/swagger/client/Manifest.java b/samples/client/petstore/java/retrofit2-play24/src/main/gen/io/swagger/client/Manifest.java deleted file mode 100644 index 41e0523a208..00000000000 --- a/samples/client/petstore/java/retrofit2-play24/src/main/gen/io/swagger/client/Manifest.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */ -public final class Manifest { -} \ No newline at end of file diff --git a/samples/client/petstore/java/retrofit2-play24/src/main/gen/io/swagger/client/R.java b/samples/client/petstore/java/retrofit2-play24/src/main/gen/io/swagger/client/R.java deleted file mode 100644 index cd0683364d5..00000000000 --- a/samples/client/petstore/java/retrofit2-play24/src/main/gen/io/swagger/client/R.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */ -public final class R { -} \ No newline at end of file diff --git a/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/OuterComposite.java b/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/OuterComposite.java index 6cb9cb2930e..1fb8683f555 100644 --- a/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/OuterComposite.java +++ b/samples/client/petstore/java/retrofit2-play24/src/main/java/io/swagger/client/model/OuterComposite.java @@ -16,10 +16,12 @@ package io.swagger.client.model; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.math.BigDecimal; import javax.validation.constraints.*; +import javax.validation.Valid; /** * OuterComposite @@ -44,6 +46,7 @@ public class OuterComposite { * Get myNumber * @return myNumber **/ + @Valid @ApiModelProperty(value = "") public BigDecimal getMyNumber() { return myNumber; diff --git a/samples/client/petstore/java/retrofit2/src/main/gen/io/swagger/client/BuildConfig.java b/samples/client/petstore/java/retrofit2/src/main/gen/io/swagger/client/BuildConfig.java deleted file mode 100644 index 720765940d3..00000000000 --- a/samples/client/petstore/java/retrofit2/src/main/gen/io/swagger/client/BuildConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */ -public final class BuildConfig { - public final static boolean DEBUG = Boolean.parseBoolean(null); -} \ No newline at end of file diff --git a/samples/client/petstore/java/retrofit2/src/main/gen/io/swagger/client/Manifest.java b/samples/client/petstore/java/retrofit2/src/main/gen/io/swagger/client/Manifest.java deleted file mode 100644 index 41e0523a208..00000000000 --- a/samples/client/petstore/java/retrofit2/src/main/gen/io/swagger/client/Manifest.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */ -public final class Manifest { -} \ No newline at end of file diff --git a/samples/client/petstore/java/retrofit2/src/main/gen/io/swagger/client/R.java b/samples/client/petstore/java/retrofit2/src/main/gen/io/swagger/client/R.java deleted file mode 100644 index cd0683364d5..00000000000 --- a/samples/client/petstore/java/retrofit2/src/main/gen/io/swagger/client/R.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */ -public final class R { -} \ No newline at end of file diff --git a/samples/client/petstore/java/retrofit2rx/src/main/gen/io/swagger/client/BuildConfig.java b/samples/client/petstore/java/retrofit2rx/src/main/gen/io/swagger/client/BuildConfig.java deleted file mode 100644 index 720765940d3..00000000000 --- a/samples/client/petstore/java/retrofit2rx/src/main/gen/io/swagger/client/BuildConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */ -public final class BuildConfig { - public final static boolean DEBUG = Boolean.parseBoolean(null); -} \ No newline at end of file diff --git a/samples/client/petstore/java/retrofit2rx/src/main/gen/io/swagger/client/Manifest.java b/samples/client/petstore/java/retrofit2rx/src/main/gen/io/swagger/client/Manifest.java deleted file mode 100644 index 41e0523a208..00000000000 --- a/samples/client/petstore/java/retrofit2rx/src/main/gen/io/swagger/client/Manifest.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */ -public final class Manifest { -} \ No newline at end of file diff --git a/samples/client/petstore/java/retrofit2rx/src/main/gen/io/swagger/client/R.java b/samples/client/petstore/java/retrofit2rx/src/main/gen/io/swagger/client/R.java deleted file mode 100644 index cd0683364d5..00000000000 --- a/samples/client/petstore/java/retrofit2rx/src/main/gen/io/swagger/client/R.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */ -public final class R { -} \ No newline at end of file diff --git a/samples/client/petstore/java/retrofit2rx2/src/main/gen/io/swagger/client/BuildConfig.java b/samples/client/petstore/java/retrofit2rx2/src/main/gen/io/swagger/client/BuildConfig.java deleted file mode 100644 index 720765940d3..00000000000 --- a/samples/client/petstore/java/retrofit2rx2/src/main/gen/io/swagger/client/BuildConfig.java +++ /dev/null @@ -1,8 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the BuildConfig class actually packed into the APK */ -public final class BuildConfig { - public final static boolean DEBUG = Boolean.parseBoolean(null); -} \ No newline at end of file diff --git a/samples/client/petstore/java/retrofit2rx2/src/main/gen/io/swagger/client/Manifest.java b/samples/client/petstore/java/retrofit2rx2/src/main/gen/io/swagger/client/Manifest.java deleted file mode 100644 index 41e0523a208..00000000000 --- a/samples/client/petstore/java/retrofit2rx2/src/main/gen/io/swagger/client/Manifest.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the Manifest class actually packed into the APK */ -public final class Manifest { -} \ No newline at end of file diff --git a/samples/client/petstore/java/retrofit2rx2/src/main/gen/io/swagger/client/R.java b/samples/client/petstore/java/retrofit2rx2/src/main/gen/io/swagger/client/R.java deleted file mode 100644 index cd0683364d5..00000000000 --- a/samples/client/petstore/java/retrofit2rx2/src/main/gen/io/swagger/client/R.java +++ /dev/null @@ -1,7 +0,0 @@ -/*___Generated_by_IDEA___*/ - -package io.swagger.client; - -/* This stub is only used by the IDE. It is NOT the R class actually packed into the APK */ -public final class R { -} \ No newline at end of file From b84769d1e37d54ea5fe0c2220678f7f9ab9f05b8 Mon Sep 17 00:00:00 2001 From: wing328 Date: Mon, 29 May 2017 22:16:42 +0800 Subject: [PATCH 10/10] fix enum float value in C#, minor format fix in doc (#5726) --- .../languages/CSharpClientCodegen.java | 3 + .../src/main/resources/csharp/README.mustache | 22 +- .../main/resources/csharp/api_doc.mustache | 18 +- .../petstore/csharp/SwaggerClient/README.md | 3 +- .../csharp/SwaggerClient/docs/FakeApi.md | 7 - .../csharp/SwaggerClient/docs/PetApi.md | 8 - .../csharp/SwaggerClient/docs/StoreApi.md | 4 - .../csharp/SwaggerClient/docs/UserApi.md | 8 - .../csharp/SwaggerClientNetStandard/README.md | 22 +- .../SwaggerClientNetStandard/docs/FakeApi.md | 247 +++++- .../docs/OuterBoolean.md | 8 + .../docs/OuterComposite.md | 11 + .../docs/OuterNumber.md | 8 + .../docs/OuterString.md | 8 + .../SwaggerClientNetStandard/docs/PetApi.md | 8 - .../SwaggerClientNetStandard/docs/StoreApi.md | 4 - .../SwaggerClientNetStandard/docs/UserApi.md | 8 - .../src/IO.Swagger/Api/FakeApi.cs | 724 ++++++++++++++++++ .../src/IO.Swagger/Model/OuterBoolean.cs | 100 +++ .../src/IO.Swagger/Model/OuterComposite.cs | 144 ++++ .../src/IO.Swagger/Model/OuterNumber.cs | 100 +++ .../src/IO.Swagger/Model/OuterString.cs | 100 +++ .../README.md | 7 +- .../docs/FakeApi.md | 7 - .../docs/PetApi.md | 8 - .../docs/StoreApi.md | 4 - .../docs/UserApi.md | 8 - .../IO.Swagger.Test/IO.Swagger.Test.csproj | 3 +- .../src/IO.Swagger/Api/FakeApi.cs | 8 - .../src/IO.Swagger/IO.Swagger.csproj | 6 +- .../src/IO.Swagger/Model/OuterBoolean.cs | 2 +- .../src/IO.Swagger/Model/OuterComposite.cs | 2 +- .../src/IO.Swagger/Model/OuterNumber.cs | 2 +- .../src/IO.Swagger/Model/OuterString.cs | 2 +- 34 files changed, 1508 insertions(+), 116 deletions(-) create mode 100644 samples/client/petstore/csharp/SwaggerClientNetStandard/docs/OuterBoolean.md create mode 100644 samples/client/petstore/csharp/SwaggerClientNetStandard/docs/OuterComposite.md create mode 100644 samples/client/petstore/csharp/SwaggerClientNetStandard/docs/OuterNumber.md create mode 100644 samples/client/petstore/csharp/SwaggerClientNetStandard/docs/OuterString.md create mode 100644 samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Model/OuterBoolean.cs create mode 100644 samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Model/OuterComposite.cs create mode 100644 samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Model/OuterNumber.cs create mode 100644 samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Model/OuterString.cs diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java index ff0ae876a93..dd4b3e9f27c 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java @@ -560,6 +560,9 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen { if ("int?".equalsIgnoreCase(datatype) || "long?".equalsIgnoreCase(datatype) || "double?".equalsIgnoreCase(datatype) || "float?".equalsIgnoreCase(datatype)) { return value; + } else if ("float?".equalsIgnoreCase(datatype)) { + // for float in C#, append "f". e.g. 3.14 => 3.14f + return value + "f"; } else { return "\"" + escapeText(value) + "\""; } diff --git a/modules/swagger-codegen/src/main/resources/csharp/README.mustache b/modules/swagger-codegen/src/main/resources/csharp/README.mustache index e48c6029f70..80e24376947 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/README.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/README.mustache @@ -102,18 +102,27 @@ namespace Example { public void main() { - {{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} +{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} + {{#hasAuthMethods}} + {{#authMethods}} + {{#isBasic}} // Configure HTTP basic authorization: {{{name}}} Configuration.Default.Username = "YOUR_USERNAME"; - Configuration.Default.Password = "YOUR_PASSWORD";{{/isBasic}}{{#isApiKey}} + Configuration.Default.Password = "YOUR_PASSWORD"; + {{/isBasic}} + {{#isApiKey}} // Configure API key authorization: {{{name}}} Configuration.Default.ApiKey.Add("{{{keyParamName}}}", "YOUR_API_KEY"); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed - // Configuration.Default.ApiKeyPrefix.Add("{{{keyParamName}}}", "Bearer");{{/isApiKey}}{{#isOAuth}} + // Configuration.Default.ApiKeyPrefix.Add("{{{keyParamName}}}", "Bearer"); + {{/isApiKey}} + {{#isOAuth}} // Configure OAuth2 access token for authorization: {{{name}}} - Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";{{/isOAuth}}{{/authMethods}} - {{/hasAuthMethods}} + Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; + {{/isOAuth}} + {{/authMethods}} + {{/hasAuthMethods}} var apiInstance = new {{classname}}(); {{#allParams}} {{#isPrimitiveType}} @@ -136,9 +145,10 @@ namespace Example { Debug.Print("Exception when calling {{classname}}.{{operationId}}: " + e.Message ); } +{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} } } -}{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} +} ``` diff --git a/modules/swagger-codegen/src/main/resources/csharp/api_doc.mustache b/modules/swagger-codegen/src/main/resources/csharp/api_doc.mustache index 9ef645bed3f..ff3cf4fc60a 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/api_doc.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/api_doc.mustache @@ -32,18 +32,26 @@ namespace Example { public void main() { - {{#hasAuthMethods}}{{#authMethods}}{{#isBasic}} + {{#hasAuthMethods}} + {{#authMethods}} + {{#isBasic}} // Configure HTTP basic authorization: {{{name}}} Configuration.Default.Username = "YOUR_USERNAME"; - Configuration.Default.Password = "YOUR_PASSWORD";{{/isBasic}}{{#isApiKey}} + Configuration.Default.Password = "YOUR_PASSWORD"; + {{/isBasic}} + {{#isApiKey}} // Configure API key authorization: {{{name}}} Configuration.Default.ApiKey.Add("{{{keyParamName}}}", "YOUR_API_KEY"); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed - // Configuration.Default.ApiKeyPrefix.Add("{{{keyParamName}}}", "Bearer");{{/isApiKey}}{{#isOAuth}} + // Configuration.Default.ApiKeyPrefix.Add("{{{keyParamName}}}", "Bearer"); + {{/isApiKey}} + {{#isOAuth}} // Configure OAuth2 access token for authorization: {{{name}}} - Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";{{/isOAuth}}{{/authMethods}} - {{/hasAuthMethods}} + Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; + {{/isOAuth}} + {{/authMethods}} + {{/hasAuthMethods}} var apiInstance = new {{classname}}(); {{#allParams}} {{#isPrimitiveType}} diff --git a/samples/client/petstore/csharp/SwaggerClient/README.md b/samples/client/petstore/csharp/SwaggerClient/README.md index 576c89fed51..509276df700 100644 --- a/samples/client/petstore/csharp/SwaggerClient/README.md +++ b/samples/client/petstore/csharp/SwaggerClient/README.md @@ -67,7 +67,7 @@ namespace Example { public void main() { - + var apiInstance = new FakeApi(); var body = new OuterBoolean(); // OuterBoolean | Input boolean as post body (optional) @@ -80,6 +80,7 @@ namespace Example { Debug.Print("Exception when calling FakeApi.FakeOuterBooleanSerialize: " + e.Message ); } + } } } diff --git a/samples/client/petstore/csharp/SwaggerClient/docs/FakeApi.md b/samples/client/petstore/csharp/SwaggerClient/docs/FakeApi.md index 1277461eb1d..41bddd87b49 100644 --- a/samples/client/petstore/csharp/SwaggerClient/docs/FakeApi.md +++ b/samples/client/petstore/csharp/SwaggerClient/docs/FakeApi.md @@ -35,7 +35,6 @@ namespace Example { public void main() { - var apiInstance = new FakeApi(); var body = new OuterBoolean(); // OuterBoolean | Input boolean as post body (optional) @@ -96,7 +95,6 @@ namespace Example { public void main() { - var apiInstance = new FakeApi(); var body = new OuterComposite(); // OuterComposite | Input composite as post body (optional) @@ -157,7 +155,6 @@ namespace Example { public void main() { - var apiInstance = new FakeApi(); var body = new OuterNumber(); // OuterNumber | Input number as post body (optional) @@ -218,7 +215,6 @@ namespace Example { public void main() { - var apiInstance = new FakeApi(); var body = new OuterString(); // OuterString | Input string as post body (optional) @@ -279,7 +275,6 @@ namespace Example { public void main() { - var apiInstance = new FakeApi(); var body = new ModelClient(); // ModelClient | client model @@ -341,7 +336,6 @@ namespace Example { public void main() { - // Configure HTTP basic authorization: http_basic_test Configuration.Default.Username = "YOUR_USERNAME"; Configuration.Default.Password = "YOUR_PASSWORD"; @@ -432,7 +426,6 @@ namespace Example { public void main() { - var apiInstance = new FakeApi(); var enumFormStringArray = new List(); // List | Form parameter enum test (string array) (optional) var enumFormString = enumFormString_example; // string | Form parameter enum test (string) (optional) (default to -efg) diff --git a/samples/client/petstore/csharp/SwaggerClient/docs/PetApi.md b/samples/client/petstore/csharp/SwaggerClient/docs/PetApi.md index f3f49f5ed5b..148d49b8b88 100644 --- a/samples/client/petstore/csharp/SwaggerClient/docs/PetApi.md +++ b/samples/client/petstore/csharp/SwaggerClient/docs/PetApi.md @@ -36,7 +36,6 @@ namespace Example { public void main() { - // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; @@ -100,7 +99,6 @@ namespace Example { public void main() { - // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; @@ -166,7 +164,6 @@ namespace Example { public void main() { - // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; @@ -231,7 +228,6 @@ namespace Example { public void main() { - // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; @@ -296,7 +292,6 @@ namespace Example { public void main() { - // Configure API key authorization: api_key Configuration.Default.ApiKey.Add("api_key", "YOUR_API_KEY"); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed @@ -363,7 +358,6 @@ namespace Example { public void main() { - // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; @@ -427,7 +421,6 @@ namespace Example { public void main() { - // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; @@ -495,7 +488,6 @@ namespace Example { public void main() { - // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; diff --git a/samples/client/petstore/csharp/SwaggerClient/docs/StoreApi.md b/samples/client/petstore/csharp/SwaggerClient/docs/StoreApi.md index bf2fdb1ed6d..1509a03158f 100644 --- a/samples/client/petstore/csharp/SwaggerClient/docs/StoreApi.md +++ b/samples/client/petstore/csharp/SwaggerClient/docs/StoreApi.md @@ -32,7 +32,6 @@ namespace Example { public void main() { - var apiInstance = new StoreApi(); var orderId = orderId_example; // string | ID of the order that needs to be deleted @@ -93,7 +92,6 @@ namespace Example { public void main() { - // Configure API key authorization: api_key Configuration.Default.ApiKey.Add("api_key", "YOUR_API_KEY"); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed @@ -156,7 +154,6 @@ namespace Example { public void main() { - var apiInstance = new StoreApi(); var orderId = 789; // long? | ID of pet that needs to be fetched @@ -218,7 +215,6 @@ namespace Example { public void main() { - var apiInstance = new StoreApi(); var body = new Order(); // Order | order placed for purchasing the pet diff --git a/samples/client/petstore/csharp/SwaggerClient/docs/UserApi.md b/samples/client/petstore/csharp/SwaggerClient/docs/UserApi.md index 78553f5b385..0ddde3f669c 100644 --- a/samples/client/petstore/csharp/SwaggerClient/docs/UserApi.md +++ b/samples/client/petstore/csharp/SwaggerClient/docs/UserApi.md @@ -36,7 +36,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); var body = new User(); // User | Created user object @@ -97,7 +96,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); var body = new List(); // List | List of user object @@ -158,7 +156,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); var body = new List(); // List | List of user object @@ -219,7 +216,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); var username = username_example; // string | The name that needs to be deleted @@ -280,7 +276,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); var username = username_example; // string | The name that needs to be fetched. Use user1 for testing. @@ -342,7 +337,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); var username = username_example; // string | The user name for login var password = password_example; // string | The password for login in clear text @@ -406,7 +400,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); try @@ -463,7 +456,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); var username = username_example; // string | name that need to be deleted var body = new User(); // User | Updated user object diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/README.md b/samples/client/petstore/csharp/SwaggerClientNetStandard/README.md index d56551bfcbc..3af054e72a1 100644 --- a/samples/client/petstore/csharp/SwaggerClientNetStandard/README.md +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/README.md @@ -47,20 +47,20 @@ namespace Example { public void main() { - + var apiInstance = new FakeApi(); - var body = new ModelClient(); // ModelClient | client model + var body = new OuterBoolean(); // OuterBoolean | Input boolean as post body (optional) try { - // To test \"client\" model - ModelClient result = apiInstance.TestClientModel(body); + OuterBoolean result = apiInstance.FakeOuterBooleanSerialize(body); Debug.WriteLine(result); } catch (Exception e) { - Debug.Print("Exception when calling FakeApi.TestClientModel: " + e.Message ); + Debug.Print("Exception when calling FakeApi.FakeOuterBooleanSerialize: " + e.Message ); } + } } } @@ -73,6 +73,10 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- +*FakeApi* | [**FakeOuterBooleanSerialize**](docs/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean | +*FakeApi* | [**FakeOuterCompositeSerialize**](docs/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite | +*FakeApi* | [**FakeOuterNumberSerialize**](docs/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | +*FakeApi* | [**FakeOuterStringSerialize**](docs/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | *FakeApi* | [**TestClientModel**](docs/FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model *FakeApi* | [**TestEndpointParameters**](docs/FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *FakeApi* | [**TestEnumParameters**](docs/FakeApi.md#testenumparameters) | **GET** /fake | To test enum parameters @@ -109,10 +113,8 @@ Class | Method | HTTP request | Description - [Model.ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [Model.ArrayTest](docs/ArrayTest.md) - [Model.Capitalization](docs/Capitalization.md) - - [Model.Cat](docs/Cat.md) - [Model.Category](docs/Category.md) - [Model.ClassModel](docs/ClassModel.md) - - [Model.Dog](docs/Dog.md) - [Model.EnumArrays](docs/EnumArrays.md) - [Model.EnumClass](docs/EnumClass.md) - [Model.EnumTest](docs/EnumTest.md) @@ -127,12 +129,18 @@ Class | Method | HTTP request | Description - [Model.Name](docs/Name.md) - [Model.NumberOnly](docs/NumberOnly.md) - [Model.Order](docs/Order.md) + - [Model.OuterBoolean](docs/OuterBoolean.md) + - [Model.OuterComposite](docs/OuterComposite.md) - [Model.OuterEnum](docs/OuterEnum.md) + - [Model.OuterNumber](docs/OuterNumber.md) + - [Model.OuterString](docs/OuterString.md) - [Model.Pet](docs/Pet.md) - [Model.ReadOnlyFirst](docs/ReadOnlyFirst.md) - [Model.SpecialModelName](docs/SpecialModelName.md) - [Model.Tag](docs/Tag.md) - [Model.User](docs/User.md) + - [Model.Cat](docs/Cat.md) + - [Model.Dog](docs/Dog.md) diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/FakeApi.md b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/FakeApi.md index 82a3463dacb..41bddd87b49 100644 --- a/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/FakeApi.md +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/FakeApi.md @@ -4,11 +4,255 @@ All URIs are relative to *http://petstore.swagger.io:80/v2* Method | HTTP request | Description ------------- | ------------- | ------------- +[**FakeOuterBooleanSerialize**](FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean | +[**FakeOuterCompositeSerialize**](FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite | +[**FakeOuterNumberSerialize**](FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number | +[**FakeOuterStringSerialize**](FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string | [**TestClientModel**](FakeApi.md#testclientmodel) | **PATCH** /fake | To test \"client\" model [**TestEndpointParameters**](FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**TestEnumParameters**](FakeApi.md#testenumparameters) | **GET** /fake | To test enum parameters + +# **FakeOuterBooleanSerialize** +> OuterBoolean FakeOuterBooleanSerialize (OuterBoolean body = null) + + + +Test serialization of outer boolean types + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class FakeOuterBooleanSerializeExample + { + public void main() + { + var apiInstance = new FakeApi(); + var body = new OuterBoolean(); // OuterBoolean | Input boolean as post body (optional) + + try + { + OuterBoolean result = apiInstance.FakeOuterBooleanSerialize(body); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling FakeApi.FakeOuterBooleanSerialize: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**OuterBoolean**](OuterBoolean.md)| Input boolean as post body | [optional] + +### Return type + +[**OuterBoolean**](OuterBoolean.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **FakeOuterCompositeSerialize** +> OuterComposite FakeOuterCompositeSerialize (OuterComposite body = null) + + + +Test serialization of object with outer number type + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class FakeOuterCompositeSerializeExample + { + public void main() + { + var apiInstance = new FakeApi(); + var body = new OuterComposite(); // OuterComposite | Input composite as post body (optional) + + try + { + OuterComposite result = apiInstance.FakeOuterCompositeSerialize(body); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling FakeApi.FakeOuterCompositeSerialize: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**OuterComposite**](OuterComposite.md)| Input composite as post body | [optional] + +### Return type + +[**OuterComposite**](OuterComposite.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **FakeOuterNumberSerialize** +> OuterNumber FakeOuterNumberSerialize (OuterNumber body = null) + + + +Test serialization of outer number types + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class FakeOuterNumberSerializeExample + { + public void main() + { + var apiInstance = new FakeApi(); + var body = new OuterNumber(); // OuterNumber | Input number as post body (optional) + + try + { + OuterNumber result = apiInstance.FakeOuterNumberSerialize(body); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling FakeApi.FakeOuterNumberSerialize: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**OuterNumber**](OuterNumber.md)| Input number as post body | [optional] + +### Return type + +[**OuterNumber**](OuterNumber.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + + +# **FakeOuterStringSerialize** +> OuterString FakeOuterStringSerialize (OuterString body = null) + + + +Test serialization of outer string types + +### Example +```csharp +using System; +using System.Diagnostics; +using IO.Swagger.Api; +using IO.Swagger.Client; +using IO.Swagger.Model; + +namespace Example +{ + public class FakeOuterStringSerializeExample + { + public void main() + { + var apiInstance = new FakeApi(); + var body = new OuterString(); // OuterString | Input string as post body (optional) + + try + { + OuterString result = apiInstance.FakeOuterStringSerialize(body); + Debug.WriteLine(result); + } + catch (Exception e) + { + Debug.Print("Exception when calling FakeApi.FakeOuterStringSerialize: " + e.Message ); + } + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**OuterString**](OuterString.md)| Input string as post body | [optional] + +### Return type + +[**OuterString**](OuterString.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: Not defined + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **TestClientModel** > ModelClient TestClientModel (ModelClient body) @@ -31,7 +275,6 @@ namespace Example { public void main() { - var apiInstance = new FakeApi(); var body = new ModelClient(); // ModelClient | client model @@ -93,7 +336,6 @@ namespace Example { public void main() { - // Configure HTTP basic authorization: http_basic_test Configuration.Default.Username = "YOUR_USERNAME"; Configuration.Default.Password = "YOUR_PASSWORD"; @@ -184,7 +426,6 @@ namespace Example { public void main() { - var apiInstance = new FakeApi(); var enumFormStringArray = new List(); // List | Form parameter enum test (string array) (optional) var enumFormString = enumFormString_example; // string | Form parameter enum test (string) (optional) (default to -efg) diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/OuterBoolean.md b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/OuterBoolean.md new file mode 100644 index 00000000000..84845b35e54 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/OuterBoolean.md @@ -0,0 +1,8 @@ +# IO.Swagger.Model.OuterBoolean +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/OuterComposite.md b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/OuterComposite.md new file mode 100644 index 00000000000..41fae66f136 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/OuterComposite.md @@ -0,0 +1,11 @@ +# IO.Swagger.Model.OuterComposite +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**MyNumber** | [**OuterNumber**](OuterNumber.md) | | [optional] +**MyString** | [**OuterString**](OuterString.md) | | [optional] +**MyBoolean** | [**OuterBoolean**](OuterBoolean.md) | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/OuterNumber.md b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/OuterNumber.md new file mode 100644 index 00000000000..7c88274d6ee --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/OuterNumber.md @@ -0,0 +1,8 @@ +# IO.Swagger.Model.OuterNumber +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/OuterString.md b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/OuterString.md new file mode 100644 index 00000000000..524423a5dab --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/OuterString.md @@ -0,0 +1,8 @@ +# IO.Swagger.Model.OuterString +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/PetApi.md b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/PetApi.md index f3f49f5ed5b..148d49b8b88 100644 --- a/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/PetApi.md +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/PetApi.md @@ -36,7 +36,6 @@ namespace Example { public void main() { - // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; @@ -100,7 +99,6 @@ namespace Example { public void main() { - // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; @@ -166,7 +164,6 @@ namespace Example { public void main() { - // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; @@ -231,7 +228,6 @@ namespace Example { public void main() { - // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; @@ -296,7 +292,6 @@ namespace Example { public void main() { - // Configure API key authorization: api_key Configuration.Default.ApiKey.Add("api_key", "YOUR_API_KEY"); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed @@ -363,7 +358,6 @@ namespace Example { public void main() { - // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; @@ -427,7 +421,6 @@ namespace Example { public void main() { - // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; @@ -495,7 +488,6 @@ namespace Example { public void main() { - // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/StoreApi.md b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/StoreApi.md index bf2fdb1ed6d..1509a03158f 100644 --- a/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/StoreApi.md +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/StoreApi.md @@ -32,7 +32,6 @@ namespace Example { public void main() { - var apiInstance = new StoreApi(); var orderId = orderId_example; // string | ID of the order that needs to be deleted @@ -93,7 +92,6 @@ namespace Example { public void main() { - // Configure API key authorization: api_key Configuration.Default.ApiKey.Add("api_key", "YOUR_API_KEY"); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed @@ -156,7 +154,6 @@ namespace Example { public void main() { - var apiInstance = new StoreApi(); var orderId = 789; // long? | ID of pet that needs to be fetched @@ -218,7 +215,6 @@ namespace Example { public void main() { - var apiInstance = new StoreApi(); var body = new Order(); // Order | order placed for purchasing the pet diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/UserApi.md b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/UserApi.md index 78553f5b385..0ddde3f669c 100644 --- a/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/UserApi.md +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/docs/UserApi.md @@ -36,7 +36,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); var body = new User(); // User | Created user object @@ -97,7 +96,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); var body = new List(); // List | List of user object @@ -158,7 +156,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); var body = new List(); // List | List of user object @@ -219,7 +216,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); var username = username_example; // string | The name that needs to be deleted @@ -280,7 +276,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); var username = username_example; // string | The name that needs to be fetched. Use user1 for testing. @@ -342,7 +337,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); var username = username_example; // string | The user name for login var password = password_example; // string | The password for login in clear text @@ -406,7 +400,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); try @@ -463,7 +456,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); var username = username_example; // string | name that need to be deleted var body = new User(); // User | Updated user object diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Api/FakeApi.cs b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Api/FakeApi.cs index 9c73f22c36b..ea748e60f0c 100644 --- a/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Api/FakeApi.cs @@ -25,6 +25,90 @@ namespace IO.Swagger.Api { #region Synchronous Operations ///

+ /// + /// + /// + /// Test serialization of outer boolean types + /// + /// Thrown when fails to make API call + /// Input boolean as post body (optional) + /// OuterBoolean + OuterBoolean FakeOuterBooleanSerialize (OuterBoolean body = null); + + /// + /// + /// + /// + /// Test serialization of outer boolean types + /// + /// Thrown when fails to make API call + /// Input boolean as post body (optional) + /// ApiResponse of OuterBoolean + ApiResponse FakeOuterBooleanSerializeWithHttpInfo (OuterBoolean body = null); + /// + /// + /// + /// + /// Test serialization of object with outer number type + /// + /// Thrown when fails to make API call + /// Input composite as post body (optional) + /// OuterComposite + OuterComposite FakeOuterCompositeSerialize (OuterComposite body = null); + + /// + /// + /// + /// + /// Test serialization of object with outer number type + /// + /// Thrown when fails to make API call + /// Input composite as post body (optional) + /// ApiResponse of OuterComposite + ApiResponse FakeOuterCompositeSerializeWithHttpInfo (OuterComposite body = null); + /// + /// + /// + /// + /// Test serialization of outer number types + /// + /// Thrown when fails to make API call + /// Input number as post body (optional) + /// OuterNumber + OuterNumber FakeOuterNumberSerialize (OuterNumber body = null); + + /// + /// + /// + /// + /// Test serialization of outer number types + /// + /// Thrown when fails to make API call + /// Input number as post body (optional) + /// ApiResponse of OuterNumber + ApiResponse FakeOuterNumberSerializeWithHttpInfo (OuterNumber body = null); + /// + /// + /// + /// + /// Test serialization of outer string types + /// + /// Thrown when fails to make API call + /// Input string as post body (optional) + /// OuterString + OuterString FakeOuterStringSerialize (OuterString body = null); + + /// + /// + /// + /// + /// Test serialization of outer string types + /// + /// Thrown when fails to make API call + /// Input string as post body (optional) + /// ApiResponse of OuterString + ApiResponse FakeOuterStringSerializeWithHttpInfo (OuterString body = null); + /// /// To test \"client\" model /// /// @@ -130,6 +214,90 @@ namespace IO.Swagger.Api #endregion Synchronous Operations #region Asynchronous Operations /// + /// + /// + /// + /// Test serialization of outer boolean types + /// + /// Thrown when fails to make API call + /// Input boolean as post body (optional) + /// Task of OuterBoolean + System.Threading.Tasks.Task FakeOuterBooleanSerializeAsync (OuterBoolean body = null); + + /// + /// + /// + /// + /// Test serialization of outer boolean types + /// + /// Thrown when fails to make API call + /// Input boolean as post body (optional) + /// Task of ApiResponse (OuterBoolean) + System.Threading.Tasks.Task> FakeOuterBooleanSerializeAsyncWithHttpInfo (OuterBoolean body = null); + /// + /// + /// + /// + /// Test serialization of object with outer number type + /// + /// Thrown when fails to make API call + /// Input composite as post body (optional) + /// Task of OuterComposite + System.Threading.Tasks.Task FakeOuterCompositeSerializeAsync (OuterComposite body = null); + + /// + /// + /// + /// + /// Test serialization of object with outer number type + /// + /// Thrown when fails to make API call + /// Input composite as post body (optional) + /// Task of ApiResponse (OuterComposite) + System.Threading.Tasks.Task> FakeOuterCompositeSerializeAsyncWithHttpInfo (OuterComposite body = null); + /// + /// + /// + /// + /// Test serialization of outer number types + /// + /// Thrown when fails to make API call + /// Input number as post body (optional) + /// Task of OuterNumber + System.Threading.Tasks.Task FakeOuterNumberSerializeAsync (OuterNumber body = null); + + /// + /// + /// + /// + /// Test serialization of outer number types + /// + /// Thrown when fails to make API call + /// Input number as post body (optional) + /// Task of ApiResponse (OuterNumber) + System.Threading.Tasks.Task> FakeOuterNumberSerializeAsyncWithHttpInfo (OuterNumber body = null); + /// + /// + /// + /// + /// Test serialization of outer string types + /// + /// Thrown when fails to make API call + /// Input string as post body (optional) + /// Task of OuterString + System.Threading.Tasks.Task FakeOuterStringSerializeAsync (OuterString body = null); + + /// + /// + /// + /// + /// Test serialization of outer string types + /// + /// Thrown when fails to make API call + /// Input string as post body (optional) + /// Task of ApiResponse (OuterString) + System.Threading.Tasks.Task> FakeOuterStringSerializeAsyncWithHttpInfo (OuterString body = null); + /// /// To test \"client\" model /// /// @@ -344,6 +512,562 @@ namespace IO.Swagger.Api this.Configuration.AddDefaultHeader(key, value); } + /// + /// Test serialization of outer boolean types + /// + /// Thrown when fails to make API call + /// Input boolean as post body (optional) + /// OuterBoolean + public OuterBoolean FakeOuterBooleanSerialize (OuterBoolean body = null) + { + ApiResponse localVarResponse = FakeOuterBooleanSerializeWithHttpInfo(body); + return localVarResponse.Data; + } + + /// + /// Test serialization of outer boolean types + /// + /// Thrown when fails to make API call + /// Input boolean as post body (optional) + /// ApiResponse of OuterBoolean + public ApiResponse< OuterBoolean > FakeOuterBooleanSerializeWithHttpInfo (OuterBoolean body = null) + { + + var localVarPath = "./fake/outer/boolean"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new Dictionary(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("FakeOuterBooleanSerialize", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Key, x => x.Value.ToString()), + (OuterBoolean) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterBoolean))); + } + + /// + /// Test serialization of outer boolean types + /// + /// Thrown when fails to make API call + /// Input boolean as post body (optional) + /// Task of OuterBoolean + public async System.Threading.Tasks.Task FakeOuterBooleanSerializeAsync (OuterBoolean body = null) + { + ApiResponse localVarResponse = await FakeOuterBooleanSerializeAsyncWithHttpInfo(body); + return localVarResponse.Data; + + } + + /// + /// Test serialization of outer boolean types + /// + /// Thrown when fails to make API call + /// Input boolean as post body (optional) + /// Task of ApiResponse (OuterBoolean) + public async System.Threading.Tasks.Task> FakeOuterBooleanSerializeAsyncWithHttpInfo (OuterBoolean body = null) + { + + var localVarPath = "./fake/outer/boolean"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new Dictionary(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("FakeOuterBooleanSerialize", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Key, x => x.Value.ToString()), + (OuterBoolean) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterBoolean))); + } + + /// + /// Test serialization of object with outer number type + /// + /// Thrown when fails to make API call + /// Input composite as post body (optional) + /// OuterComposite + public OuterComposite FakeOuterCompositeSerialize (OuterComposite body = null) + { + ApiResponse localVarResponse = FakeOuterCompositeSerializeWithHttpInfo(body); + return localVarResponse.Data; + } + + /// + /// Test serialization of object with outer number type + /// + /// Thrown when fails to make API call + /// Input composite as post body (optional) + /// ApiResponse of OuterComposite + public ApiResponse< OuterComposite > FakeOuterCompositeSerializeWithHttpInfo (OuterComposite body = null) + { + + var localVarPath = "./fake/outer/composite"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new Dictionary(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("FakeOuterCompositeSerialize", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Key, x => x.Value.ToString()), + (OuterComposite) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterComposite))); + } + + /// + /// Test serialization of object with outer number type + /// + /// Thrown when fails to make API call + /// Input composite as post body (optional) + /// Task of OuterComposite + public async System.Threading.Tasks.Task FakeOuterCompositeSerializeAsync (OuterComposite body = null) + { + ApiResponse localVarResponse = await FakeOuterCompositeSerializeAsyncWithHttpInfo(body); + return localVarResponse.Data; + + } + + /// + /// Test serialization of object with outer number type + /// + /// Thrown when fails to make API call + /// Input composite as post body (optional) + /// Task of ApiResponse (OuterComposite) + public async System.Threading.Tasks.Task> FakeOuterCompositeSerializeAsyncWithHttpInfo (OuterComposite body = null) + { + + var localVarPath = "./fake/outer/composite"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new Dictionary(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("FakeOuterCompositeSerialize", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Key, x => x.Value.ToString()), + (OuterComposite) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterComposite))); + } + + /// + /// Test serialization of outer number types + /// + /// Thrown when fails to make API call + /// Input number as post body (optional) + /// OuterNumber + public OuterNumber FakeOuterNumberSerialize (OuterNumber body = null) + { + ApiResponse localVarResponse = FakeOuterNumberSerializeWithHttpInfo(body); + return localVarResponse.Data; + } + + /// + /// Test serialization of outer number types + /// + /// Thrown when fails to make API call + /// Input number as post body (optional) + /// ApiResponse of OuterNumber + public ApiResponse< OuterNumber > FakeOuterNumberSerializeWithHttpInfo (OuterNumber body = null) + { + + var localVarPath = "./fake/outer/number"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new Dictionary(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("FakeOuterNumberSerialize", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Key, x => x.Value.ToString()), + (OuterNumber) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterNumber))); + } + + /// + /// Test serialization of outer number types + /// + /// Thrown when fails to make API call + /// Input number as post body (optional) + /// Task of OuterNumber + public async System.Threading.Tasks.Task FakeOuterNumberSerializeAsync (OuterNumber body = null) + { + ApiResponse localVarResponse = await FakeOuterNumberSerializeAsyncWithHttpInfo(body); + return localVarResponse.Data; + + } + + /// + /// Test serialization of outer number types + /// + /// Thrown when fails to make API call + /// Input number as post body (optional) + /// Task of ApiResponse (OuterNumber) + public async System.Threading.Tasks.Task> FakeOuterNumberSerializeAsyncWithHttpInfo (OuterNumber body = null) + { + + var localVarPath = "./fake/outer/number"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new Dictionary(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("FakeOuterNumberSerialize", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Key, x => x.Value.ToString()), + (OuterNumber) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterNumber))); + } + + /// + /// Test serialization of outer string types + /// + /// Thrown when fails to make API call + /// Input string as post body (optional) + /// OuterString + public OuterString FakeOuterStringSerialize (OuterString body = null) + { + ApiResponse localVarResponse = FakeOuterStringSerializeWithHttpInfo(body); + return localVarResponse.Data; + } + + /// + /// Test serialization of outer string types + /// + /// Thrown when fails to make API call + /// Input string as post body (optional) + /// ApiResponse of OuterString + public ApiResponse< OuterString > FakeOuterStringSerializeWithHttpInfo (OuterString body = null) + { + + var localVarPath = "./fake/outer/string"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new Dictionary(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("FakeOuterStringSerialize", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Key, x => x.Value.ToString()), + (OuterString) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterString))); + } + + /// + /// Test serialization of outer string types + /// + /// Thrown when fails to make API call + /// Input string as post body (optional) + /// Task of OuterString + public async System.Threading.Tasks.Task FakeOuterStringSerializeAsync (OuterString body = null) + { + ApiResponse localVarResponse = await FakeOuterStringSerializeAsyncWithHttpInfo(body); + return localVarResponse.Data; + + } + + /// + /// Test serialization of outer string types + /// + /// Thrown when fails to make API call + /// Input string as post body (optional) + /// Task of ApiResponse (OuterString) + public async System.Threading.Tasks.Task> FakeOuterStringSerializeAsyncWithHttpInfo (OuterString body = null) + { + + var localVarPath = "./fake/outer/string"; + var localVarPathParams = new Dictionary(); + var localVarQueryParams = new Dictionary(); + var localVarHeaderParams = new Dictionary(Configuration.DefaultHeader); + var localVarFormParams = new Dictionary(); + var localVarFileParams = new Dictionary(); + Object localVarPostBody = null; + + // to determine the Content-Type header + String[] localVarHttpContentTypes = new String[] { + }; + String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes); + + // to determine the Accept header + String[] localVarHttpHeaderAccepts = new String[] { + }; + String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); + if (localVarHttpHeaderAccept != null) + localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); + + if (body != null && body.GetType() != typeof(byte[])) + { + localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter + } + else + { + localVarPostBody = body; // byte array + } + + + // make the HTTP request + IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath, + Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, + localVarPathParams, localVarHttpContentType); + + int localVarStatusCode = (int) localVarResponse.StatusCode; + + if (ExceptionFactory != null) + { + Exception exception = ExceptionFactory("FakeOuterStringSerialize", localVarResponse); + if (exception != null) throw exception; + } + + return new ApiResponse(localVarStatusCode, + localVarResponse.Headers.ToDictionary(x => x.Key, x => x.Value.ToString()), + (OuterString) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterString))); + } + /// /// To test \"client\" model To test \"client\" model /// diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Model/OuterBoolean.cs b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Model/OuterBoolean.cs new file mode 100644 index 00000000000..54f81745c24 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Model/OuterBoolean.cs @@ -0,0 +1,100 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace IO.Swagger.Model +{ + /// + /// OuterBoolean + /// + [DataContract] + public partial class OuterBoolean : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + public OuterBoolean() + { + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class OuterBoolean {\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + // credit: http://stackoverflow.com/a/10454552/677735 + return this.Equals(obj as OuterBoolean); + } + + /// + /// Returns true if OuterBoolean instances are equal + /// + /// Instance of OuterBoolean to be compared + /// Boolean + public bool Equals(OuterBoolean other) + { + // credit: http://stackoverflow.com/a/10454552/677735 + if (other == null) + return false; + + return false; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + // credit: http://stackoverflow.com/a/263416/677735 + unchecked // Overflow is fine, just wrap + { + int hash = 41; + // Suitable nullity checks etc, of course :) + return hash; + } + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Model/OuterComposite.cs b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Model/OuterComposite.cs new file mode 100644 index 00000000000..308c26d4f5c --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Model/OuterComposite.cs @@ -0,0 +1,144 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace IO.Swagger.Model +{ + /// + /// OuterComposite + /// + [DataContract] + public partial class OuterComposite : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + /// MyNumber. + /// MyString. + /// MyBoolean. + public OuterComposite(OuterNumber MyNumber = default(OuterNumber), OuterString MyString = default(OuterString), OuterBoolean MyBoolean = default(OuterBoolean)) + { + this.MyNumber = MyNumber; + this.MyString = MyString; + this.MyBoolean = MyBoolean; + } + + /// + /// Gets or Sets MyNumber + /// + [DataMember(Name="my_number", EmitDefaultValue=false)] + public OuterNumber MyNumber { get; set; } + /// + /// Gets or Sets MyString + /// + [DataMember(Name="my_string", EmitDefaultValue=false)] + public OuterString MyString { get; set; } + /// + /// Gets or Sets MyBoolean + /// + [DataMember(Name="my_boolean", EmitDefaultValue=false)] + public OuterBoolean MyBoolean { get; set; } + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class OuterComposite {\n"); + sb.Append(" MyNumber: ").Append(MyNumber).Append("\n"); + sb.Append(" MyString: ").Append(MyString).Append("\n"); + sb.Append(" MyBoolean: ").Append(MyBoolean).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + // credit: http://stackoverflow.com/a/10454552/677735 + return this.Equals(obj as OuterComposite); + } + + /// + /// Returns true if OuterComposite instances are equal + /// + /// Instance of OuterComposite to be compared + /// Boolean + public bool Equals(OuterComposite other) + { + // credit: http://stackoverflow.com/a/10454552/677735 + if (other == null) + return false; + + return + ( + this.MyNumber == other.MyNumber || + this.MyNumber != null && + this.MyNumber.Equals(other.MyNumber) + ) && + ( + this.MyString == other.MyString || + this.MyString != null && + this.MyString.Equals(other.MyString) + ) && + ( + this.MyBoolean == other.MyBoolean || + this.MyBoolean != null && + this.MyBoolean.Equals(other.MyBoolean) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + // credit: http://stackoverflow.com/a/263416/677735 + unchecked // Overflow is fine, just wrap + { + int hash = 41; + // Suitable nullity checks etc, of course :) + if (this.MyNumber != null) + hash = hash * 59 + this.MyNumber.GetHashCode(); + if (this.MyString != null) + hash = hash * 59 + this.MyString.GetHashCode(); + if (this.MyBoolean != null) + hash = hash * 59 + this.MyBoolean.GetHashCode(); + return hash; + } + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Model/OuterNumber.cs b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Model/OuterNumber.cs new file mode 100644 index 00000000000..103fd4f69dd --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Model/OuterNumber.cs @@ -0,0 +1,100 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace IO.Swagger.Model +{ + /// + /// OuterNumber + /// + [DataContract] + public partial class OuterNumber : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + public OuterNumber() + { + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class OuterNumber {\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + // credit: http://stackoverflow.com/a/10454552/677735 + return this.Equals(obj as OuterNumber); + } + + /// + /// Returns true if OuterNumber instances are equal + /// + /// Instance of OuterNumber to be compared + /// Boolean + public bool Equals(OuterNumber other) + { + // credit: http://stackoverflow.com/a/10454552/677735 + if (other == null) + return false; + + return false; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + // credit: http://stackoverflow.com/a/263416/677735 + unchecked // Overflow is fine, just wrap + { + int hash = 41; + // Suitable nullity checks etc, of course :) + return hash; + } + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Model/OuterString.cs b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Model/OuterString.cs new file mode 100644 index 00000000000..327fe620b59 --- /dev/null +++ b/samples/client/petstore/csharp/SwaggerClientNetStandard/src/IO.Swagger/Model/OuterString.cs @@ -0,0 +1,100 @@ +/* + * Swagger Petstore + * + * This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ + * + * OpenAPI spec version: 1.0.0 + * Contact: apiteam@swagger.io + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Runtime.Serialization; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace IO.Swagger.Model +{ + /// + /// OuterString + /// + [DataContract] + public partial class OuterString : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + public OuterString() + { + } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class OuterString {\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + // credit: http://stackoverflow.com/a/10454552/677735 + return this.Equals(obj as OuterString); + } + + /// + /// Returns true if OuterString instances are equal + /// + /// Instance of OuterString to be compared + /// Boolean + public bool Equals(OuterString other) + { + // credit: http://stackoverflow.com/a/10454552/677735 + if (other == null) + return false; + + return false; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + // credit: http://stackoverflow.com/a/263416/677735 + unchecked // Overflow is fine, just wrap + { + int hash = 41; + // Suitable nullity checks etc, of course :) + return hash; + } + } + } + +} diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/README.md b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/README.md index e9f8551872b..509276df700 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/README.md +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/README.md @@ -67,7 +67,7 @@ namespace Example { public void main() { - + var apiInstance = new FakeApi(); var body = new OuterBoolean(); // OuterBoolean | Input boolean as post body (optional) @@ -80,6 +80,7 @@ namespace Example { Debug.Print("Exception when calling FakeApi.FakeOuterBooleanSerialize: " + e.Message ); } + } } } @@ -132,10 +133,8 @@ Class | Method | HTTP request | Description - [Model.ArrayOfNumberOnly](docs/ArrayOfNumberOnly.md) - [Model.ArrayTest](docs/ArrayTest.md) - [Model.Capitalization](docs/Capitalization.md) - - [Model.Cat](docs/Cat.md) - [Model.Category](docs/Category.md) - [Model.ClassModel](docs/ClassModel.md) - - [Model.Dog](docs/Dog.md) - [Model.EnumArrays](docs/EnumArrays.md) - [Model.EnumClass](docs/EnumClass.md) - [Model.EnumTest](docs/EnumTest.md) @@ -160,6 +159,8 @@ Class | Method | HTTP request | Description - [Model.SpecialModelName](docs/SpecialModelName.md) - [Model.Tag](docs/Tag.md) - [Model.User](docs/User.md) + - [Model.Cat](docs/Cat.md) + - [Model.Dog](docs/Dog.md) diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/FakeApi.md b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/FakeApi.md index 1277461eb1d..41bddd87b49 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/FakeApi.md +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/FakeApi.md @@ -35,7 +35,6 @@ namespace Example { public void main() { - var apiInstance = new FakeApi(); var body = new OuterBoolean(); // OuterBoolean | Input boolean as post body (optional) @@ -96,7 +95,6 @@ namespace Example { public void main() { - var apiInstance = new FakeApi(); var body = new OuterComposite(); // OuterComposite | Input composite as post body (optional) @@ -157,7 +155,6 @@ namespace Example { public void main() { - var apiInstance = new FakeApi(); var body = new OuterNumber(); // OuterNumber | Input number as post body (optional) @@ -218,7 +215,6 @@ namespace Example { public void main() { - var apiInstance = new FakeApi(); var body = new OuterString(); // OuterString | Input string as post body (optional) @@ -279,7 +275,6 @@ namespace Example { public void main() { - var apiInstance = new FakeApi(); var body = new ModelClient(); // ModelClient | client model @@ -341,7 +336,6 @@ namespace Example { public void main() { - // Configure HTTP basic authorization: http_basic_test Configuration.Default.Username = "YOUR_USERNAME"; Configuration.Default.Password = "YOUR_PASSWORD"; @@ -432,7 +426,6 @@ namespace Example { public void main() { - var apiInstance = new FakeApi(); var enumFormStringArray = new List(); // List | Form parameter enum test (string array) (optional) var enumFormString = enumFormString_example; // string | Form parameter enum test (string) (optional) (default to -efg) diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/PetApi.md b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/PetApi.md index f3f49f5ed5b..148d49b8b88 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/PetApi.md +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/PetApi.md @@ -36,7 +36,6 @@ namespace Example { public void main() { - // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; @@ -100,7 +99,6 @@ namespace Example { public void main() { - // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; @@ -166,7 +164,6 @@ namespace Example { public void main() { - // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; @@ -231,7 +228,6 @@ namespace Example { public void main() { - // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; @@ -296,7 +292,6 @@ namespace Example { public void main() { - // Configure API key authorization: api_key Configuration.Default.ApiKey.Add("api_key", "YOUR_API_KEY"); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed @@ -363,7 +358,6 @@ namespace Example { public void main() { - // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; @@ -427,7 +421,6 @@ namespace Example { public void main() { - // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; @@ -495,7 +488,6 @@ namespace Example { public void main() { - // Configure OAuth2 access token for authorization: petstore_auth Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN"; diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/StoreApi.md b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/StoreApi.md index bf2fdb1ed6d..1509a03158f 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/StoreApi.md +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/StoreApi.md @@ -32,7 +32,6 @@ namespace Example { public void main() { - var apiInstance = new StoreApi(); var orderId = orderId_example; // string | ID of the order that needs to be deleted @@ -93,7 +92,6 @@ namespace Example { public void main() { - // Configure API key authorization: api_key Configuration.Default.ApiKey.Add("api_key", "YOUR_API_KEY"); // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed @@ -156,7 +154,6 @@ namespace Example { public void main() { - var apiInstance = new StoreApi(); var orderId = 789; // long? | ID of pet that needs to be fetched @@ -218,7 +215,6 @@ namespace Example { public void main() { - var apiInstance = new StoreApi(); var body = new Order(); // Order | order placed for purchasing the pet diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/UserApi.md b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/UserApi.md index 78553f5b385..0ddde3f669c 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/UserApi.md +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/docs/UserApi.md @@ -36,7 +36,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); var body = new User(); // User | Created user object @@ -97,7 +96,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); var body = new List(); // List | List of user object @@ -158,7 +156,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); var body = new List(); // List | List of user object @@ -219,7 +216,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); var username = username_example; // string | The name that needs to be deleted @@ -280,7 +276,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); var username = username_example; // string | The name that needs to be fetched. Use user1 for testing. @@ -342,7 +337,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); var username = username_example; // string | The user name for login var password = password_example; // string | The password for login in clear text @@ -406,7 +400,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); try @@ -463,7 +456,6 @@ namespace Example { public void main() { - var apiInstance = new UserApi(); var username = username_example; // string | name that need to be deleted var body = new User(); // User | Updated user object diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger.Test/IO.Swagger.Test.csproj b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger.Test/IO.Swagger.Test.csproj index a5e34c3155f..7cac6bb0121 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger.Test/IO.Swagger.Test.csproj +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger.Test/IO.Swagger.Test.csproj @@ -66,7 +66,8 @@ Contact: apiteam@swagger.io - + diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Api/FakeApi.cs b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Api/FakeApi.cs index 76d88a6b174..953b7844ed2 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Api/FakeApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Api/FakeApi.cs @@ -579,7 +579,6 @@ namespace IO.Swagger.Api return new ApiResponse(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (OuterBoolean) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterBoolean))); - } /// @@ -650,7 +649,6 @@ namespace IO.Swagger.Api return new ApiResponse(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (OuterBoolean) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterBoolean))); - } /// @@ -720,7 +718,6 @@ namespace IO.Swagger.Api return new ApiResponse(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (OuterComposite) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterComposite))); - } /// @@ -791,7 +788,6 @@ namespace IO.Swagger.Api return new ApiResponse(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (OuterComposite) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterComposite))); - } /// @@ -861,7 +857,6 @@ namespace IO.Swagger.Api return new ApiResponse(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (OuterNumber) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterNumber))); - } /// @@ -932,7 +927,6 @@ namespace IO.Swagger.Api return new ApiResponse(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (OuterNumber) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterNumber))); - } /// @@ -1002,7 +996,6 @@ namespace IO.Swagger.Api return new ApiResponse(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (OuterString) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterString))); - } /// @@ -1073,7 +1066,6 @@ namespace IO.Swagger.Api return new ApiResponse(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (OuterString) Configuration.ApiClient.Deserialize(localVarResponse, typeof(OuterString))); - } /// diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/IO.Swagger.csproj b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/IO.Swagger.csproj index 3c33414c2c8..493a343283d 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/IO.Swagger.csproj +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/IO.Swagger.csproj @@ -64,10 +64,8 @@ Contact: apiteam@swagger.io - - - - + diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/OuterBoolean.cs b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/OuterBoolean.cs index 2081641d2f8..8a830ee9602 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/OuterBoolean.cs +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/OuterBoolean.cs @@ -127,7 +127,7 @@ namespace IO.Swagger.Model /// Validation context /// Validation Result IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { + { yield break; } } diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/OuterComposite.cs b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/OuterComposite.cs index 14f8b9d756c..e4b41a639fc 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/OuterComposite.cs +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/OuterComposite.cs @@ -171,7 +171,7 @@ namespace IO.Swagger.Model /// Validation context /// Validation Result IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { + { yield break; } } diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/OuterNumber.cs b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/OuterNumber.cs index 1cfdf28555a..a60260550be 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/OuterNumber.cs +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/OuterNumber.cs @@ -127,7 +127,7 @@ namespace IO.Swagger.Model /// Validation context /// Validation Result IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { + { yield break; } } diff --git a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/OuterString.cs b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/OuterString.cs index 9ee02e48db8..f4687db798f 100644 --- a/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/OuterString.cs +++ b/samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/src/IO.Swagger/Model/OuterString.cs @@ -127,7 +127,7 @@ namespace IO.Swagger.Model /// Validation context /// Validation Result IEnumerable IValidatableObject.Validate(ValidationContext validationContext) - { + { yield break; } }