Merge branch 'scottrw93-validation'

This commit is contained in:
wing328 2016-05-09 11:03:46 +08:00
commit caea3876b5
23 changed files with 285 additions and 6 deletions

View File

@ -3,15 +3,21 @@ package io.swagger.codegen.languages;
import io.swagger.codegen.CliOption; import io.swagger.codegen.CliOption;
import io.swagger.codegen.CodegenConfig; import io.swagger.codegen.CodegenConfig;
import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.CodegenModel;
import io.swagger.codegen.CodegenParameter; import io.swagger.codegen.CodegenParameter;
import io.swagger.codegen.CodegenProperty;
import io.swagger.codegen.CodegenType; import io.swagger.codegen.CodegenType;
import io.swagger.codegen.DefaultCodegen; import io.swagger.codegen.DefaultCodegen;
import io.swagger.codegen.SupportingFile; import io.swagger.codegen.SupportingFile;
import io.swagger.models.properties.*; import io.swagger.models.properties.*;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@ -21,6 +27,8 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
protected String apiDocPath = "docs/"; protected String apiDocPath = "docs/";
protected String modelDocPath = "docs/"; protected String modelDocPath = "docs/";
protected Map<Character, String> regexModifiers;
private String testFolder; private String testFolder;
public PythonClientCodegen() { public PythonClientCodegen() {
@ -87,6 +95,14 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
"assert", "else", "if", "pass", "yield", "break", "except", "import", "assert", "else", "if", "pass", "yield", "break", "except", "import",
"print", "class", "exec", "in", "raise", "continue", "finally", "is", "print", "class", "exec", "in", "raise", "continue", "finally", "is",
"return", "def", "for", "lambda", "try", "self")); "return", "def", "for", "lambda", "try", "self"));
regexModifiers = new HashMap<Character, String>();
regexModifiers.put('i', "IGNORECASE");
regexModifiers.put('l', "LOCALE");
regexModifiers.put('m', "MULTILINE");
regexModifiers.put('s', "DOTALL");
regexModifiers.put('u', "UNICODE");
regexModifiers.put('x', "VERBOSE");
cliOptions.clear(); cliOptions.clear();
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "python package name (convention: snake_case).") cliOptions.add(new CliOption(CodegenConstants.PACKAGE_NAME, "python package name (convention: snake_case).")
@ -143,6 +159,46 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
private static String dropDots(String str) { private static String dropDots(String str) {
return str.replaceAll("\\.", "_"); return str.replaceAll("\\.", "_");
} }
@Override
public void postProcessParameter(CodegenParameter parameter){
postProcessPattern(parameter.pattern, parameter.vendorExtensions);
}
@Override
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
postProcessPattern(property.pattern, property.vendorExtensions);
}
/*
* The swagger pattern spec follows the Perl convention and style of modifiers. Python
* does not support this in as natural a way so it needs to convert it. See
* https://docs.python.org/2/howto/regex.html#compilation-flags for details.
*/
public void postProcessPattern(String pattern, Map<String, Object> vendorExtensions){
if(pattern != null) {
int i = pattern.lastIndexOf('/');
//Must follow Perl /pattern/modifiers convention
if(pattern.charAt(0) != '/' || i < 2) {
throw new IllegalArgumentException("Pattern must follow the Perl "
+ "/pattern/modifiers convention. "+pattern+" is not valid.");
}
String regex = pattern.substring(1, i).replace("'", "\'");
List<String> modifiers = new ArrayList<String>();
for(char c : pattern.substring(i).toCharArray()) {
if(regexModifiers.containsKey(c)) {
String modifier = regexModifiers.get(c);
modifiers.add(modifier);
}
}
vendorExtensions.put("x-regex", regex);
vendorExtensions.put("x-modifiers", modifiers);
}
}
@Override @Override
public CodegenType getTag() { public CodegenType getTag() {

View File

@ -21,6 +21,7 @@ from __future__ import absolute_import
import sys import sys
import os import os
import re
# python 2 and python 3 compatibility library # python 2 and python 3 compatibility library
from six import iteritems from six import iteritems
@ -94,6 +95,31 @@ class {{classname}}(object):
if ('{{paramName}}' not in params) or (params['{{paramName}}'] is None): if ('{{paramName}}' not in params) or (params['{{paramName}}'] is None):
raise ValueError("Missing the required parameter `{{paramName}}` when calling `{{operationId}}`") raise ValueError("Missing the required parameter `{{paramName}}` when calling `{{operationId}}`")
{{/required}} {{/required}}
{{/allParams}}
{{#allParams}}
{{#hasValidation}}
{{#maxLength}}
if '{{paramName}}' in params and len(params['{{paramName}}']) > {{maxLength}}:
raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be less than or equal to `{{maxLength}}`")
{{/maxLength}}
{{#minLength}}
if '{{paramName}}' in params and len(params['{{paramName}}']) < {{minLength}}:
raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, length must be greater than or equal to `{{minLength}}`")
{{/minLength}}
{{#maximum}}
if '{{paramName}}' in params and params['{{paramName}}'] > {{maximum}}:
raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value less than or equal to `{{maximum}}`")
{{/maximum}}
{{#minimum}}
if '{{paramName}}' in params and params['{{paramName}}'] < {{minimum}}:
raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must be a value greater than or equal to `{{minimum}}`")
{{/minimum}}
{{#pattern}}
if '{{paramName}}' in params and not re.search('{{vendorExtensions.x-regex}}', params['{{paramName}}']{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}):
raise ValueError("Invalid value for parameter `{{paramName}}` when calling `{{operationId}}`, must conform to the pattern `{{pattern}}`")
{{/pattern}}
{{/hasValidation}}
{{/allParams}} {{/allParams}}
resource_path = '{{path}}'.replace('{format}', 'json') resource_path = '{{path}}'.replace('{format}', 'json')

View File

@ -22,6 +22,7 @@ Copyright 2016 SmartBear Software
{{#model}} {{#model}}
from pprint import pformat from pprint import pformat
from six import iteritems from six import iteritems
import re
class {{classname}}(object): class {{classname}}(object):
@ -79,7 +80,36 @@ class {{classname}}(object):
"Invalid value for `{{name}}`, must be one of {0}" "Invalid value for `{{name}}`, must be one of {0}"
.format(allowed_values) .format(allowed_values)
) )
{{/isEnum}}self._{{name}} = {{name}} {{/isEnum}}
{{^isEnum}}
{{#hasValidation}}
if not {{name}}:
raise ValueError("Invalid value for `{{name}}`, must not be `None`")
{{#maxLength}}
if len({{name}}) > {{maxLength}}:
raise ValueError("Invalid value for `{{name}}`, length must be less than `{{maxLength}}`")
{{/maxLength}}
{{#minLength}}
if len({{name}}) < {{minLength}}:
raise ValueError("Invalid value for `{{name}}`, length must be greater than or equal to `{{minLength}}`")
{{/minLength}}
{{#maximum}}
if {{name}} > {{maximum}}:
raise ValueError("Invalid value for `{{name}}`, must be a value less than or equal to `{{maximum}}`")
{{/maximum}}
{{#minimum}}
if {{name}} < {{minimum}}:
raise ValueError("Invalid value for `{{name}}`, must be a value greater than or equal to `{{minimum}}`")
{{/minimum}}
{{#pattern}}
if not re.search('{{vendorExtensions.x-regex}}', {{name}}{{#vendorExtensions.x-modifiers}}{{#-first}}, flags={{/-first}}re.{{.}}{{^-last}} | {{/-last}}{{/vendorExtensions.x-modifiers}}):
raise ValueError("Invalid value for `{{name}}`, must be a follow pattern or equal to `{{pattern}}`")
{{/pattern}}
{{/hasValidation}}
{{/isEnum}}
self._{{name}} = {{name}}
{{/vars}} {{/vars}}
def to_dict(self): def to_dict(self):

View File

@ -5,7 +5,7 @@ This Python package is automatically generated by the [Swagger Codegen](https://
- API version: 1.0.0 - API version: 1.0.0
- Package version: 1.0.0 - Package version: 1.0.0
- Build date: 2016-04-27T22:50:21.115+01:00 - Build date: 2016-05-09T01:08:25.311+01:00
- Build package: class io.swagger.codegen.languages.PythonClientCodegen - Build package: class io.swagger.codegen.languages.PythonClientCodegen
## Requirements. ## Requirements.
@ -18,9 +18,9 @@ Python 2.7 and 3.4+
If the python package is hosted on Github, you can install directly from Github If the python package is hosted on Github, you can install directly from Github
```sh ```sh
pip install git+https://github.com/YOUR_GIT_USR_ID/YOUR_GIT_REPO_ID.git pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git
``` ```
(you may need to run `pip` with root permission: `sudo pip install git+https://github.com/YOUR_GIT_USR_ID/YOUR_GIT_REPO_ID.git`) (you may need to run `pip` with root permission: `sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git`)
Then import the package: Then import the package:
```python ```python

View File

@ -8,12 +8,12 @@ git_repo_id=$2
release_note=$3 release_note=$3
if [ "$git_user_id" = "" ]; then if [ "$git_user_id" = "" ]; then
git_user_id="YOUR_GIT_USR_ID" git_user_id="GIT_USER_ID"
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
fi fi
if [ "$git_repo_id" = "" ]; then if [ "$git_repo_id" = "" ]; then
git_repo_id="YOUR_GIT_REPO_ID" git_repo_id="GIT_REPO_ID"
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
fi fi

View File

@ -21,6 +21,7 @@ from __future__ import absolute_import
import sys import sys
import os import os
import re
# python 2 and python 3 compatibility library # python 2 and python 3 compatibility library
from six import iteritems from six import iteritems
@ -103,6 +104,31 @@ class FakeApi(object):
if ('byte' not in params) or (params['byte'] is None): if ('byte' not in params) or (params['byte'] is None):
raise ValueError("Missing the required parameter `byte` when calling `test_endpoint_parameters`") raise ValueError("Missing the required parameter `byte` when calling `test_endpoint_parameters`")
if 'number' in params and params['number'] > 543.2:
raise ValueError("Invalid value for parameter `number` when calling `test_endpoint_parameters`, must be a value less than or equal to `543.2`")
if 'number' in params and params['number'] < 32.1:
raise ValueError("Invalid value for parameter `number` when calling `test_endpoint_parameters`, must be a value greater than or equal to `32.1`")
if 'double' in params and params['double'] > 123.4:
raise ValueError("Invalid value for parameter `double` when calling `test_endpoint_parameters`, must be a value less than or equal to `123.4`")
if 'double' in params and params['double'] < 67.8:
raise ValueError("Invalid value for parameter `double` when calling `test_endpoint_parameters`, must be a value greater than or equal to `67.8`")
if 'string' in params and not re.search('[a-z]', params['string'], flags=re.IGNORECASE):
raise ValueError("Invalid value for parameter `string` when calling `test_endpoint_parameters`, must conform to the pattern `/[a-z]/i`")
if 'integer' in params and params['integer'] > 100.0:
raise ValueError("Invalid value for parameter `integer` when calling `test_endpoint_parameters`, must be a value less than or equal to `100.0`")
if 'integer' in params and params['integer'] < 10.0:
raise ValueError("Invalid value for parameter `integer` when calling `test_endpoint_parameters`, must be a value greater than or equal to `10.0`")
if 'int32' in params and params['int32'] > 200.0:
raise ValueError("Invalid value for parameter `int32` when calling `test_endpoint_parameters`, must be a value less than or equal to `200.0`")
if 'int32' in params and params['int32'] < 20.0:
raise ValueError("Invalid value for parameter `int32` when calling `test_endpoint_parameters`, must be a value greater than or equal to `20.0`")
if 'float' in params and params['float'] > 987.6:
raise ValueError("Invalid value for parameter `float` when calling `test_endpoint_parameters`, must be a value less than or equal to `987.6`")
if 'password' in params and len(params['password']) > 64:
raise ValueError("Invalid value for parameter `password` when calling `test_endpoint_parameters`, length must be less than or equal to `64`")
if 'password' in params and len(params['password']) < 10:
raise ValueError("Invalid value for parameter `password` when calling `test_endpoint_parameters`, length must be greater than or equal to `10`")
resource_path = '/fake'.replace('{format}', 'json') resource_path = '/fake'.replace('{format}', 'json')
path_params = {} path_params = {}

View File

@ -21,6 +21,7 @@ from __future__ import absolute_import
import sys import sys
import os import os
import re
# python 2 and python 3 compatibility library # python 2 and python 3 compatibility library
from six import iteritems from six import iteritems
@ -83,6 +84,7 @@ class PetApi(object):
if ('body' not in params) or (params['body'] is None): if ('body' not in params) or (params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `add_pet`") raise ValueError("Missing the required parameter `body` when calling `add_pet`")
resource_path = '/pet'.replace('{format}', 'json') resource_path = '/pet'.replace('{format}', 'json')
path_params = {} path_params = {}
@ -161,6 +163,7 @@ class PetApi(object):
if ('pet_id' not in params) or (params['pet_id'] is None): if ('pet_id' not in params) or (params['pet_id'] is None):
raise ValueError("Missing the required parameter `pet_id` when calling `delete_pet`") raise ValueError("Missing the required parameter `pet_id` when calling `delete_pet`")
resource_path = '/pet/{petId}'.replace('{format}', 'json') resource_path = '/pet/{petId}'.replace('{format}', 'json')
path_params = {} path_params = {}
if 'pet_id' in params: if 'pet_id' in params:
@ -240,6 +243,7 @@ class PetApi(object):
if ('status' not in params) or (params['status'] is None): if ('status' not in params) or (params['status'] is None):
raise ValueError("Missing the required parameter `status` when calling `find_pets_by_status`") raise ValueError("Missing the required parameter `status` when calling `find_pets_by_status`")
resource_path = '/pet/findByStatus'.replace('{format}', 'json') resource_path = '/pet/findByStatus'.replace('{format}', 'json')
path_params = {} path_params = {}
@ -317,6 +321,7 @@ class PetApi(object):
if ('tags' not in params) or (params['tags'] is None): if ('tags' not in params) or (params['tags'] is None):
raise ValueError("Missing the required parameter `tags` when calling `find_pets_by_tags`") raise ValueError("Missing the required parameter `tags` when calling `find_pets_by_tags`")
resource_path = '/pet/findByTags'.replace('{format}', 'json') resource_path = '/pet/findByTags'.replace('{format}', 'json')
path_params = {} path_params = {}
@ -394,6 +399,7 @@ class PetApi(object):
if ('pet_id' not in params) or (params['pet_id'] is None): 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`") raise ValueError("Missing the required parameter `pet_id` when calling `get_pet_by_id`")
resource_path = '/pet/{petId}'.replace('{format}', 'json') resource_path = '/pet/{petId}'.replace('{format}', 'json')
path_params = {} path_params = {}
if 'pet_id' in params: if 'pet_id' in params:
@ -471,6 +477,7 @@ class PetApi(object):
if ('body' not in params) or (params['body'] is None): if ('body' not in params) or (params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `update_pet`") raise ValueError("Missing the required parameter `body` when calling `update_pet`")
resource_path = '/pet'.replace('{format}', 'json') resource_path = '/pet'.replace('{format}', 'json')
path_params = {} path_params = {}
@ -550,6 +557,7 @@ class PetApi(object):
if ('pet_id' not in params) or (params['pet_id'] is None): if ('pet_id' not in params) or (params['pet_id'] is None):
raise ValueError("Missing the required parameter `pet_id` when calling `update_pet_with_form`") raise ValueError("Missing the required parameter `pet_id` when calling `update_pet_with_form`")
resource_path = '/pet/{petId}'.replace('{format}', 'json') resource_path = '/pet/{petId}'.replace('{format}', 'json')
path_params = {} path_params = {}
if 'pet_id' in params: if 'pet_id' in params:
@ -633,6 +641,7 @@ class PetApi(object):
if ('pet_id' not in params) or (params['pet_id'] is None): if ('pet_id' not in params) or (params['pet_id'] is None):
raise ValueError("Missing the required parameter `pet_id` when calling `upload_file`") raise ValueError("Missing the required parameter `pet_id` when calling `upload_file`")
resource_path = '/pet/{petId}/uploadImage'.replace('{format}', 'json') resource_path = '/pet/{petId}/uploadImage'.replace('{format}', 'json')
path_params = {} path_params = {}
if 'pet_id' in params: if 'pet_id' in params:

View File

@ -21,6 +21,7 @@ from __future__ import absolute_import
import sys import sys
import os import os
import re
# python 2 and python 3 compatibility library # python 2 and python 3 compatibility library
from six import iteritems from six import iteritems
@ -83,6 +84,9 @@ class StoreApi(object):
if ('order_id' not in params) or (params['order_id'] is None): if ('order_id' not in params) or (params['order_id'] is None):
raise ValueError("Missing the required parameter `order_id` when calling `delete_order`") raise ValueError("Missing the required parameter `order_id` when calling `delete_order`")
if 'order_id' in params and params['order_id'] < 1.0:
raise ValueError("Invalid value for parameter `order_id` when calling `delete_order`, must be a value greater than or equal to `1.0`")
resource_path = '/store/order/{orderId}'.replace('{format}', 'json') resource_path = '/store/order/{orderId}'.replace('{format}', 'json')
path_params = {} path_params = {}
if 'order_id' in params: if 'order_id' in params:
@ -156,6 +160,7 @@ class StoreApi(object):
del params['kwargs'] del params['kwargs']
resource_path = '/store/inventory'.replace('{format}', 'json') resource_path = '/store/inventory'.replace('{format}', 'json')
path_params = {} path_params = {}
@ -231,6 +236,11 @@ class StoreApi(object):
if ('order_id' not in params) or (params['order_id'] is None): if ('order_id' not in params) or (params['order_id'] is None):
raise ValueError("Missing the required parameter `order_id` when calling `get_order_by_id`") raise ValueError("Missing the required parameter `order_id` when calling `get_order_by_id`")
if 'order_id' in params and params['order_id'] > 5.0:
raise ValueError("Invalid value for parameter `order_id` when calling `get_order_by_id`, must be a value less than or equal to `5.0`")
if 'order_id' in params and params['order_id'] < 1.0:
raise ValueError("Invalid value for parameter `order_id` when calling `get_order_by_id`, must be a value greater than or equal to `1.0`")
resource_path = '/store/order/{orderId}'.replace('{format}', 'json') resource_path = '/store/order/{orderId}'.replace('{format}', 'json')
path_params = {} path_params = {}
if 'order_id' in params: if 'order_id' in params:
@ -308,6 +318,7 @@ class StoreApi(object):
if ('body' not in params) or (params['body'] is None): if ('body' not in params) or (params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `place_order`") raise ValueError("Missing the required parameter `body` when calling `place_order`")
resource_path = '/store/order'.replace('{format}', 'json') resource_path = '/store/order'.replace('{format}', 'json')
path_params = {} path_params = {}

View File

@ -21,6 +21,7 @@ from __future__ import absolute_import
import sys import sys
import os import os
import re
# python 2 and python 3 compatibility library # python 2 and python 3 compatibility library
from six import iteritems from six import iteritems
@ -83,6 +84,7 @@ class UserApi(object):
if ('body' not in params) or (params['body'] is None): if ('body' not in params) or (params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `create_user`") raise ValueError("Missing the required parameter `body` when calling `create_user`")
resource_path = '/user'.replace('{format}', 'json') resource_path = '/user'.replace('{format}', 'json')
path_params = {} path_params = {}
@ -160,6 +162,7 @@ class UserApi(object):
if ('body' not in params) or (params['body'] is None): if ('body' not in params) or (params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `create_users_with_array_input`") raise ValueError("Missing the required parameter `body` when calling `create_users_with_array_input`")
resource_path = '/user/createWithArray'.replace('{format}', 'json') resource_path = '/user/createWithArray'.replace('{format}', 'json')
path_params = {} path_params = {}
@ -237,6 +240,7 @@ class UserApi(object):
if ('body' not in params) or (params['body'] is None): if ('body' not in params) or (params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `create_users_with_list_input`") raise ValueError("Missing the required parameter `body` when calling `create_users_with_list_input`")
resource_path = '/user/createWithList'.replace('{format}', 'json') resource_path = '/user/createWithList'.replace('{format}', 'json')
path_params = {} path_params = {}
@ -314,6 +318,7 @@ class UserApi(object):
if ('username' not in params) or (params['username'] is None): if ('username' not in params) or (params['username'] is None):
raise ValueError("Missing the required parameter `username` when calling `delete_user`") raise ValueError("Missing the required parameter `username` when calling `delete_user`")
resource_path = '/user/{username}'.replace('{format}', 'json') resource_path = '/user/{username}'.replace('{format}', 'json')
path_params = {} path_params = {}
if 'username' in params: if 'username' in params:
@ -391,6 +396,7 @@ class UserApi(object):
if ('username' not in params) or (params['username'] is None): if ('username' not in params) or (params['username'] is None):
raise ValueError("Missing the required parameter `username` when calling `get_user_by_name`") raise ValueError("Missing the required parameter `username` when calling `get_user_by_name`")
resource_path = '/user/{username}'.replace('{format}', 'json') resource_path = '/user/{username}'.replace('{format}', 'json')
path_params = {} path_params = {}
if 'username' in params: if 'username' in params:
@ -472,6 +478,7 @@ class UserApi(object):
if ('password' not in params) or (params['password'] is None): if ('password' not in params) or (params['password'] is None):
raise ValueError("Missing the required parameter `password` when calling `login_user`") raise ValueError("Missing the required parameter `password` when calling `login_user`")
resource_path = '/user/login'.replace('{format}', 'json') resource_path = '/user/login'.replace('{format}', 'json')
path_params = {} path_params = {}
@ -547,6 +554,7 @@ class UserApi(object):
del params['kwargs'] del params['kwargs']
resource_path = '/user/logout'.replace('{format}', 'json') resource_path = '/user/logout'.replace('{format}', 'json')
path_params = {} path_params = {}
@ -626,6 +634,7 @@ class UserApi(object):
if ('body' not in params) or (params['body'] is None): if ('body' not in params) or (params['body'] is None):
raise ValueError("Missing the required parameter `body` when calling `update_user`") raise ValueError("Missing the required parameter `body` when calling `update_user`")
resource_path = '/user/{username}'.replace('{format}', 'json') resource_path = '/user/{username}'.replace('{format}', 'json')
path_params = {} path_params = {}
if 'username' in params: if 'username' in params:

View File

@ -20,6 +20,7 @@ Copyright 2016 SmartBear Software
from pprint import pformat from pprint import pformat
from six import iteritems from six import iteritems
import re
class Animal(object): class Animal(object):
@ -66,6 +67,7 @@ class Animal(object):
:param class_name: The class_name of this Animal. :param class_name: The class_name of this Animal.
:type: str :type: str
""" """
self._class_name = class_name self._class_name = class_name
def to_dict(self): def to_dict(self):

View File

@ -20,6 +20,7 @@ Copyright 2016 SmartBear Software
from pprint import pformat from pprint import pformat
from six import iteritems from six import iteritems
import re
class ApiResponse(object): class ApiResponse(object):
@ -72,6 +73,7 @@ class ApiResponse(object):
:param code: The code of this ApiResponse. :param code: The code of this ApiResponse.
:type: int :type: int
""" """
self._code = code self._code = code
@property @property
@ -94,6 +96,7 @@ class ApiResponse(object):
:param type: The type of this ApiResponse. :param type: The type of this ApiResponse.
:type: str :type: str
""" """
self._type = type self._type = type
@property @property
@ -116,6 +119,7 @@ class ApiResponse(object):
:param message: The message of this ApiResponse. :param message: The message of this ApiResponse.
:type: str :type: str
""" """
self._message = message self._message = message
def to_dict(self): def to_dict(self):

View File

@ -20,6 +20,7 @@ Copyright 2016 SmartBear Software
from pprint import pformat from pprint import pformat
from six import iteritems from six import iteritems
import re
class Cat(object): class Cat(object):
@ -69,6 +70,7 @@ class Cat(object):
:param class_name: The class_name of this Cat. :param class_name: The class_name of this Cat.
:type: str :type: str
""" """
self._class_name = class_name self._class_name = class_name
@property @property
@ -91,6 +93,7 @@ class Cat(object):
:param declawed: The declawed of this Cat. :param declawed: The declawed of this Cat.
:type: bool :type: bool
""" """
self._declawed = declawed self._declawed = declawed
def to_dict(self): def to_dict(self):

View File

@ -20,6 +20,7 @@ Copyright 2016 SmartBear Software
from pprint import pformat from pprint import pformat
from six import iteritems from six import iteritems
import re
class Category(object): class Category(object):
@ -69,6 +70,7 @@ class Category(object):
:param id: The id of this Category. :param id: The id of this Category.
:type: int :type: int
""" """
self._id = id self._id = id
@property @property
@ -91,6 +93,7 @@ class Category(object):
:param name: The name of this Category. :param name: The name of this Category.
:type: str :type: str
""" """
self._name = name self._name = name
def to_dict(self): def to_dict(self):

View File

@ -20,6 +20,7 @@ Copyright 2016 SmartBear Software
from pprint import pformat from pprint import pformat
from six import iteritems from six import iteritems
import re
class Dog(object): class Dog(object):
@ -69,6 +70,7 @@ class Dog(object):
:param class_name: The class_name of this Dog. :param class_name: The class_name of this Dog.
:type: str :type: str
""" """
self._class_name = class_name self._class_name = class_name
@property @property
@ -91,6 +93,7 @@ class Dog(object):
:param breed: The breed of this Dog. :param breed: The breed of this Dog.
:type: str :type: str
""" """
self._breed = breed self._breed = breed
def to_dict(self): def to_dict(self):

View File

@ -20,6 +20,7 @@ Copyright 2016 SmartBear Software
from pprint import pformat from pprint import pformat
from six import iteritems from six import iteritems
import re
class FormatTest(object): class FormatTest(object):
@ -102,6 +103,14 @@ class FormatTest(object):
:param integer: The integer of this FormatTest. :param integer: The integer of this FormatTest.
:type: int :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:
raise ValueError("Invalid value for `integer`, must be a value greater than or equal to `10.0`")
self._integer = integer self._integer = integer
@property @property
@ -124,6 +133,14 @@ class FormatTest(object):
:param int32: The int32 of this FormatTest. :param int32: The int32 of this FormatTest.
:type: int :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:
raise ValueError("Invalid value for `int32`, must be a value greater than or equal to `20.0`")
self._int32 = int32 self._int32 = int32
@property @property
@ -146,6 +163,7 @@ class FormatTest(object):
:param int64: The int64 of this FormatTest. :param int64: The int64 of this FormatTest.
:type: int :type: int
""" """
self._int64 = int64 self._int64 = int64
@property @property
@ -168,6 +186,14 @@ class FormatTest(object):
:param number: The number of this FormatTest. :param number: The number of this FormatTest.
:type: float :type: float
""" """
if not number:
raise ValueError("Invalid value for `number`, must not be `None`")
if number > 543.2:
raise ValueError("Invalid value for `number`, must be a value less than or equal to `543.2`")
if number < 32.1:
raise ValueError("Invalid value for `number`, must be a value greater than or equal to `32.1`")
self._number = number self._number = number
@property @property
@ -190,6 +216,14 @@ class FormatTest(object):
:param float: The float of this FormatTest. :param float: The float of this FormatTest.
:type: float :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:
raise ValueError("Invalid value for `float`, must be a value greater than or equal to `54.3`")
self._float = float self._float = float
@property @property
@ -212,6 +246,14 @@ class FormatTest(object):
:param double: The double of this FormatTest. :param double: The double of this FormatTest.
:type: float :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:
raise ValueError("Invalid value for `double`, must be a value greater than or equal to `67.8`")
self._double = double self._double = double
@property @property
@ -234,6 +276,12 @@ class FormatTest(object):
:param string: The string of this FormatTest. :param string: The string of this FormatTest.
:type: str :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`")
self._string = string self._string = string
@property @property
@ -256,6 +304,7 @@ class FormatTest(object):
:param byte: The byte of this FormatTest. :param byte: The byte of this FormatTest.
:type: str :type: str
""" """
self._byte = byte self._byte = byte
@property @property
@ -278,6 +327,7 @@ class FormatTest(object):
:param binary: The binary of this FormatTest. :param binary: The binary of this FormatTest.
:type: str :type: str
""" """
self._binary = binary self._binary = binary
@property @property
@ -300,6 +350,7 @@ class FormatTest(object):
:param date: The date of this FormatTest. :param date: The date of this FormatTest.
:type: date :type: date
""" """
self._date = date self._date = date
@property @property
@ -322,6 +373,7 @@ class FormatTest(object):
:param date_time: The date_time of this FormatTest. :param date_time: The date_time of this FormatTest.
:type: datetime :type: datetime
""" """
self._date_time = date_time self._date_time = date_time
@property @property
@ -344,6 +396,7 @@ class FormatTest(object):
:param uuid: The uuid of this FormatTest. :param uuid: The uuid of this FormatTest.
:type: str :type: str
""" """
self._uuid = uuid self._uuid = uuid
@property @property
@ -366,6 +419,14 @@ class FormatTest(object):
:param password: The password of this FormatTest. :param password: The password of this FormatTest.
:type: str :type: str
""" """
if not password:
raise ValueError("Invalid value for `password`, must not be `None`")
if len(password) > 64:
raise ValueError("Invalid value for `password`, length must be less than `64`")
if len(password) < 10:
raise ValueError("Invalid value for `password`, length must be greater than or equal to `10`")
self._password = password self._password = password
def to_dict(self): def to_dict(self):

View File

@ -20,6 +20,7 @@ Copyright 2016 SmartBear Software
from pprint import pformat from pprint import pformat
from six import iteritems from six import iteritems
import re
class Model200Response(object): class Model200Response(object):
@ -66,6 +67,7 @@ class Model200Response(object):
:param name: The name of this Model200Response. :param name: The name of this Model200Response.
:type: int :type: int
""" """
self._name = name self._name = name
def to_dict(self): def to_dict(self):

View File

@ -20,6 +20,7 @@ Copyright 2016 SmartBear Software
from pprint import pformat from pprint import pformat
from six import iteritems from six import iteritems
import re
class ModelReturn(object): class ModelReturn(object):
@ -66,6 +67,7 @@ class ModelReturn(object):
:param _return: The _return of this ModelReturn. :param _return: The _return of this ModelReturn.
:type: int :type: int
""" """
self.__return = _return self.__return = _return
def to_dict(self): def to_dict(self):

View File

@ -20,6 +20,7 @@ Copyright 2016 SmartBear Software
from pprint import pformat from pprint import pformat
from six import iteritems from six import iteritems
import re
class Name(object): class Name(object):
@ -72,6 +73,7 @@ class Name(object):
:param name: The name of this Name. :param name: The name of this Name.
:type: int :type: int
""" """
self._name = name self._name = name
@property @property
@ -94,6 +96,7 @@ class Name(object):
:param snake_case: The snake_case of this Name. :param snake_case: The snake_case of this Name.
:type: int :type: int
""" """
self._snake_case = snake_case self._snake_case = snake_case
@property @property
@ -116,6 +119,7 @@ class Name(object):
:param _property: The _property of this Name. :param _property: The _property of this Name.
:type: str :type: str
""" """
self.__property = _property self.__property = _property
def to_dict(self): def to_dict(self):

View File

@ -20,6 +20,7 @@ Copyright 2016 SmartBear Software
from pprint import pformat from pprint import pformat
from six import iteritems from six import iteritems
import re
class Order(object): class Order(object):
@ -81,6 +82,7 @@ class Order(object):
:param id: The id of this Order. :param id: The id of this Order.
:type: int :type: int
""" """
self._id = id self._id = id
@property @property
@ -103,6 +105,7 @@ class Order(object):
:param pet_id: The pet_id of this Order. :param pet_id: The pet_id of this Order.
:type: int :type: int
""" """
self._pet_id = pet_id self._pet_id = pet_id
@property @property
@ -125,6 +128,7 @@ class Order(object):
:param quantity: The quantity of this Order. :param quantity: The quantity of this Order.
:type: int :type: int
""" """
self._quantity = quantity self._quantity = quantity
@property @property
@ -147,6 +151,7 @@ class Order(object):
:param ship_date: The ship_date of this Order. :param ship_date: The ship_date of this Order.
:type: datetime :type: datetime
""" """
self._ship_date = ship_date self._ship_date = ship_date
@property @property
@ -175,6 +180,7 @@ class Order(object):
"Invalid value for `status`, must be one of {0}" "Invalid value for `status`, must be one of {0}"
.format(allowed_values) .format(allowed_values)
) )
self._status = status self._status = status
@property @property
@ -197,6 +203,7 @@ class Order(object):
:param complete: The complete of this Order. :param complete: The complete of this Order.
:type: bool :type: bool
""" """
self._complete = complete self._complete = complete
def to_dict(self): def to_dict(self):

View File

@ -20,6 +20,7 @@ Copyright 2016 SmartBear Software
from pprint import pformat from pprint import pformat
from six import iteritems from six import iteritems
import re
class Pet(object): class Pet(object):
@ -81,6 +82,7 @@ class Pet(object):
:param id: The id of this Pet. :param id: The id of this Pet.
:type: int :type: int
""" """
self._id = id self._id = id
@property @property
@ -103,6 +105,7 @@ class Pet(object):
:param category: The category of this Pet. :param category: The category of this Pet.
:type: Category :type: Category
""" """
self._category = category self._category = category
@property @property
@ -125,6 +128,7 @@ class Pet(object):
:param name: The name of this Pet. :param name: The name of this Pet.
:type: str :type: str
""" """
self._name = name self._name = name
@property @property
@ -147,6 +151,7 @@ class Pet(object):
:param photo_urls: The photo_urls of this Pet. :param photo_urls: The photo_urls of this Pet.
:type: list[str] :type: list[str]
""" """
self._photo_urls = photo_urls self._photo_urls = photo_urls
@property @property
@ -169,6 +174,7 @@ class Pet(object):
:param tags: The tags of this Pet. :param tags: The tags of this Pet.
:type: list[Tag] :type: list[Tag]
""" """
self._tags = tags self._tags = tags
@property @property
@ -197,6 +203,7 @@ class Pet(object):
"Invalid value for `status`, must be one of {0}" "Invalid value for `status`, must be one of {0}"
.format(allowed_values) .format(allowed_values)
) )
self._status = status self._status = status
def to_dict(self): def to_dict(self):

View File

@ -20,6 +20,7 @@ Copyright 2016 SmartBear Software
from pprint import pformat from pprint import pformat
from six import iteritems from six import iteritems
import re
class SpecialModelName(object): class SpecialModelName(object):
@ -66,6 +67,7 @@ class SpecialModelName(object):
:param special_property_name: The special_property_name of this SpecialModelName. :param special_property_name: The special_property_name of this SpecialModelName.
:type: int :type: int
""" """
self._special_property_name = special_property_name self._special_property_name = special_property_name
def to_dict(self): def to_dict(self):

View File

@ -20,6 +20,7 @@ Copyright 2016 SmartBear Software
from pprint import pformat from pprint import pformat
from six import iteritems from six import iteritems
import re
class Tag(object): class Tag(object):
@ -69,6 +70,7 @@ class Tag(object):
:param id: The id of this Tag. :param id: The id of this Tag.
:type: int :type: int
""" """
self._id = id self._id = id
@property @property
@ -91,6 +93,7 @@ class Tag(object):
:param name: The name of this Tag. :param name: The name of this Tag.
:type: str :type: str
""" """
self._name = name self._name = name
def to_dict(self): def to_dict(self):

View File

@ -20,6 +20,7 @@ Copyright 2016 SmartBear Software
from pprint import pformat from pprint import pformat
from six import iteritems from six import iteritems
import re
class User(object): class User(object):
@ -87,6 +88,7 @@ class User(object):
:param id: The id of this User. :param id: The id of this User.
:type: int :type: int
""" """
self._id = id self._id = id
@property @property
@ -109,6 +111,7 @@ class User(object):
:param username: The username of this User. :param username: The username of this User.
:type: str :type: str
""" """
self._username = username self._username = username
@property @property
@ -131,6 +134,7 @@ class User(object):
:param first_name: The first_name of this User. :param first_name: The first_name of this User.
:type: str :type: str
""" """
self._first_name = first_name self._first_name = first_name
@property @property
@ -153,6 +157,7 @@ class User(object):
:param last_name: The last_name of this User. :param last_name: The last_name of this User.
:type: str :type: str
""" """
self._last_name = last_name self._last_name = last_name
@property @property
@ -175,6 +180,7 @@ class User(object):
:param email: The email of this User. :param email: The email of this User.
:type: str :type: str
""" """
self._email = email self._email = email
@property @property
@ -197,6 +203,7 @@ class User(object):
:param password: The password of this User. :param password: The password of this User.
:type: str :type: str
""" """
self._password = password self._password = password
@property @property
@ -219,6 +226,7 @@ class User(object):
:param phone: The phone of this User. :param phone: The phone of this User.
:type: str :type: str
""" """
self._phone = phone self._phone = phone
@property @property
@ -241,6 +249,7 @@ class User(object):
:param user_status: The user_status of this User. :param user_status: The user_status of this User.
:type: int :type: int
""" """
self._user_status = user_status self._user_status = user_status
def to_dict(self): def to_dict(self):