Merge branch 'python-patterns' of https://github.com/scop/swagger-codegen into scop-python-patterns

This commit is contained in:
wing328 2016-08-31 13:54:47 +08:00
commit 429bc46a79
5 changed files with 19 additions and 19 deletions

View File

@ -203,7 +203,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
+ "/pattern/modifiers convention. "+pattern+" is not valid.");
}
String regex = pattern.substring(1, i).replace("'", "\'");
String regex = pattern.substring(1, i).replace("'", "\\'");
List<String> modifiers = new ArrayList<String>();
for(char c : pattern.substring(i).toCharArray()) {

View File

@ -135,8 +135,8 @@ class {{classname}}(object):
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}}`")
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}}

View File

@ -89,8 +89,8 @@ class {{classname}}(object):
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}}`")
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}}

View File

@ -5,7 +5,7 @@ This Python package is automatically generated by the [Swagger Codegen](https://
- API version: 1.0.0
- Package version: 1.0.0
- Build date: 2016-08-29T16:39:50.642+02:00
- Build date: 2016-08-30T08:06:49.587+03:00
- Build package: class io.swagger.codegen.languages.PythonClientCodegen
## Requirements.
@ -131,12 +131,6 @@ Class | Method | HTTP request | Description
## Documentation For Authorization
## api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
## petstore_auth
- **Type**: OAuth
@ -150,6 +144,12 @@ Class | Method | HTTP request | Description
- **Type**: HTTP basic authentication
## api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
## Author

View File

@ -216,13 +216,6 @@ class Configuration(object):
:return: The Auth Settings information dict.
"""
return {
'api_key':
{
'type': 'api_key',
'in': 'header',
'key': 'api_key',
'value': self.get_api_key_with_prefix('api_key')
},
'petstore_auth':
{
@ -238,6 +231,13 @@ class Configuration(object):
'key': 'Authorization',
'value': self.get_basic_auth_token()
},
'api_key':
{
'type': 'api_key',
'in': 'header',
'key': 'api_key',
'value': self.get_api_key_with_prefix('api_key')
},
}