From 34f1e3614660f0771d3798eb34f464c04de0f057 Mon Sep 17 00:00:00 2001 From: Hamed Ramezanian Date: Thu, 13 Oct 2016 07:41:40 +0100 Subject: [PATCH 1/8] Sanitize tuples properly (#3949) * Sanitize tuples properly In Python, Tuples are fixed size in nature whereas lists are dynamic. So they should be sanitize as same as lists. Failure case here is when you have a query or post parameter as Datetime. * Update the Petstore sample * Skip file sanitization * Return tuple instead of list * Sanitize all tuples, no exceptions --- .../src/main/resources/python/api_client.mustache | 5 ++++- samples/client/petstore/python/petstore_api/api_client.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/python/api_client.mustache b/modules/swagger-codegen/src/main/resources/python/api_client.mustache index 3879b3cd706..0a5864a81af 100644 --- a/modules/swagger-codegen/src/main/resources/python/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api_client.mustache @@ -176,7 +176,7 @@ class ApiClient(object): :param obj: The data to serialize. :return: The serialized form of data. """ - types = (str, float, bool, tuple) + tuple(integer_types) + (text_type,) + types = (str, float, bool, bytes) + tuple(integer_types) + (text_type,) if isinstance(obj, type(None)): return None elif isinstance(obj, types): @@ -184,6 +184,9 @@ class ApiClient(object): elif isinstance(obj, list): return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj] + elif isinstance(obj, tuple): + return tuple(self.sanitize_for_serialization(sub_obj) + for sub_obj in obj) elif isinstance(obj, (datetime, date)): return obj.isoformat() else: diff --git a/samples/client/petstore/python/petstore_api/api_client.py b/samples/client/petstore/python/petstore_api/api_client.py index 2c8dc409135..adf66173dbc 100644 --- a/samples/client/petstore/python/petstore_api/api_client.py +++ b/samples/client/petstore/python/petstore_api/api_client.py @@ -176,7 +176,7 @@ class ApiClient(object): :param obj: The data to serialize. :return: The serialized form of data. """ - types = (str, float, bool, tuple) + tuple(integer_types) + (text_type,) + types = (str, float, bool, bytes) + tuple(integer_types) + (text_type,) if isinstance(obj, type(None)): return None elif isinstance(obj, types): @@ -184,6 +184,9 @@ class ApiClient(object): elif isinstance(obj, list): return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj] + elif isinstance(obj, tuple): + return tuple(self.sanitize_for_serialization(sub_obj) + for sub_obj in obj) elif isinstance(obj, (datetime, date)): return obj.isoformat() else: From d0f3cd642d01de18017c2a3d0b999c2337230219 Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 13 Oct 2016 15:28:11 +0800 Subject: [PATCH 2/8] fix missing () in python doc --- .../swagger-codegen/src/main/resources/python/README.mustache | 2 +- samples/client/petstore/python/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/python/README.mustache b/modules/swagger-codegen/src/main/resources/python/README.mustache index 9f592946b06..9f432447443 100644 --- a/modules/swagger-codegen/src/main/resources/python/README.mustache +++ b/modules/swagger-codegen/src/main/resources/python/README.mustache @@ -70,7 +70,7 @@ from pprint import pprint {{{packageName}}}.configuration.access_token = 'YOUR_ACCESS_TOKEN'{{/isOAuth}}{{/authMethods}} {{/hasAuthMethods}} # create an instance of the API class -api_instance = {{{packageName}}}.{{{classname}}} +api_instance = {{{packageName}}}.{{{classname}}}() {{#allParams}}{{paramName}} = {{{example}}} # {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} {{/allParams}} diff --git a/samples/client/petstore/python/README.md b/samples/client/petstore/python/README.md index ec654c5190e..7b29cebd534 100644 --- a/samples/client/petstore/python/README.md +++ b/samples/client/petstore/python/README.md @@ -51,7 +51,7 @@ import petstore_api from petstore_api.rest import ApiException from pprint import pprint # create an instance of the API class -api_instance = petstore_api.FakeApi +api_instance = petstore_api.FakeApi() body = petstore_api.Client() # Client | client model try: From 47c387470c12f6e3f69225e1ff95409dd117074e Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 13 Oct 2016 16:38:39 +0800 Subject: [PATCH 3/8] fix required prop check for ruby client --- .../resources/ruby/partial_model_generic.mustache | 4 ++-- .../petstore/ruby/lib/petstore/models/animal.rb | 4 ++++ .../client/petstore/ruby/lib/petstore/models/cat.rb | 4 ++++ .../client/petstore/ruby/lib/petstore/models/dog.rb | 4 ++++ .../ruby/lib/petstore/models/format_test.rb | 13 ++++++++----- .../petstore/ruby/lib/petstore/models/name.rb | 4 ++++ .../client/petstore/ruby/lib/petstore/models/pet.rb | 8 ++++++++ 7 files changed, 34 insertions(+), 7 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/ruby/partial_model_generic.mustache b/modules/swagger-codegen/src/main/resources/ruby/partial_model_generic.mustache index 20662ae9771..00a75b25396 100644 --- a/modules/swagger-codegen/src/main/resources/ruby/partial_model_generic.mustache +++ b/modules/swagger-codegen/src/main/resources/ruby/partial_model_generic.mustache @@ -78,13 +78,13 @@ def list_invalid_properties invalid_properties = Array.new {{#vars}} - {{#hasValidation}} {{#required}} if @{{{name}}}.nil? invalid_properties.push("invalid value for '{{{name}}}', {{{name}}} cannot be nil.") end - {{/required}} + {{/required}} + {{#hasValidation}} {{#maxLength}} if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.length > {{{maxLength}}} invalid_properties.push("invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}.") diff --git a/samples/client/petstore/ruby/lib/petstore/models/animal.rb b/samples/client/petstore/ruby/lib/petstore/models/animal.rb index 7dad66580fa..0e941aa2657 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/animal.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/animal.rb @@ -71,6 +71,10 @@ module Petstore # @return Array for valid properies with the reasons def list_invalid_properties invalid_properties = Array.new + if @class_name.nil? + invalid_properties.push("invalid value for 'class_name', class_name cannot be nil.") + end + return invalid_properties end diff --git a/samples/client/petstore/ruby/lib/petstore/models/cat.rb b/samples/client/petstore/ruby/lib/petstore/models/cat.rb index 7ed6e12ddd0..3d42282a5f4 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/cat.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/cat.rb @@ -79,6 +79,10 @@ module Petstore # @return Array for valid properies with the reasons def list_invalid_properties invalid_properties = Array.new + if @class_name.nil? + invalid_properties.push("invalid value for 'class_name', class_name cannot be nil.") + end + return invalid_properties end diff --git a/samples/client/petstore/ruby/lib/petstore/models/dog.rb b/samples/client/petstore/ruby/lib/petstore/models/dog.rb index 0e8a993caea..addfdcfec84 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/dog.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/dog.rb @@ -79,6 +79,10 @@ module Petstore # @return Array for valid properies with the reasons def list_invalid_properties invalid_properties = Array.new + if @class_name.nil? + invalid_properties.push("invalid value for 'class_name', class_name cannot be nil.") + end + return invalid_properties end diff --git a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb index f734b42b993..75b105e8678 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/format_test.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/format_test.rb @@ -157,7 +157,6 @@ module Petstore # @return Array for valid properies with the reasons def list_invalid_properties invalid_properties = Array.new - if !@integer.nil? && @integer > 100.0 invalid_properties.push("invalid value for 'integer', must be smaller than or equal to 100.0.") end @@ -166,7 +165,6 @@ module Petstore invalid_properties.push("invalid value for 'integer', must be greater than or equal to 10.0.") end - if !@int32.nil? && @int32 > 200.0 invalid_properties.push("invalid value for 'int32', must be smaller than or equal to 200.0.") end @@ -187,7 +185,6 @@ module Petstore invalid_properties.push("invalid value for 'number', must be greater than or equal to 32.1.") end - if !@float.nil? && @float > 987.6 invalid_properties.push("invalid value for 'float', must be smaller than or equal to 987.6.") end @@ -196,7 +193,6 @@ module Petstore invalid_properties.push("invalid value for 'float', must be greater than or equal to 54.3.") end - if !@double.nil? && @double > 123.4 invalid_properties.push("invalid value for 'double', must be smaller than or equal to 123.4.") end @@ -205,11 +201,18 @@ module Petstore invalid_properties.push("invalid value for 'double', must be greater than or equal to 67.8.") end - if !@string.nil? && @string !~ Regexp.new(/[a-z]/i) invalid_properties.push("invalid value for 'string', must conform to the pattern /[a-z]/i.") end + if @byte.nil? + invalid_properties.push("invalid value for 'byte', byte cannot be nil.") + end + + if @date.nil? + invalid_properties.push("invalid value for 'date', date cannot be nil.") + end + if @password.nil? invalid_properties.push("invalid value for 'password', password cannot be nil.") end diff --git a/samples/client/petstore/ruby/lib/petstore/models/name.rb b/samples/client/petstore/ruby/lib/petstore/models/name.rb index 27a37cdc19c..47b1319b638 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/name.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/name.rb @@ -85,6 +85,10 @@ module Petstore # @return Array for valid properies with the reasons def list_invalid_properties invalid_properties = Array.new + if @name.nil? + invalid_properties.push("invalid value for 'name', name cannot be nil.") + end + return invalid_properties end diff --git a/samples/client/petstore/ruby/lib/petstore/models/pet.rb b/samples/client/petstore/ruby/lib/petstore/models/pet.rb index 52191258d7a..18ad44b0830 100644 --- a/samples/client/petstore/ruby/lib/petstore/models/pet.rb +++ b/samples/client/petstore/ruby/lib/petstore/models/pet.rb @@ -127,6 +127,14 @@ module Petstore # @return Array for valid properies with the reasons def list_invalid_properties invalid_properties = Array.new + if @name.nil? + invalid_properties.push("invalid value for 'name', name cannot be nil.") + end + + if @photo_urls.nil? + invalid_properties.push("invalid value for 'photo_urls', photo_urls cannot be nil.") + end + return invalid_properties end From 4b0d58abfd4a93d4f526055132478694ad602184 Mon Sep 17 00:00:00 2001 From: wing328 Date: Thu, 13 Oct 2016 18:15:04 +0800 Subject: [PATCH 4/8] fix hasHeaderParams tag --- .../codegen/languages/ConfluenceWikiGenerator.java | 12 ++++++++++++ .../main/resources/confluenceWikiDocs/index.mustache | 6 +++--- .../src/main/resources/htmlDocs/index.mustache | 4 ++-- samples/documentation/cwiki/confluence-markup.txt | 4 +++- samples/html/index.html | 4 ++++ 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ConfluenceWikiGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ConfluenceWikiGenerator.java index 747dcdfd769..972721bcfa1 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ConfluenceWikiGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ConfluenceWikiGenerator.java @@ -92,4 +92,16 @@ public class ConfluenceWikiGenerator extends DefaultCodegen implements CodegenCo } return objs; } + + @Override + public String escapeQuotationMark(String input) { + // just return the original string + return input; + } + + @Override + public String escapeUnsafeCharacters(String input) { + // just return the original string + return input; + } } diff --git a/modules/swagger-codegen/src/main/resources/confluenceWikiDocs/index.mustache b/modules/swagger-codegen/src/main/resources/confluenceWikiDocs/index.mustache index 0a90ab4c549..28312bb4b74 100644 --- a/modules/swagger-codegen/src/main/resources/confluenceWikiDocs/index.mustache +++ b/modules/swagger-codegen/src/main/resources/confluenceWikiDocs/index.mustache @@ -32,12 +32,12 @@ h2. Endpoints {{/bodyParams}} {{/hasBodyParam}} - {{#hasHeaderParam}} + {{#hasHeaderParams}} h5. Header Parameters ||Name||Description||Required||Default||Pattern|| {{#headerParam}}{{>param}} {{/headerParam}} - {{/hasHeaderParam}} + {{/hasHeaderParams}} {{#hasQueryParams}} h5. Query Parameters @@ -91,4 +91,4 @@ h2. Models {{#vars}} |{{name}} |{{#isNotRequired}}(x){{/isNotRequired}} |{{datatype}} |{{description}} | {{/vars}} {{/model}} -{{/models}} \ No newline at end of file +{{/models}} diff --git a/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache b/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache index 466df75c41f..d3c2681bced 100644 --- a/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache +++ b/modules/swagger-codegen/src/main/resources/htmlDocs/index.mustache @@ -80,12 +80,12 @@ {{/hasBodyParam}} - {{#hasHeaderParam}} + {{#hasHeaderParams}}

Request headers

{{#headerParam}}{{>headerParam}}{{/headerParam}}
- {{/hasHeaderParam}} + {{/hasHeaderParams}} {{#hasQueryParams}}

Query parameters

diff --git a/samples/documentation/cwiki/confluence-markup.txt b/samples/documentation/cwiki/confluence-markup.txt index dcbba6877a7..83996a97de8 100644 --- a/samples/documentation/cwiki/confluence-markup.txt +++ b/samples/documentation/cwiki/confluence-markup.txt @@ -60,7 +60,9 @@ h2. Endpoints |petId |Pet id to delete |(/) | | | - + h5. Header Parameters + ||Name||Description||Required||Default||Pattern|| + diff --git a/samples/html/index.html b/samples/html/index.html index d83d25c03a5..425b46386d2 100644 --- a/samples/html/index.html +++ b/samples/html/index.html @@ -288,6 +288,10 @@ font-style: italic; +

Request headers

+
+ +
From e101d22bc3d35d4622bcf7b295a28befba0e23fc Mon Sep 17 00:00:00 2001 From: Radim Date: Thu, 13 Oct 2016 13:46:37 +0200 Subject: [PATCH 5/8] typo relesae -> release --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 33706464129..6546e9d8926 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,7 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ ``` (if you're on Windows, replace the last command with `java -jar modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l php -o c:\temp\php_api_client`) -You can also download the JAR (latest relesae) directly from [maven.org](http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.2.1/swagger-codegen-cli-2.2.1.jar ) +You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.2.1/swagger-codegen-cli-2.2.1.jar ) To get a list of **general** options available, please run `java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar help generate` From 7df89e6ff49412555d4efb987c5efdf07c3145aa Mon Sep 17 00:00:00 2001 From: feda12 Date: Thu, 13 Oct 2016 09:43:53 -0500 Subject: [PATCH 6/8] Added OrderCloud.io to list of companies using swagger-codegen (#3971) * Added OrderCloud.io to list of companies using swagger-codegen * Fixed alphabetical order for OrderCloud.io --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6546e9d8926..5ecc466d4c5 100644 --- a/README.md +++ b/README.md @@ -783,6 +783,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you - [nViso](http://www.nviso.ch/) - [Okiok](https://www.okiok.com) - [Onedata](http://onedata.org) +- [OrderCloud.io](http://ordercloud.io) - [OSDN](https://osdn.jp) - [PagerDuty](https://www.pagerduty.com) - [Pepipost](https://www.pepipost.com) From 6199c5d1c36dc61fe9646ea65fcaf7aaafa35637 Mon Sep 17 00:00:00 2001 From: Brian Shamblen Date: Thu, 13 Oct 2016 18:22:08 -0700 Subject: [PATCH 7/8] Updates to html2 templates to use security headers in curl examples (#3987) * Fixes #3974 * Update petstore example for html2 --- .../src/main/resources/htmlDocs2/index.mustache | 2 +- samples/html2/index.html | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/htmlDocs2/index.mustache b/modules/swagger-codegen/src/main/resources/htmlDocs2/index.mustache index 4c3989dc1c2..c07ed7ca1e1 100644 --- a/modules/swagger-codegen/src/main/resources/htmlDocs2/index.mustache +++ b/modules/swagger-codegen/src/main/resources/htmlDocs2/index.mustache @@ -266,7 +266,7 @@ function loadGoogleFontCss() {

-curl -X {{httpMethod}}{{#isApiKey}} -H "apiKey: [[apiKey]]" -H "apiSecret: [[apiSecret]]"{{/isApiKey}} "{{basePath}}{{path}}{{#hasQueryParams}}?{{#queryParams}}{{^-first}}&{{/-first}}{{paramName}}={{vendorExtensions.x-eg}}{{/queryParams}}{{/hasQueryParams}}"
+curl -X {{httpMethod}}{{#authMethods}}{{#isApiKey}}{{#isKeyInHeader}} -H "{{keyParamName}}: [[apiKey]]" {{/isKeyInHeader}}{{/isApiKey}}{{#isBasic}} -H "Authorization: Basic [[basicHash]]" {{/isBasic}}{{/authMethods}} "{{basePath}}{{path}}{{#hasQueryParams}}?{{#queryParams}}{{^-first}}&{{/-first}}{{paramName}}={{vendorExtensions.x-eg}}{{/queryParams}}{{/hasQueryParams}}"
 
 
 
diff --git a/samples/html2/index.html b/samples/html2/index.html index 86b9fa7313e..38c4970ed5e 100644 --- a/samples/html2/index.html +++ b/samples/html2/index.html @@ -2834,7 +2834,7 @@ try {

-curl -X get "http://petstore.swagger.io/v2/pet/{petId}"
+curl -X get -H "api_key: [[apiKey]]"  "http://petstore.swagger.io/v2/pet/{petId}"
 
 
 
@@ -5195,7 +5195,7 @@ try {

-curl -X get "http://petstore.swagger.io/v2/store/inventory"
+curl -X get -H "api_key: [[apiKey]]"  "http://petstore.swagger.io/v2/store/inventory"
 
 
 
@@ -9921,7 +9921,7 @@ try {
- Generated 2016-09-29T11:08:44.942+08:00 + Generated 2016-10-13T09:03:51.792-07:00
From 03ed192b98534e8fcfb85a4f6613cc746d1d1295 Mon Sep 17 00:00:00 2001 From: wing328 Date: Fri, 14 Oct 2016 11:12:37 +0800 Subject: [PATCH 8/8] [Android] fix URL encoding for Android API client (#3992) * fix url encoding for android * add exception handling for url encoding in android --- .../src/main/resources/android/apiInvoker.mustache | 10 +++++++--- .../android/libraries/volley/apiInvoker.mustache | 7 ++++++- .../src/main/java/io/swagger/client/ApiInvoker.java | 10 +++++++--- .../src/main/java/io/swagger/client/ApiInvoker.java | 7 ++++++- 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/android/apiInvoker.mustache b/modules/swagger-codegen/src/main/resources/android/apiInvoker.mustache index 0b3f24c9f0b..0dac1bb8f59 100644 --- a/modules/swagger-codegen/src/main/resources/android/apiInvoker.mustache +++ b/modules/swagger-codegen/src/main/resources/android/apiInvoker.mustache @@ -16,6 +16,8 @@ import org.apache.http.params.*; import org.apache.http.util.EntityUtils; import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.net.Socket; import java.net.UnknownHostException; import java.net.URLEncoder; @@ -25,8 +27,6 @@ import java.util.Map; import java.util.HashMap; import java.util.List; import java.util.ArrayList; -import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.security.GeneralSecurityException; import java.security.KeyManagementException; @@ -207,7 +207,11 @@ public class ApiInvoker { } public String escapeString(String str) { - return str; + try { + return URLEncoder.encode(str, "UTF-8"); + } catch (UnsupportedEncodingException e) { + return str; + } } public static Object deserialize(String json, String containerType, Class cls) throws ApiException { diff --git a/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiInvoker.mustache b/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiInvoker.mustache index e40f4c04124..d57d8bb058f 100644 --- a/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiInvoker.mustache +++ b/modules/swagger-codegen/src/main/resources/android/libraries/volley/apiInvoker.mustache @@ -20,6 +20,7 @@ import org.apache.http.HttpEntity; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; +import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -232,7 +233,11 @@ public class ApiInvoker { } public String escapeString(String str) { - return str; + try { + return URLEncoder.encode(str, "UTF-8"); + } catch (UnsupportedEncodingException e) { + return str; + } } public static Object deserialize(String json, String containerType, Class cls) throws ApiException { diff --git a/samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/ApiInvoker.java b/samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/ApiInvoker.java index 24f5a129780..7118a48d50e 100644 --- a/samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/ApiInvoker.java +++ b/samples/client/petstore/android/httpclient/src/main/java/io/swagger/client/ApiInvoker.java @@ -39,6 +39,8 @@ import org.apache.http.params.*; import org.apache.http.util.EntityUtils; import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.net.Socket; import java.net.UnknownHostException; import java.net.URLEncoder; @@ -48,8 +50,6 @@ import java.util.Map; import java.util.HashMap; import java.util.List; import java.util.ArrayList; -import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.security.GeneralSecurityException; import java.security.KeyManagementException; @@ -230,7 +230,11 @@ public class ApiInvoker { } public String escapeString(String str) { - return str; + try { + return URLEncoder.encode(str, "UTF-8"); + } catch (UnsupportedEncodingException e) { + return str; + } } public static Object deserialize(String json, String containerType, Class cls) throws ApiException { diff --git a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiInvoker.java b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiInvoker.java index 158209c4be2..e1e32e370a3 100644 --- a/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiInvoker.java +++ b/samples/client/petstore/android/volley/src/main/java/io/swagger/client/ApiInvoker.java @@ -43,6 +43,7 @@ import org.apache.http.HttpEntity; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; +import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -246,7 +247,11 @@ public class ApiInvoker { } public String escapeString(String str) { - return str; + try { + return URLEncoder.encode(str, "UTF-8"); + } catch (UnsupportedEncodingException e) { + return str; + } } public static Object deserialize(String json, String containerType, Class cls) throws ApiException {