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 @@ -542,7 +542,7 @@ public void setEnsureUniqueParams(Boolean ensureUniqueParams) {
* @return properly-escaped pattern
*/
public String toRegularExpression(String pattern) {
return escapeText(pattern);
return escapeText(addRegularExpressionDelimiter(pattern));
}

/**
Expand Down Expand Up @@ -3264,4 +3264,19 @@ public void updateCodegenPropertyEnum(CodegenProperty var) {
}
}
}

/**
* If the pattern misses the delimiter, add "/" to the beginning and end
* Otherwise, return the original pattern
*
* @param pattern the pattern (regular expression)
* @return the pattern with delimiter
*/
public String addRegularExpressionDelimiter(String pattern) {
if (pattern != null && !pattern.matches("^/.*")) {
return "/" + pattern + "/";
}

return pattern;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -727,4 +727,5 @@ public String escapeQuotationMark(String input) {
public String escapeUnsafeCharacters(String input) {
return input.replace("=end", "=_end").replace("=begin", "=_begin");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ paths:
- name: enum_form_string_array
type: array
items:
tyep: string
type: string
default: '$'
enum:
- '>'
Expand All @@ -616,7 +616,7 @@ paths:
- name: enum_header_string_array
type: array
items:
tyep: string
type: string
default: '$'
enum:
- '>'
Expand Down Expand Up @@ -737,6 +737,11 @@ paths:
pattern: /[a-z]/i
in: formData
description: None
- name: pattern_without_delimiter
type: string
pattern: "^[A-Z].*"
in: formData
description: None
required: true
- name: byte
type: string
Expand Down
14 changes: 7 additions & 7 deletions samples/client/petstore/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-15T23:29:03.602+01:00
- Build date: 2016-08-22T17:54:52.358+08:00
- Build package: class io.swagger.codegen.languages.PythonClientCodegen

## Requirements.
Expand Down Expand Up @@ -130,6 +130,12 @@ 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
Expand All @@ -143,12 +149,6 @@ Class | Method | HTTP request | Description

- **Type**: HTTP basic authentication

## api_key

- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header


## Author

Expand Down
10 changes: 6 additions & 4 deletions samples/client/petstore/python/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ No authorization required
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)

# **test_endpoint_parameters**
> test_endpoint_parameters(number, double, string, byte, integer=integer, int32=int32, int64=int64, float=float, binary=binary, date=date, date_time=date_time, password=password)
> test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, date=date, date_time=date_time, password=password)

Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트

Expand All @@ -76,20 +76,21 @@ petstore_api.configuration.password = 'YOUR_PASSWORD'
api_instance = petstore_api.FakeApi()
number = 3.4 # float | None
double = 1.2 # float | None
string = 'string_example' # str | None
pattern_without_delimiter = 'pattern_without_delimiter_example' # str | None
byte = 'B' # str | None
integer = 56 # int | None (optional)
int32 = 56 # int | None (optional)
int64 = 789 # int | None (optional)
float = 3.4 # float | None (optional)
string = 'string_example' # str | None (optional)
binary = 'B' # str | None (optional)
date = '2013-10-20' # date | None (optional)
date_time = '2013-10-20T19:20:30+01:00' # datetime | None (optional)
password = 'password_example' # str | None (optional)

try:
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
api_instance.test_endpoint_parameters(number, double, string, byte, integer=integer, int32=int32, int64=int64, float=float, binary=binary, date=date, date_time=date_time, password=password)
api_instance.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, integer=integer, int32=int32, int64=int64, float=float, string=string, binary=binary, date=date, date_time=date_time, password=password)
except ApiException as e:
print "Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e
```
Expand All @@ -100,12 +101,13 @@ Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**number** | **float**| None |
**double** | **float**| None |
**string** | **str**| None |
**pattern_without_delimiter** | **str**| None |
**byte** | **str**| None |
**integer** | **int**| None | [optional]
**int32** | **int**| None | [optional]
**int64** | **int**| None | [optional]
**float** | **float**| None | [optional]
**string** | **str**| None | [optional]
**binary** | **str**| None | [optional]
**date** | **date**| None | [optional]
**date_time** | **datetime**| None | [optional]
Expand Down
34 changes: 20 additions & 14 deletions samples/client/petstore/python/petstore_api/apis/fake_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def test_client_model_with_http_info(self, body, **kwargs):
callback=params.get('callback'),
_return_http_data_only=params.get('_return_http_data_only'))

def test_endpoint_parameters(self, number, double, string, byte, **kwargs):
def test_endpoint_parameters(self, number, double, pattern_without_delimiter, byte, **kwargs):
"""
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
Expand All @@ -166,18 +166,19 @@ def test_endpoint_parameters(self, number, double, string, byte, **kwargs):
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.test_endpoint_parameters(number, double, string, byte, callback=callback_function)
>>> thread = api.test_endpoint_parameters(number, double, pattern_without_delimiter, byte, callback=callback_function)

:param callback function: The callback function
for asynchronous request. (optional)
:param float number: None (required)
:param float double: None (required)
:param str string: None (required)
:param str pattern_without_delimiter: None (required)
:param str byte: None (required)
:param int integer: None
:param int int32: None
:param int int64: None
:param float float: None
:param str string: None
:param str binary: None
:param date date: None
:param datetime date_time: None
Expand All @@ -188,12 +189,12 @@ def test_endpoint_parameters(self, number, double, string, byte, **kwargs):
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('callback'):
return self.test_endpoint_parameters_with_http_info(number, double, string, byte, **kwargs)
return self.test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, **kwargs)
else:
(data) = self.test_endpoint_parameters_with_http_info(number, double, string, byte, **kwargs)
(data) = self.test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, **kwargs)
return data

def test_endpoint_parameters_with_http_info(self, number, double, string, byte, **kwargs):
def test_endpoint_parameters_with_http_info(self, number, double, pattern_without_delimiter, byte, **kwargs):
"""
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
Expand All @@ -204,18 +205,19 @@ def test_endpoint_parameters_with_http_info(self, number, double, string, byte,
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.test_endpoint_parameters_with_http_info(number, double, string, byte, callback=callback_function)
>>> thread = api.test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, callback=callback_function)

:param callback function: The callback function
for asynchronous request. (optional)
:param float number: None (required)
:param float double: None (required)
:param str string: None (required)
:param str pattern_without_delimiter: None (required)
:param str byte: None (required)
:param int integer: None
:param int int32: None
:param int int64: None
:param float float: None
:param str string: None
:param str binary: None
:param date date: None
:param datetime date_time: None
Expand All @@ -225,7 +227,7 @@ def test_endpoint_parameters_with_http_info(self, number, double, string, byte,
returns the request thread.
"""

all_params = ['number', 'double', 'string', 'byte', 'integer', 'int32', 'int64', 'float', 'binary', 'date', 'date_time', 'password']
all_params = ['number', 'double', 'pattern_without_delimiter', 'byte', 'integer', 'int32', 'int64', 'float', 'string', 'binary', 'date', 'date_time', 'password']
all_params.append('callback')
all_params.append('_return_http_data_only')

Expand All @@ -244,9 +246,9 @@ def test_endpoint_parameters_with_http_info(self, number, double, string, byte,
# verify the required parameter 'double' is set
if ('double' not in params) or (params['double'] is None):
raise ValueError("Missing the required parameter `double` when calling `test_endpoint_parameters`")
# verify the required parameter 'string' is set
if ('string' not in params) or (params['string'] is None):
raise ValueError("Missing the required parameter `string` when calling `test_endpoint_parameters`")
# verify the required parameter 'pattern_without_delimiter' is set
if ('pattern_without_delimiter' not in params) or (params['pattern_without_delimiter'] is None):
raise ValueError("Missing the required parameter `pattern_without_delimiter` when calling `test_endpoint_parameters`")
# verify the required parameter 'byte' is set
if ('byte' not in params) or (params['byte'] is None):
raise ValueError("Missing the required parameter `byte` when calling `test_endpoint_parameters`")
Expand All @@ -259,8 +261,8 @@ def test_endpoint_parameters_with_http_info(self, number, double, string, byte,
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 'pattern_without_delimiter' in params and not re.search('^[A-Z].*', params['pattern_without_delimiter']):
raise ValueError("Invalid value for parameter `pattern_without_delimiter` when calling `test_endpoint_parameters`, must conform to the pattern `/^[A-Z].*/`")
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:
Expand All @@ -271,6 +273,8 @@ def test_endpoint_parameters_with_http_info(self, number, double, string, byte,
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 '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 '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:
Expand Down Expand Up @@ -298,6 +302,8 @@ def test_endpoint_parameters_with_http_info(self, number, double, string, byte,
form_params.append(('double', params['double']))
if 'string' in params:
form_params.append(('string', params['string']))
if 'pattern_without_delimiter' in params:
form_params.append(('pattern_without_delimiter', params['pattern_without_delimiter']))
if 'byte' in params:
form_params.append(('byte', params['byte']))
if 'binary' in params:
Expand Down
14 changes: 7 additions & 7 deletions samples/client/petstore/python/petstore_api/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@ def auth_settings(self):
: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':
{
Expand All @@ -236,13 +243,6 @@ def auth_settings(self):
'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')
},

}

Expand Down
16 changes: 10 additions & 6 deletions samples/client/petstore/ruby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This SDK is automatically generated by the [Swagger Codegen](https://github.com/

- API version: 1.0.0
- Package version: 1.0.0
- Build date: 2016-08-09T19:11:03.532+10:00
- Build date: 2016-08-22T16:46:39.641+08:00
- Build package: class io.swagger.codegen.languages.RubyClientCodegen

## Installation
Expand Down Expand Up @@ -78,7 +78,7 @@ Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*Petstore::FakeApi* | [**test_client_model**](docs/FakeApi.md#test_client_model) | **PATCH** /fake | To test \"client\" model
*Petstore::FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
*Petstore::FakeApi* | [**test_enum_query_parameters**](docs/FakeApi.md#test_enum_query_parameters) | **GET** /fake | To test enum query parameters
*Petstore::FakeApi* | [**test_enum_parameters**](docs/FakeApi.md#test_enum_parameters) | **GET** /fake | To test enum parameters
*Petstore::PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store
*Petstore::PetApi* | [**delete_pet**](docs/PetApi.md#delete_pet) | **DELETE** /pet/{petId} | Deletes a pet
*Petstore::PetApi* | [**find_pets_by_status**](docs/PetApi.md#find_pets_by_status) | **GET** /pet/findByStatus | Finds Pets by status
Expand Down Expand Up @@ -137,6 +137,12 @@ 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
Expand All @@ -146,9 +152,7 @@ Class | Method | HTTP request | Description
- write:pets: modify pets in your account
- read:pets: read your pets

### api_key
### http_basic_test

- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
- **Type**: HTTP basic authentication

Loading