Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ class {{classname}}(object):
if not set({{{name}}}).issubset(set(allowed_values)):
raise ValueError(
"Invalid values for `{{{name}}}` [{0}], must be a subset of [{1}]"
.format(", ".join(map(str, set({{{name}}})-set(allowed_values))),
.format(", ".join(map(str, set({{{name}}})-set(allowed_values))),
", ".join(map(str, allowed_values)))
)
{{/isListContainer}}
{{#isMapContainer}}
if not set({{{name}}}.keys()).issubset(set(allowed_values)):
raise ValueError(
"Invalid keys in `{{{name}}}` [{0}], must be a subset of [{1}]"
.format(", ".join(map(str, set({{{name}}}.keys())-set(allowed_values))),
.format(", ".join(map(str, set({{{name}}}.keys())-set(allowed_values))),
", ".join(map(str, allowed_values)))
)
{{/isMapContainer}}
Expand All @@ -89,9 +89,10 @@ class {{classname}}(object):
{{/isEnum}}
{{^isEnum}}
{{#hasValidation}}

if not {{name}}:
{{#required}}
if {{name}} is None:
raise ValueError("Invalid value for `{{name}}`, must not be `None`")
{{/required}}
{{#maxLength}}
if len({{name}}) > {{maxLength}}:
raise ValueError("Invalid value for `{{name}}`, length must be less than or equal to `{{maxLength}}`")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def array_enum(self, array_enum):
if not set(array_enum).issubset(set(allowed_values)):
raise ValueError(
"Invalid values for `array_enum` [{0}], must be a subset of [{1}]"
.format(", ".join(map(str, set(array_enum)-set(allowed_values))),
.format(", ".join(map(str, set(array_enum)-set(allowed_values))),
", ".join(map(str, allowed_values)))
)

Expand Down
17 changes: 0 additions & 17 deletions samples/client/petstore/python/petstore_api/models/format_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ def integer(self, integer):
:param integer: The integer of this FormatTest.
:type: int
"""

if not integer:
raise ValueError("Invalid value for `integer`, must not be `None`")
if integer > 100.0:
raise ValueError("Invalid value for `integer`, must be a value less than or equal to `100.0`")
if integer < 10.0:
Expand Down Expand Up @@ -138,9 +135,6 @@ def int32(self, int32):
:param int32: The int32 of this FormatTest.
:type: int
"""

if not int32:
raise ValueError("Invalid value for `int32`, must not be `None`")
if int32 > 200.0:
raise ValueError("Invalid value for `int32`, must be a value less than or equal to `200.0`")
if int32 < 20.0:
Expand Down Expand Up @@ -191,7 +185,6 @@ def number(self, number):
:param number: The number of this FormatTest.
:type: float
"""

if not number:
raise ValueError("Invalid value for `number`, must not be `None`")
if number > 543.2:
Expand Down Expand Up @@ -221,9 +214,6 @@ def float(self, float):
:param float: The float of this FormatTest.
:type: float
"""

if not float:
raise ValueError("Invalid value for `float`, must not be `None`")
if float > 987.6:
raise ValueError("Invalid value for `float`, must be a value less than or equal to `987.6`")
if float < 54.3:
Expand Down Expand Up @@ -251,9 +241,6 @@ def double(self, double):
:param double: The double of this FormatTest.
:type: float
"""

if not double:
raise ValueError("Invalid value for `double`, must not be `None`")
if double > 123.4:
raise ValueError("Invalid value for `double`, must be a value less than or equal to `123.4`")
if double < 67.8:
Expand Down Expand Up @@ -281,9 +268,6 @@ def string(self, string):
:param string: The string of this FormatTest.
:type: str
"""

if not string:
raise ValueError("Invalid value for `string`, must not be `None`")
if not re.search('[a-z]', string, flags=re.IGNORECASE):
raise ValueError("Invalid value for `string`, must be a follow pattern or equal to `/[a-z]/i`")

Expand Down Expand Up @@ -424,7 +408,6 @@ def password(self, password):
:param password: The password of this FormatTest.
:type: str
"""

if not password:
raise ValueError("Invalid value for `password`, must not be `None`")
if len(password) > 64:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def map_of_enum_string(self, map_of_enum_string):
if not set(map_of_enum_string.keys()).issubset(set(allowed_values)):
raise ValueError(
"Invalid keys in `map_of_enum_string` [{0}], must be a subset of [{1}]"
.format(", ".join(map(str, set(map_of_enum_string.keys())-set(allowed_values))),
.format(", ".join(map(str, set(map_of_enum_string.keys())-set(allowed_values))),
", ".join(map(str, allowed_values)))
)

Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/python/petstore_api/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def request(self, method, url, query_params=None, headers=None,
# Pass a `string` parameter directly in the body to support
# other content types than Json when `body` argument is provided
# in serialized form
elif isinstance(body, basestring):
elif isinstance(body, str):
request_body = body
r = self.pool_manager.request(method, url,
body=request_body,
Expand Down
4 changes: 3 additions & 1 deletion samples/client/petstore/ruby/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ opts = {
binary: "B", # String | None
date: Date.parse("2013-10-20"), # Date | None
date_time: DateTime.parse("2013-10-20T19:20:30+01:00"), # DateTime | None
password: "password_example" # String | None
password: "password_example", # String | None
callback: "callback_example" # String | None
}

begin
Expand Down Expand Up @@ -119,6 +120,7 @@ Name | Type | Description | Notes
**date** | **Date**| None | [optional]
**date_time** | **DateTime**| None | [optional]
**password** | **String**| None | [optional]
**callback** | **String**| None | [optional]

### Return type

Expand Down
3 changes: 3 additions & 0 deletions samples/client/petstore/ruby/lib/petstore/api/fake_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def test_client_model_with_http_info(body, opts = {})
# @option opts [Date] :date None
# @option opts [DateTime] :date_time None
# @option opts [String] :password None
# @option opts [String] :callback None
# @return [nil]
def test_endpoint_parameters(number, double, pattern_without_delimiter, byte, opts = {})
test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, opts)
Expand All @@ -126,6 +127,7 @@ def test_endpoint_parameters(number, double, pattern_without_delimiter, byte, op
# @option opts [Date] :date None
# @option opts [DateTime] :date_time None
# @option opts [String] :password None
# @option opts [String] :callback None
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, opts = {})
if @api_client.config.debugging
Expand Down Expand Up @@ -223,6 +225,7 @@ def test_endpoint_parameters_with_http_info(number, double, pattern_without_deli
form_params["date"] = opts[:'date'] if !opts[:'date'].nil?
form_params["dateTime"] = opts[:'date_time'] if !opts[:'date_time'].nil?
form_params["password"] = opts[:'password'] if !opts[:'password'].nil?
form_params["callback"] = opts[:'callback'] if !opts[:'callback'].nil?

# http body (model)
post_body = nil
Expand Down