From 906bd2c7bf8b931f85289ad6a06b2f8617b628c7 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sun, 17 Jan 2016 19:14:11 +0800 Subject: [PATCH 1/2] add binary mapping for code generator --- .../codegen/languages/AbstractTypeScriptClientCodegen.java | 4 +++- .../java/io/swagger/codegen/languages/DartClientCodegen.java | 3 +++ .../io/swagger/codegen/languages/FlashClientCodegen.java | 3 +++ .../java/io/swagger/codegen/languages/PerlClientCodegen.java | 3 +++ .../io/swagger/codegen/languages/PythonClientCodegen.java | 3 +++ .../java/io/swagger/codegen/languages/Qt5CPPGenerator.java | 3 +++ .../io/swagger/codegen/languages/ScalaClientCodegen.java | 3 +++ .../io/swagger/codegen/languages/ScalatraServerCodegen.java | 5 ++++- .../io/swagger/codegen/languages/SilexServerCodegen.java | 3 +++ .../io/swagger/codegen/languages/SinatraServerCodegen.java | 3 +++ .../codegen/languages/SlimFrameworkServerCodegen.java | 3 +++ .../main/java/io/swagger/codegen/languages/SwiftCodegen.java | 3 +++ .../io/swagger/codegen/languages/TizenClientCodegen.java | 3 +++ 13 files changed, 40 insertions(+), 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractTypeScriptClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractTypeScriptClientCodegen.java index cdfc01d2f8..ebc8a0617f 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractTypeScriptClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractTypeScriptClientCodegen.java @@ -52,7 +52,9 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp typeMapping.put("integer", "number"); typeMapping.put("Map", "any"); typeMapping.put("DateTime", "Date"); - + //TODO binary should be mapped to byte array + // mapped to String as a workaround + typeMapping.put("binary", "string"); } @Override diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java index 7d11f2a818..e936a37f3c 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/DartClientCodegen.java @@ -76,6 +76,9 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig { typeMapping.put("Date", "DateTime"); typeMapping.put("date", "DateTime"); typeMapping.put("File", "MultipartFile"); + //TODO binary should be mapped to byte array + // mapped to String as a workaround + typeMapping.put("binary", "String"); cliOptions.add(new CliOption(BROWSER_CLIENT, "Is the client browser based")); cliOptions.add(new CliOption(PUB_NAME, "Name in generated pubspec")); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FlashClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FlashClientCodegen.java index dac3d23b22..435e235c68 100755 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FlashClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/FlashClientCodegen.java @@ -63,6 +63,9 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig typeMapping.put("DateTime", "Date"); typeMapping.put("object", "Object"); typeMapping.put("file", "File"); + //TODO binary should be mapped to byte array + // mapped to String as a workaround + typeMapping.put("binary", "String"); importMapping = new HashMap(); importMapping.put("File", "flash.filesystem.File"); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java index 90fea3f4a9..9f287ea089 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PerlClientCodegen.java @@ -72,6 +72,9 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig { typeMapping.put("array", "ARRAY"); typeMapping.put("map", "HASH"); typeMapping.put("object", "object"); + //TODO binary should be mapped to byte array + // mapped to String as a workaround + typeMapping.put("binary", "string"); cliOptions.clear(); cliOptions.add(new CliOption(MODULE_NAME, "Perl module name (convention: CamelCase or Long::Module).").defaultValue("SwaggerClient")); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java index 02ce858d0c..6bcb9c5d55 100755 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/PythonClientCodegen.java @@ -51,6 +51,9 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig typeMapping.put("DateTime", "datetime"); typeMapping.put("object", "object"); typeMapping.put("file", "file"); + //TODO binary should be mapped to byte array + // mapped to String as a workaround + typeMapping.put("binary", "str"); // from https://docs.python.org/release/2.5.4/ref/keywords.html reservedWords = new HashSet( diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java index 18ba371806..94cac627e9 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/Qt5CPPGenerator.java @@ -121,6 +121,9 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig { typeMapping.put("map", "QMap"); typeMapping.put("file", "SWGHttpRequestInputFileElement"); typeMapping.put("object", PREFIX + "Object"); + //TODO binary should be mapped to byte array + // mapped to String as a workaround + typeMapping.put("binary", "QString"); importMapping = new HashMap(); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalaClientCodegen.java index 088d7fdaad..e8f462a41f 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalaClientCodegen.java @@ -96,6 +96,9 @@ public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig typeMapping.put("double", "Double"); typeMapping.put("object", "Any"); typeMapping.put("file", "File"); + //TODO binary should be mapped to byte array + // mapped to String as a workaround + typeMapping.put("binary", "String"); languageSpecificPrimitives = new HashSet( Arrays.asList( diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalatraServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalatraServerCodegen.java index 5d6da58013..5a4d5c43ef 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalatraServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalatraServerCodegen.java @@ -67,6 +67,9 @@ public class ScalatraServerCodegen extends DefaultCodegen implements CodegenConf typeMapping.put("integer", "Int"); typeMapping.put("long", "Long"); + //TODO binary should be mapped to byte array + // mapped to String as a workaround + typeMapping.put("binary", "String"); additionalProperties.put("appName", "Swagger Sample"); additionalProperties.put("appName", "Swagger Sample"); @@ -193,4 +196,4 @@ public class ScalatraServerCodegen extends DefaultCodegen implements CodegenConf } return toModelName(type); } -} \ No newline at end of file +} diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SilexServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SilexServerCodegen.java index 4effb48004..40dedb0aea 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SilexServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SilexServerCodegen.java @@ -81,6 +81,9 @@ public class SilexServerCodegen extends DefaultCodegen implements CodegenConfig typeMapping.put("array", "array"); typeMapping.put("list", "array"); typeMapping.put("object", "object"); + //TODO binary should be mapped to byte array + // mapped to String as a workaround + typeMapping.put("binary", "string"); supportingFiles.add(new SupportingFile("README.mustache", packagePath.replace('/', File.separatorChar), "README.md")); supportingFiles.add(new SupportingFile("composer.json", packagePath.replace('/', File.separatorChar), "composer.json")); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SinatraServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SinatraServerCodegen.java index e478c00341..d512f7deb9 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SinatraServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SinatraServerCodegen.java @@ -60,6 +60,9 @@ public class SinatraServerCodegen extends DefaultCodegen implements CodegenConfi typeMapping.put("String", "string"); typeMapping.put("List", "array"); typeMapping.put("map", "map"); + //TODO binary should be mapped to byte array + // mapped to String as a workaround + typeMapping.put("binary", "string"); // remove modelPackage and apiPackage added by default cliOptions.clear(); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SlimFrameworkServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SlimFrameworkServerCodegen.java index ae28493fe7..3810c6895e 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SlimFrameworkServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SlimFrameworkServerCodegen.java @@ -83,6 +83,9 @@ public class SlimFrameworkServerCodegen extends DefaultCodegen implements Codege typeMapping.put("array", "array"); typeMapping.put("list", "array"); typeMapping.put("object", "object"); + //TODO binary should be mapped to byte array + // mapped to String as a workaround + typeMapping.put("binary", "string"); supportingFiles.add(new SupportingFile("README.mustache", packagePath.replace('/', File.separatorChar), "README.md")); supportingFiles.add(new SupportingFile("composer.json", packagePath.replace('/', File.separatorChar), "composer.json")); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java index ddd72e4230..1beb9a3b23 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java @@ -120,6 +120,9 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig { typeMapping.put("double", "Double"); typeMapping.put("object", "String"); typeMapping.put("file", "NSURL"); + //TODO binary should be mapped to byte array + // mapped to String as a workaround + typeMapping.put("binary", "String"); importMapping = new HashMap(); diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TizenClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TizenClientCodegen.java index 83241ddc5e..d7b7d13f63 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TizenClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/TizenClientCodegen.java @@ -76,6 +76,9 @@ public class TizenClientCodegen extends DefaultCodegen implements CodegenConfig typeMapping.put("map", "HashMap"); typeMapping.put("number", "Long"); typeMapping.put("object", PREFIX + "Object"); + //TODO binary should be mapped to byte array + // mapped to String as a workaround + typeMapping.put("binary", "String"); importMapping = new HashMap(); From bfc83b330fdaf8f8ce9846175a990d0f53b079d5 Mon Sep 17 00:00:00 2001 From: wing328 Date: Sun, 17 Jan 2016 19:32:50 +0800 Subject: [PATCH 2/2] fix indent, update perl & python sample --- .gitignore | 1 + .../AbstractTypeScriptClientCodegen.java | 2 +- samples/client/petstore/perl/README.md | 2 +- .../perl/lib/WWW/SwaggerClient/Role.pm | 4 +- samples/client/petstore/perl/t/04_role.t | 2 +- samples/client/petstore/python/.coverage | 2 +- .../petstore/python/dev-requirements.txt.log | 15 ++ .../python/swagger_client/apis/pet_api.py | 155 ++++++++++++++++++ 8 files changed, 177 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index d84a08f7b9..f80da2af55 100644 --- a/.gitignore +++ b/.gitignore @@ -59,6 +59,7 @@ samples/client/petstore/perl/deep_module_test/ samples/client/petstore/python/.projectile samples/client/petstore/python/.venv/ +samples/client/petstore/python/dev-requirements.txt.log .settings diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractTypeScriptClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractTypeScriptClientCodegen.java index ebc8a0617f..4a9c055730 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractTypeScriptClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractTypeScriptClientCodegen.java @@ -52,7 +52,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp typeMapping.put("integer", "number"); typeMapping.put("Map", "any"); typeMapping.put("DateTime", "Date"); - //TODO binary should be mapped to byte array + //TODO binary should be mapped to byte array // mapped to String as a workaround typeMapping.put("binary", "string"); } diff --git a/samples/client/petstore/perl/README.md b/samples/client/petstore/perl/README.md index f42bbf6eb1..e2685dd246 100644 --- a/samples/client/petstore/perl/README.md +++ b/samples/client/petstore/perl/README.md @@ -8,7 +8,7 @@ WWW::SwaggerClient::Role - a Moose role for the Swagger Petstore Automatically generated by the Perl Swagger Codegen project: -- Build date: 2016-01-15T15:57:32.150+08:00 +- Build date: 2016-01-17T19:21:19.346+08:00 - Build package: class io.swagger.codegen.languages.PerlClientCodegen - Codegen version: diff --git a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm index 07b499ad75..cc1e39c665 100644 --- a/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm +++ b/samples/client/petstore/perl/lib/WWW/SwaggerClient/Role.pm @@ -37,7 +37,7 @@ has version_info => ( is => 'ro', default => sub { { app_name => 'Swagger Petstore', app_version => '1.0.0', - generated_date => '2016-01-15T15:57:32.150+08:00', + generated_date => '2016-01-17T19:21:19.346+08:00', generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen', } }, documentation => 'Information about the application version and the codegen codebase version' @@ -103,7 +103,7 @@ Automatically generated by the Perl Swagger Codegen project: =over 4 -=item Build date: 2016-01-15T15:57:32.150+08:00 +=item Build date: 2016-01-17T19:21:19.346+08:00 =item Build package: class io.swagger.codegen.languages.PerlClientCodegen diff --git a/samples/client/petstore/perl/t/04_role.t b/samples/client/petstore/perl/t/04_role.t index 73328fa6e6..a5f47ec53c 100644 --- a/samples/client/petstore/perl/t/04_role.t +++ b/samples/client/petstore/perl/t/04_role.t @@ -50,7 +50,7 @@ is $get_pet->tags->[0]->id, '11', 'stored and retrieved: got the proper tag id'; # API method docs is_deeply( [sort keys %{$api->pet_api->method_documentation}], - [ 'add_pet', 'delete_pet', 'find_pets_by_status', 'find_pets_by_tags', 'get_pet_by_id', 'update_pet', 'update_pet_with_form', 'upload_file'], + [ 'add_pet', 'add_pet_using_byte_array', 'delete_pet', 'find_pets_by_status', 'find_pets_by_tags', 'get_pet_by_id', 'get_pet_by_id_with_byte_array', 'update_pet', 'update_pet_with_form', 'upload_file'], "Pet API method_documentation has the correct keys"); is $api->pet_api->method_documentation->{get_pet_by_id}->{params}->{pet_id}->{description}, 'ID of pet that needs to be fetched', 'get_pet_by_id parameter pet_id description is correct'; diff --git a/samples/client/petstore/python/.coverage b/samples/client/petstore/python/.coverage index 9921d07556..4cd98e43d2 100644 --- a/samples/client/petstore/python/.coverage +++ b/samples/client/petstore/python/.coverage @@ -1 +1 @@ -!coverage.py: This is a private format, don't read it directly!{"lines": {"/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/python/swagger_client/models/user.py": [278, 70, 136, 202, 272, 81, 147, 213, 22, 25, 92, 29, 158, 224, 103, 169, 235, 284, 114, 19, 180, 30, 246, 266, 191, 125, 21], "/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/python/swagger_client/models/category.py": [128, 134, 72, 74, 109, 19, 21, 22, 104, 25, 29, 30, 96, 100, 114, 102, 39, 40, 41, 103, 44, 45, 46, 112, 49, 50, 83, 116, 94, 52, 122, 61, 85, 63], "/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/python/swagger_client/models/order.py": [130, 172, 141, 173, 19, 21, 22, 152, 25, 29, 30, 52, 161, 163, 39, 40, 41, 42, 43, 44, 45, 174, 175, 48, 49, 50, 51, 180, 53, 54, 57, 58, 59, 60, 61, 62, 191, 64, 202, 75, 86, 176, 222, 97, 228, 178, 234, 108, 240, 119], "/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/python/swagger_client/apis/__init__.py": [1, 4, 5, 6], "/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/python/swagger_client/apis/pet_api.py": [512, 513, 514, 516, 598, 18, 20, 22, 23, 26, 539, 28, 29, 542, 543, 32, 548, 37, 39, 40, 41, 42, 555, 556, 45, 558, 559, 560, 562, 564, 565, 566, 265, 568, 569, 345, 571, 574, 575, 576, 580, 581, 70, 584, 73, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 86, 88, 90, 92, 93, 95, 96, 97, 100, 101, 102, 106, 107, 621, 622, 624, 625, 626, 115, 116, 117, 118, 631, 632, 121, 122, 635, 124, 638, 639, 669, 641, 642, 643, 645, 647, 649, 650, 651, 652, 653, 654, 656, 145, 146, 659, 148, 661, 150, 665, 666, 155, 156, 538, 159, 160, 673, 162, 675, 676, 677, 166, 679, 168, 169, 171, 172, 173, 541, 176, 177, 178, 182, 183, 186, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 200, 119, 120, 377, 221, 222, 549, 224, 225, 226, 231, 232, 235, 236, 110, 238, 240, 552, 242, 244, 246, 247, 249, 383, 252, 253, 254, 258, 259, 262, 264, 44, 266, 267, 268, 269, 270, 271, 272, 273, 274, 276, 46, 48, 475, 112, 298, 300, 301, 302, 307, 308, 311, 312, 314, 316, 317, 318, 320, 322, 505, 325, 113, 328, 329, 330, 334, 335, 338, 340, 341, 342, 343, 344, 241, 346, 347, 348, 349, 350, 485, 352, 114, 373, 374, 376, 660, 378, 149, 384, 387, 390, 391, 393, 394, 395, 397, 399, 401, 402, 323, 404, 407, 408, 409, 297, 413, 414, 69, 417, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 431, 72, 499, 671, 74, 672, 454, 455, 457, 458, 459, 674, 464, 465, 468, 471, 472, 164, 474, 79, 476, 478, 480, 80, 482, 483, 484, 678, 486, 487, 489, 492, 493, 494, 680, 498, 83, 502, 681, 504, 84, 506, 507, 508, 509, 510, 511], "/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/python/swagger_client/configuration.py": [135, 136, 137, 138, 139, 142, 19, 149, 22, 23, 25, 26, 27, 29, 158, 31, 32, 34, 36, 37, 39, 40, 41, 170, 43, 172, 46, 47, 189, 179, 52, 54, 59, 61, 190, 63, 192, 224, 67, 69, 71, 200, 73, 204, 80, 81, 82, 84, 213, 86, 199, 88, 90, 219, 92, 221, 222, 223, 96, 225, 98, 100, 102, 230, 104, 167, 111, 76, 168, 157, 122, 123, 42, 21], "/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/python/swagger_client/apis/user_api.py": [32, 355, 37, 39, 200, 124, 428, 589, 48, 18, 20, 22, 23, 276, 26, 507, 28, 29], "/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/python/swagger_client/rest.py": [20, 21, 23, 24, 25, 26, 27, 28, 31, 33, 35, 36, 40, 42, 48, 51, 53, 54, 55, 56, 57, 59, 63, 65, 72, 74, 82, 83, 88, 92, 95, 98, 101, 102, 103, 104, 105, 106, 109, 110, 121, 122, 124, 129, 130, 132, 135, 137, 138, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 152, 153, 154, 155, 156, 159, 160, 161, 166, 170, 171, 174, 176, 177, 179, 181, 182, 183, 184, 186, 191, 198, 199, 200, 201, 203, 204, 205, 206, 207, 208, 210, 211, 212, 213, 214, 215, 217, 225, 227, 228, 229, 230, 231, 232, 239, 243, 244, 245, 246, 248, 249, 251], "/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/python/swagger_client/apis/store_api.py": [18, 276, 22, 23, 26, 28, 29, 197, 32, 37, 39, 40, 41, 44, 46, 48, 20, 68, 69, 71, 72, 79, 82, 83, 85, 87, 89, 91, 92, 94, 97, 98, 99, 103, 104, 107, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 121], "/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/python/swagger_client/models/pet.py": [128, 130, 150, 172, 139, 141, 19, 215, 21, 22, 152, 25, 29, 30, 161, 163, 39, 40, 41, 42, 43, 44, 45, 174, 48, 49, 50, 51, 52, 53, 54, 183, 57, 58, 59, 60, 61, 62, 64, 194, 195, 200, 73, 202, 75, 206, 208, 209, 210, 211, 84, 213, 86, 185, 216, 218, 220, 222, 95, 97, 226, 228, 234, 108, 238, 240, 117, 119, 212, 106], "/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/python/swagger_client/api_client.py": [512, 520, 527, 528, 529, 19, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 37, 550, 40, 42, 44, 560, 49, 52, 568, 570, 571, 572, 573, 574, 575, 577, 68, 69, 74, 75, 76, 78, 79, 81, 82, 84, 86, 93, 98, 100, 104, 105, 106, 109, 110, 111, 113, 114, 117, 118, 119, 120, 121, 122, 125, 126, 127, 128, 131, 132, 133, 136, 139, 140, 143, 146, 147, 148, 149, 151, 154, 155, 157, 159, 160, 162, 539, 164, 173, 174, 176, 178, 193, 194, 196, 197, 198, 199, 200, 201, 202, 203, 204, 206, 207, 214, 215, 216, 548, 218, 219, 221, 549, 233, 237, 238, 242, 244, 253, 254, 256, 257, 258, 259, 260, 262, 263, 264, 265, 269, 270, 271, 274, 276, 277, 278, 280, 281, 282, 283, 285, 288, 289, 290, 318, 319, 320, 321, 322, 324, 325, 326, 327, 328, 329, 330, 331, 332, 334, 335, 339, 340, 341, 342, 343, 347, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 371, 372, 373, 374, 381, 389, 391, 392, 394, 395, 396, 397, 399, 400, 401, 402, 403, 404, 406, 408, 415, 416, 418, 420, 421, 423, 425, 432, 433, 435, 437, 438, 440, 442, 450, 452, 455, 456, 457, 458, 460, 461, 469, 495, 504, 505, 510], "/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/python/swagger_client/models/tag.py": [128, 132, 134, 72, 74, 109, 19, 21, 22, 104, 25, 29, 30, 96, 100, 114, 102, 39, 40, 41, 103, 44, 45, 46, 112, 49, 50, 83, 116, 94, 52, 122, 61, 85, 63], "/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/python/swagger_client/__init__.py": [1, 4, 5, 6, 7, 8, 11, 12, 13, 16, 18, 20], "/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/python/swagger_client/models/__init__.py": [1, 4, 5, 6, 7, 8]}} \ No newline at end of file +!coverage.py: This is a private format, don't read it directly!{"lines": {"/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/apis/pet_api.py": [512, 513, 514, 683, 516, 86, 18, 20, 22, 23, 26, 539, 28, 29, 542, 543, 32, 548, 37, 39, 40, 41, 42, 555, 556, 45, 558, 559, 560, 562, 564, 565, 566, 265, 568, 569, 571, 574, 575, 576, 580, 581, 70, 584, 73, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 598, 88, 90, 92, 93, 95, 96, 97, 100, 101, 102, 106, 107, 621, 622, 624, 625, 626, 79, 116, 117, 118, 631, 632, 121, 122, 635, 124, 638, 639, 641, 642, 643, 645, 647, 649, 650, 651, 652, 653, 654, 656, 145, 146, 659, 148, 661, 150, 665, 666, 155, 156, 538, 159, 160, 673, 162, 675, 164, 677, 166, 679, 168, 169, 171, 172, 173, 541, 176, 177, 178, 115, 182, 183, 186, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 200, 119, 120, 377, 221, 222, 549, 224, 225, 226, 231, 232, 431, 235, 236, 110, 238, 240, 552, 242, 244, 246, 247, 249, 762, 383, 252, 253, 254, 258, 259, 262, 264, 44, 266, 267, 268, 269, 270, 271, 272, 273, 274, 276, 46, 48, 297, 298, 300, 301, 302, 307, 308, 311, 312, 314, 316, 317, 318, 320, 322, 323, 325, 113, 328, 329, 330, 334, 335, 338, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 485, 352, 84, 114, 373, 374, 376, 660, 378, 149, 384, 387, 390, 391, 393, 394, 395, 397, 399, 401, 402, 404, 407, 408, 409, 413, 414, 69, 417, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 669, 72, 241, 671, 74, 672, 83, 454, 455, 457, 458, 459, 674, 112, 464, 465, 468, 471, 472, 676, 474, 475, 476, 478, 480, 80, 482, 483, 484, 678, 486, 487, 489, 492, 493, 494, 680, 498, 499, 502, 681, 504, 505, 506, 507, 508, 509, 510, 511], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/models/category.py": [128, 134, 72, 74, 109, 19, 21, 22, 104, 25, 29, 30, 96, 100, 114, 102, 39, 40, 41, 103, 44, 45, 46, 112, 49, 50, 83, 116, 94, 52, 122, 61, 85, 63], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/models/tag.py": [128, 132, 134, 72, 74, 109, 19, 21, 22, 104, 25, 29, 30, 96, 100, 114, 102, 39, 40, 41, 103, 44, 45, 46, 112, 49, 50, 83, 116, 94, 52, 122, 61, 85, 63], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/__init__.py": [1, 4, 5, 6, 7, 8, 11, 12, 13, 16, 18, 20], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/models/pet.py": [128, 130, 150, 172, 139, 141, 19, 215, 21, 22, 152, 25, 29, 30, 161, 163, 39, 40, 41, 42, 43, 44, 45, 174, 48, 49, 50, 51, 52, 53, 54, 183, 57, 58, 59, 60, 61, 62, 64, 194, 195, 200, 73, 202, 75, 206, 208, 209, 210, 211, 84, 213, 86, 185, 216, 218, 220, 222, 95, 97, 226, 228, 234, 108, 238, 240, 117, 119, 212, 106], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/configuration.py": [135, 136, 137, 138, 139, 142, 19, 149, 22, 23, 25, 26, 27, 29, 158, 31, 32, 34, 36, 37, 39, 40, 41, 170, 43, 172, 46, 47, 189, 179, 52, 54, 59, 61, 190, 63, 192, 224, 67, 69, 71, 200, 73, 204, 80, 81, 82, 84, 213, 86, 199, 88, 90, 219, 92, 221, 222, 223, 96, 225, 98, 100, 102, 230, 104, 167, 111, 76, 168, 157, 122, 123, 42, 21], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/models/order.py": [130, 172, 141, 173, 19, 21, 22, 152, 25, 29, 30, 52, 161, 163, 39, 40, 41, 42, 43, 44, 45, 174, 175, 48, 49, 50, 51, 180, 53, 54, 57, 58, 59, 60, 61, 62, 191, 64, 202, 75, 86, 176, 222, 97, 228, 178, 234, 108, 240, 119], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/api_client.py": [512, 520, 527, 528, 529, 19, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 37, 550, 40, 42, 44, 560, 49, 52, 568, 570, 571, 572, 573, 574, 575, 577, 68, 69, 74, 75, 76, 78, 79, 81, 82, 84, 86, 93, 98, 100, 104, 105, 106, 109, 110, 111, 113, 114, 117, 118, 119, 120, 121, 122, 125, 126, 127, 128, 131, 132, 133, 136, 139, 140, 143, 146, 147, 148, 149, 151, 154, 155, 157, 159, 160, 162, 539, 164, 173, 174, 176, 178, 193, 194, 196, 197, 198, 199, 200, 201, 202, 203, 204, 206, 207, 214, 215, 216, 548, 218, 219, 221, 549, 233, 237, 238, 242, 244, 253, 254, 256, 257, 258, 259, 260, 262, 263, 264, 265, 269, 270, 271, 274, 276, 277, 278, 280, 281, 282, 283, 285, 288, 289, 290, 318, 319, 320, 321, 322, 324, 325, 326, 327, 328, 329, 330, 331, 332, 334, 335, 339, 340, 341, 342, 343, 347, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 371, 372, 373, 374, 381, 389, 391, 392, 394, 395, 396, 397, 399, 400, 401, 402, 403, 404, 406, 408, 415, 416, 418, 420, 421, 423, 425, 432, 433, 435, 437, 438, 440, 442, 450, 452, 455, 456, 457, 458, 460, 461, 469, 495, 504, 505, 510], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/apis/__init__.py": [1, 4, 5, 6], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/apis/store_api.py": [18, 276, 22, 23, 26, 28, 29, 197, 32, 37, 39, 40, 41, 44, 46, 48, 20, 68, 69, 71, 72, 79, 82, 83, 85, 87, 89, 91, 92, 94, 97, 98, 99, 103, 104, 107, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 121], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/models/user.py": [278, 70, 136, 202, 272, 81, 147, 213, 22, 25, 92, 29, 158, 224, 103, 169, 235, 284, 114, 19, 180, 30, 246, 266, 191, 125, 21], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/apis/user_api.py": [32, 355, 37, 39, 200, 124, 428, 589, 48, 18, 20, 22, 23, 276, 26, 507, 28, 29], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/models/__init__.py": [1, 4, 5, 6, 7, 8], "/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/python/swagger_client/rest.py": [20, 21, 23, 24, 25, 26, 27, 28, 31, 33, 35, 36, 40, 42, 48, 51, 53, 54, 55, 56, 57, 59, 63, 65, 72, 74, 82, 83, 88, 92, 95, 98, 101, 102, 103, 104, 105, 106, 109, 110, 121, 122, 124, 129, 130, 132, 135, 137, 138, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 152, 153, 154, 155, 156, 159, 160, 161, 166, 170, 171, 174, 176, 177, 179, 181, 182, 183, 184, 186, 191, 198, 199, 200, 201, 203, 204, 205, 206, 207, 208, 210, 211, 212, 213, 214, 215, 217, 225, 227, 228, 229, 230, 231, 232, 239, 243, 244, 245, 246, 248, 249, 251]}} \ No newline at end of file diff --git a/samples/client/petstore/python/dev-requirements.txt.log b/samples/client/petstore/python/dev-requirements.txt.log index 28a3909b9e..3418ab244d 100644 --- a/samples/client/petstore/python/dev-requirements.txt.log +++ b/samples/client/petstore/python/dev-requirements.txt.log @@ -146,3 +146,18 @@ Requirement already satisfied (use --upgrade to upgrade): randomize in /private/ Requirement already satisfied (use --upgrade to upgrade): virtualenv>=1.11.2 in /private/var/tmp/pr/Tengah/swagger-codegen/samples/client/petstore/python/venv/lib/python2.7/site-packages (from tox->-r dev-requirements.txt (line 2)) Requirement already satisfied (use --upgrade to upgrade): py>=1.4.17 in /private/var/tmp/pr/Tengah/swagger-codegen/samples/client/petstore/python/venv/lib/python2.7/site-packages (from tox->-r dev-requirements.txt (line 2)) Requirement already satisfied (use --upgrade to upgrade): pluggy<0.4.0,>=0.3.0 in /private/var/tmp/pr/Tengah/swagger-codegen/samples/client/petstore/python/venv/lib/python2.7/site-packages (from tox->-r dev-requirements.txt (line 2)) +Collecting nose (from -r dev-requirements.txt (line 1)) + Using cached nose-1.3.7-py2-none-any.whl +Collecting tox (from -r dev-requirements.txt (line 2)) + Using cached tox-2.3.1-py2.py3-none-any.whl +Collecting coverage (from -r dev-requirements.txt (line 3)) +Collecting randomize (from -r dev-requirements.txt (line 4)) + Using cached randomize-0.13-py2.py3-none-any.whl +Collecting virtualenv>=1.11.2 (from tox->-r dev-requirements.txt (line 2)) + Using cached virtualenv-13.1.2-py2.py3-none-any.whl +Collecting py>=1.4.17 (from tox->-r dev-requirements.txt (line 2)) + Using cached py-1.4.31-py2.py3-none-any.whl +Collecting pluggy<0.4.0,>=0.3.0 (from tox->-r dev-requirements.txt (line 2)) + Using cached pluggy-0.3.1-py2.py3-none-any.whl +Installing collected packages: nose, virtualenv, py, pluggy, tox, coverage, randomize +Successfully installed coverage-4.0.3 nose-1.3.7 pluggy-0.3.1 py-1.4.31 randomize-0.13 tox-2.3.1 virtualenv-13.1.2 diff --git a/samples/client/petstore/python/swagger_client/apis/pet_api.py b/samples/client/petstore/python/swagger_client/apis/pet_api.py index 8e50474658..c3171760dd 100644 --- a/samples/client/petstore/python/swagger_client/apis/pet_api.py +++ b/samples/client/petstore/python/swagger_client/apis/pet_api.py @@ -679,3 +679,158 @@ class PetApi(object): auth_settings=auth_settings, callback=params.get('callback')) return response + + def get_pet_by_id_with_byte_array(self, pet_id, **kwargs): + """ + Fake endpoint to test byte array return by 'Find pet by ID' + Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.get_pet_by_id_with_byte_array(pet_id, callback=callback_function) + + :param callback function: The callback function + for asynchronous request. (optional) + :param int pet_id: ID of pet that needs to be fetched (required) + :return: Binary + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['pet_id'] + all_params.append('callback') + + params = locals() + for key, val in iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method get_pet_by_id_with_byte_array" % key + ) + params[key] = val + del params['kwargs'] + + # verify the required parameter 'pet_id' is set + if ('pet_id' not in params) or (params['pet_id'] is None): + raise ValueError("Missing the required parameter `pet_id` when calling `get_pet_by_id_with_byte_array`") + + resource_path = '/pet/{petId}?testing_byte_array=true'.replace('{format}', 'json') + method = 'GET' + + path_params = {} + if 'pet_id' in params: + path_params['petId'] = params['pet_id'] + + query_params = {} + + header_params = {} + + form_params = {} + files = {} + + body_params = None + + # HTTP header `Accept` + header_params['Accept'] = self.api_client.\ + select_header_accept(['application/json', 'application/xml']) + if not header_params['Accept']: + del header_params['Accept'] + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.\ + select_header_content_type([]) + + # Authentication setting + auth_settings = ['api_key'] + + response = self.api_client.call_api(resource_path, method, + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=files, + response_type='Binary', + auth_settings=auth_settings, + callback=params.get('callback')) + return response + + def add_pet_using_byte_array(self, **kwargs): + """ + Fake endpoint to test byte array in body parameter for adding a new pet to the store + + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please define a `callback` function + to be invoked when receiving the response. + >>> def callback_function(response): + >>> pprint(response) + >>> + >>> thread = api.add_pet_using_byte_array(callback=callback_function) + + :param callback function: The callback function + for asynchronous request. (optional) + :param Binary body: Pet object in the form of byte array + :return: None + If the method is called asynchronously, + returns the request thread. + """ + + all_params = ['body'] + all_params.append('callback') + + params = locals() + for key, val in iteritems(params['kwargs']): + if key not in all_params: + raise TypeError( + "Got an unexpected keyword argument '%s'" + " to method add_pet_using_byte_array" % key + ) + params[key] = val + del params['kwargs'] + + + resource_path = '/pet?testing_byte_array=true'.replace('{format}', 'json') + method = 'POST' + + path_params = {} + + query_params = {} + + header_params = {} + + form_params = {} + files = {} + + body_params = None + if 'body' in params: + body_params = params['body'] + + # HTTP header `Accept` + header_params['Accept'] = self.api_client.\ + select_header_accept(['application/json', 'application/xml']) + if not header_params['Accept']: + del header_params['Accept'] + + # HTTP header `Content-Type` + header_params['Content-Type'] = self.api_client.\ + select_header_content_type(['application/json', 'application/xml']) + + # Authentication setting + auth_settings = ['petstore_auth'] + + response = self.api_client.call_api(resource_path, method, + path_params, + query_params, + header_params, + body=body_params, + post_params=form_params, + files=files, + response_type=None, + auth_settings=auth_settings, + callback=params.get('callback')) + return response