Merge pull request #3287 from lrimkus/patch-1

Python vnd content-type header support
This commit is contained in:
wing328 2016-07-06 11:27:20 +08:00 committed by GitHub
commit c1d835dcfc
10 changed files with 37 additions and 237 deletions

View File

@ -10,6 +10,7 @@ import json
import ssl import ssl
import certifi import certifi
import logging import logging
import re
# python 2 and python 3 compatibility library # python 2 and python 3 compatibility library
from six import iteritems from six import iteritems
@ -121,7 +122,7 @@ class RESTClientObject(object):
if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
if query_params: if query_params:
url += '?' + urlencode(query_params) url += '?' + urlencode(query_params)
if headers['Content-Type'] == 'application/json': if re.search('json', headers['Content-Type'], re.IGNORECASE):
request_body = None request_body = None
if body: if body:
request_body = json.dumps(body) request_body = json.dumps(body)

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-06-28T16:59:47.081+08:00 - Build date: 2016-07-05T10:32:24.684-04:00
- Build package: class io.swagger.codegen.languages.PythonClientCodegen - Build package: class io.swagger.codegen.languages.PythonClientCodegen
## Requirements. ## Requirements.
@ -52,13 +52,24 @@ from petstore_api.rest import ApiException
from pprint import pprint from pprint import pprint
# create an instance of the API class # create an instance of the API class
api_instance = petstore_api.FakeApi api_instance = petstore_api.FakeApi
test_code_inject__end = 'test_code_inject__end_example' # str | To test code injection */ =end (optional) number = 3.4 # float | None
double = 1.2 # float | None
string = 'string_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)
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: try:
# To test code injection */ =end # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
api_instance.test_code_inject__end(test_code_inject__end=test_code_inject__end) 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)
except ApiException as e: except ApiException as e:
print "Exception when calling FakeApi->test_code_inject__end: %s\n" % e print "Exception when calling FakeApi->test_endpoint_parameters: %s\n" % e
``` ```
@ -68,7 +79,6 @@ All URIs are relative to *http://petstore.swagger.io/v2*
Class | Method | HTTP request | Description Class | Method | HTTP request | Description
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
*FakeApi* | [**test_code_inject__end**](docs/FakeApi.md#test_code_inject__end) | **PUT** /fake | To test code injection */ =end
*FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 *FakeApi* | [**test_endpoint_parameters**](docs/FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
*FakeApi* | [**test_enum_query_parameters**](docs/FakeApi.md#test_enum_query_parameters) | **GET** /fake | To test enum query parameters *FakeApi* | [**test_enum_query_parameters**](docs/FakeApi.md#test_enum_query_parameters) | **GET** /fake | To test enum query parameters
*PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store *PetApi* | [**add_pet**](docs/PetApi.md#add_pet) | **POST** /pet | Add a new pet to the store
@ -126,12 +136,6 @@ Class | Method | HTTP request | Description
## Documentation For Authorization ## Documentation For Authorization
## api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
## petstore_auth ## petstore_auth
- **Type**: OAuth - **Type**: OAuth
@ -141,6 +145,12 @@ Class | Method | HTTP request | Description
- **write:pets**: modify pets in your account - **write:pets**: modify pets in your account
- **read:pets**: read your pets - **read:pets**: read your pets
## api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
## Author ## Author

View File

@ -6,7 +6,6 @@ Name | Type | Description | Notes
**array_of_string** | **list[str]** | | [optional] **array_of_string** | **list[str]** | | [optional]
**array_array_of_integer** | **list[list[int]]** | | [optional] **array_array_of_integer** | **list[list[int]]** | | [optional]
**array_array_of_model** | **list[list[ReadOnlyFirst]]** | | [optional] **array_array_of_model** | **list[list[ReadOnlyFirst]]** | | [optional]
**array_of_enum** | **list[str]** | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -4,55 +4,10 @@ All URIs are relative to *http://petstore.swagger.io/v2*
Method | HTTP request | Description Method | HTTP request | Description
------------- | ------------- | ------------- ------------- | ------------- | -------------
[**test_code_inject__end**](FakeApi.md#test_code_inject__end) | **PUT** /fake | To test code injection */ =end
[**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 [**test_endpoint_parameters**](FakeApi.md#test_endpoint_parameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
[**test_enum_query_parameters**](FakeApi.md#test_enum_query_parameters) | **GET** /fake | To test enum query parameters [**test_enum_query_parameters**](FakeApi.md#test_enum_query_parameters) | **GET** /fake | To test enum query parameters
# **test_code_inject__end**
> test_code_inject__end(test_code_inject__end=test_code_inject__end)
To test code injection */ =end
### Example
```python
import time
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()
test_code_inject__end = 'test_code_inject__end_example' # str | To test code injection */ =end (optional)
try:
# To test code injection */ =end
api_instance.test_code_inject__end(test_code_inject__end=test_code_inject__end)
except ApiException as e:
print "Exception when calling FakeApi->test_code_inject__end: %s\n" % e
```
### Parameters
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**test_code_inject__end** | **str**| To test code injection */ =end | [optional]
### Return type
void (empty response body)
### Authorization
No authorization required
### HTTP request headers
- **Content-Type**: application/json, */ =end));(phpinfo(
- **Accept**: application/json, */ end
[[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**
> 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, string, byte, integer=integer, int32=int32, int64=int64, float=float, binary=binary, date=date, date_time=date_time, password=password)

View File

@ -4,7 +4,6 @@
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**map_map_of_string** | [**dict(str, dict(str, str))**](dict.md) | | [optional] **map_map_of_string** | [**dict(str, dict(str, str))**](dict.md) | | [optional]
**map_map_of_enum** | [**dict(str, dict(str, str))**](dict.md) | | [optional]
**map_of_enum_string** | **dict(str, str)** | | [optional] **map_of_enum_string** | **dict(str, str)** | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -51,107 +51,6 @@ class FakeApi(object):
config.api_client = ApiClient() config.api_client = ApiClient()
self.api_client = config.api_client self.api_client = config.api_client
def test_code_inject__end(self, **kwargs):
"""
To test code injection */ =end
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.test_code_inject__end(callback=callback_function)
:param callback function: The callback function
for asynchronous request. (optional)
:param str test_code_inject__end: To test code injection */ =end
:return: None
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('callback'):
return self.test_code_inject__end_with_http_info(**kwargs)
else:
(data) = self.test_code_inject__end_with_http_info(**kwargs)
return data
def test_code_inject__end_with_http_info(self, **kwargs):
"""
To test code injection */ =end
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.test_code_inject__end_with_http_info(callback=callback_function)
:param callback function: The callback function
for asynchronous request. (optional)
:param str test_code_inject__end: To test code injection */ =end
:return: None
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['test_code_inject__end']
all_params.append('callback')
all_params.append('_return_http_data_only')
params = locals()
for key, val in iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method test_code_inject__end" % key
)
params[key] = val
del params['kwargs']
resource_path = '/fake'.replace('{format}', 'json')
path_params = {}
query_params = {}
header_params = {}
form_params = []
local_var_files = {}
if 'test_code_inject__end' in params:
form_params.append(('test code inject */ =end', params['test_code_inject__end']))
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.\
select_header_accept(['application/json', '*/ end'])
if not header_params['Accept']:
del header_params['Accept']
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.\
select_header_content_type(['application/json', '*/ =end));(phpinfo('])
# Authentication setting
auth_settings = []
return self.api_client.call_api(resource_path, 'PUT',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type=None,
auth_settings=auth_settings,
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, string, byte, **kwargs):
""" """
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트

View File

@ -221,13 +221,6 @@ class Configuration(object):
:return: The Auth Settings information dict. :return: The Auth Settings information dict.
""" """
return { return {
'api_key':
{
'type': 'api_key',
'in': 'header',
'key': 'api_key',
'value': self.get_api_key_with_prefix('api_key')
},
'petstore_auth': 'petstore_auth':
{ {
@ -236,6 +229,13 @@ class Configuration(object):
'key': 'Authorization', 'key': 'Authorization',
'value': 'Bearer ' + self.access_token 'value': 'Bearer ' + self.access_token
}, },
'api_key':
{
'type': 'api_key',
'in': 'header',
'key': 'api_key',
'value': self.get_api_key_with_prefix('api_key')
},
} }

View File

@ -32,7 +32,7 @@ class ArrayTest(object):
NOTE: This class is auto generated by the swagger code generator program. NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually. Do not edit the class manually.
""" """
def __init__(self, array_of_string=None, array_array_of_integer=None, array_array_of_model=None, array_of_enum=None): def __init__(self, array_of_string=None, array_array_of_integer=None, array_array_of_model=None):
""" """
ArrayTest - a model defined in Swagger ArrayTest - a model defined in Swagger
@ -44,21 +44,18 @@ class ArrayTest(object):
self.swagger_types = { self.swagger_types = {
'array_of_string': 'list[str]', 'array_of_string': 'list[str]',
'array_array_of_integer': 'list[list[int]]', 'array_array_of_integer': 'list[list[int]]',
'array_array_of_model': 'list[list[ReadOnlyFirst]]', 'array_array_of_model': 'list[list[ReadOnlyFirst]]'
'array_of_enum': 'list[str]'
} }
self.attribute_map = { self.attribute_map = {
'array_of_string': 'array_of_string', 'array_of_string': 'array_of_string',
'array_array_of_integer': 'array_array_of_integer', 'array_array_of_integer': 'array_array_of_integer',
'array_array_of_model': 'array_array_of_model', 'array_array_of_model': 'array_array_of_model'
'array_of_enum': 'array_of_enum'
} }
self._array_of_string = array_of_string self._array_of_string = array_of_string
self._array_array_of_integer = array_array_of_integer self._array_array_of_integer = array_array_of_integer
self._array_array_of_model = array_array_of_model self._array_array_of_model = array_array_of_model
self._array_of_enum = array_of_enum
@property @property
def array_of_string(self): def array_of_string(self):
@ -129,35 +126,6 @@ class ArrayTest(object):
self._array_array_of_model = array_array_of_model self._array_array_of_model = array_array_of_model
@property
def array_of_enum(self):
"""
Gets the array_of_enum of this ArrayTest.
:return: The array_of_enum of this ArrayTest.
:rtype: list[str]
"""
return self._array_of_enum
@array_of_enum.setter
def array_of_enum(self, array_of_enum):
"""
Sets the array_of_enum of this ArrayTest.
:param array_of_enum: The array_of_enum of this ArrayTest.
:type: list[str]
"""
allowed_values = []
if array_of_enum not in allowed_values:
raise ValueError(
"Invalid value for `array_of_enum`, must be one of {0}"
.format(allowed_values)
)
self._array_of_enum = array_of_enum
def to_dict(self): def to_dict(self):
""" """
Returns the model properties as a dict Returns the model properties as a dict

View File

@ -32,7 +32,7 @@ class MapTest(object):
NOTE: This class is auto generated by the swagger code generator program. NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually. Do not edit the class manually.
""" """
def __init__(self, map_map_of_string=None, map_map_of_enum=None, map_of_enum_string=None): def __init__(self, map_map_of_string=None, map_of_enum_string=None):
""" """
MapTest - a model defined in Swagger MapTest - a model defined in Swagger
@ -43,18 +43,15 @@ class MapTest(object):
""" """
self.swagger_types = { self.swagger_types = {
'map_map_of_string': 'dict(str, dict(str, str))', 'map_map_of_string': 'dict(str, dict(str, str))',
'map_map_of_enum': 'dict(str, dict(str, str))',
'map_of_enum_string': 'dict(str, str)' 'map_of_enum_string': 'dict(str, str)'
} }
self.attribute_map = { self.attribute_map = {
'map_map_of_string': 'map_map_of_string', 'map_map_of_string': 'map_map_of_string',
'map_map_of_enum': 'map_map_of_enum',
'map_of_enum_string': 'map_of_enum_string' 'map_of_enum_string': 'map_of_enum_string'
} }
self._map_map_of_string = map_map_of_string self._map_map_of_string = map_map_of_string
self._map_map_of_enum = map_map_of_enum
self._map_of_enum_string = map_of_enum_string self._map_of_enum_string = map_of_enum_string
@property @property
@ -80,35 +77,6 @@ class MapTest(object):
self._map_map_of_string = map_map_of_string self._map_map_of_string = map_map_of_string
@property
def map_map_of_enum(self):
"""
Gets the map_map_of_enum of this MapTest.
:return: The map_map_of_enum of this MapTest.
:rtype: dict(str, dict(str, str))
"""
return self._map_map_of_enum
@map_map_of_enum.setter
def map_map_of_enum(self, map_map_of_enum):
"""
Sets the map_map_of_enum of this MapTest.
:param map_map_of_enum: The map_map_of_enum of this MapTest.
:type: dict(str, dict(str, str))
"""
allowed_values = []
if map_map_of_enum not in allowed_values:
raise ValueError(
"Invalid value for `map_map_of_enum`, must be one of {0}"
.format(allowed_values)
)
self._map_map_of_enum = map_map_of_enum
@property @property
def map_of_enum_string(self): def map_of_enum_string(self):
""" """

View File

@ -30,6 +30,7 @@ import json
import ssl import ssl
import certifi import certifi
import logging import logging
import re
# python 2 and python 3 compatibility library # python 2 and python 3 compatibility library
from six import iteritems from six import iteritems
@ -141,7 +142,7 @@ class RESTClientObject(object):
if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
if query_params: if query_params:
url += '?' + urlencode(query_params) url += '?' + urlencode(query_params)
if headers['Content-Type'] == 'application/json': if re.search('json', headers['Content-Type'], re.IGNORECASE):
request_body = None request_body = None
if body: if body:
request_body = json.dumps(body) request_body = json.dumps(body)