diff --git a/README.md b/README.md index 33706464129..5ecc466d4c5 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` @@ -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) 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/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/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}}
-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/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/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/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/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 {
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:
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:
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
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;
+
-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 {