forked from loafle/openapi-generator-original
Merge pull request #1234 from geekerzp/python_http_verb
[Python] Enhancements http verbs of python client
This commit is contained in:
commit
53e13aee19
@ -338,6 +338,12 @@ class ApiClient(object):
|
||||
return self.rest_client.HEAD(url,
|
||||
query_params=query_params,
|
||||
headers=headers)
|
||||
elif method == "OPTIONS":
|
||||
return self.rest_client.OPTIONS(url,
|
||||
query_params=query_params,
|
||||
headers=headers,
|
||||
post_params=post_params,
|
||||
body=body)
|
||||
elif method == "POST":
|
||||
return self.rest_client.POST(url,
|
||||
query_params=query_params,
|
||||
|
@ -103,7 +103,7 @@ class RESTClientObject(object):
|
||||
and `multipart/form-data`
|
||||
"""
|
||||
method = method.upper()
|
||||
assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', 'PATCH']
|
||||
assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', 'PATCH', 'OPTIONS']
|
||||
|
||||
if post_params and body:
|
||||
raise ValueError(
|
||||
@ -117,8 +117,8 @@ class RESTClientObject(object):
|
||||
headers['Content-Type'] = 'application/json'
|
||||
|
||||
try:
|
||||
# For `POST`, `PUT`, `PATCH`
|
||||
if method in ['POST', 'PUT', 'PATCH']:
|
||||
# For `POST`, `PUT`, `PATCH`, `OPTIONS`
|
||||
if method in ['POST', 'PUT', 'PATCH', 'OPTIONS']:
|
||||
if query_params:
|
||||
url += '?' + urlencode(query_params)
|
||||
if headers['Content-Type'] == 'application/json':
|
||||
@ -172,6 +172,13 @@ class RESTClientObject(object):
|
||||
headers=headers,
|
||||
query_params=query_params)
|
||||
|
||||
def OPTIONS(self, url, headers=None, query_params=None, post_params=None, body=None):
|
||||
return self.request("OPTIONS", url,
|
||||
headers=headers,
|
||||
query_params=query_params,
|
||||
post_params=post_params,
|
||||
body=body)
|
||||
|
||||
def DELETE(self, url, headers=None, query_params=None):
|
||||
return self.request("DELETE", url,
|
||||
headers=headers,
|
||||
@ -226,22 +233,3 @@ class ApiException(Exception):
|
||||
error_message += "HTTP response body: {0}\n".format(self.body)
|
||||
|
||||
return error_message
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -9,8 +9,8 @@ from .models.order import Order
|
||||
|
||||
# import apis into sdk package
|
||||
from .apis.user_api import UserApi
|
||||
from .apis.pet_api import PetApi
|
||||
from .apis.store_api import StoreApi
|
||||
from .apis.pet_api import PetApi
|
||||
|
||||
# import ApiClient
|
||||
from .api_client import ApiClient
|
||||
|
@ -270,7 +270,7 @@ class ApiClient(object):
|
||||
if klass in [int, float, str, bool]:
|
||||
return self.__deserialize_primitive(data, klass)
|
||||
elif klass == object:
|
||||
return self.__deserialize_object()
|
||||
return self.__deserialize_object(data)
|
||||
elif klass == date:
|
||||
return self.__deserialize_date(data)
|
||||
elif klass == datetime:
|
||||
@ -338,6 +338,12 @@ class ApiClient(object):
|
||||
return self.rest_client.HEAD(url,
|
||||
query_params=query_params,
|
||||
headers=headers)
|
||||
elif method == "OPTIONS":
|
||||
return self.rest_client.OPTIONS(url,
|
||||
query_params=query_params,
|
||||
headers=headers,
|
||||
post_params=post_params,
|
||||
body=body)
|
||||
elif method == "POST":
|
||||
return self.rest_client.POST(url,
|
||||
query_params=query_params,
|
||||
@ -495,13 +501,13 @@ class ApiClient(object):
|
||||
value = data
|
||||
return value
|
||||
|
||||
def __deserialize_object(self):
|
||||
def __deserialize_object(self, value):
|
||||
"""
|
||||
Deserializes empty object.
|
||||
Return a original value.
|
||||
|
||||
:return: object.
|
||||
"""
|
||||
return object()
|
||||
return value
|
||||
|
||||
def __deserialize_date(self, string):
|
||||
"""
|
||||
|
@ -2,5 +2,5 @@ from __future__ import absolute_import
|
||||
|
||||
# import apis into api package
|
||||
from .user_api import UserApi
|
||||
from .pet_api import PetApi
|
||||
from .store_api import StoreApi
|
||||
from .pet_api import PetApi
|
||||
|
@ -409,7 +409,7 @@ class PetApi(object):
|
||||
select_header_content_type([])
|
||||
|
||||
# Authentication setting
|
||||
auth_settings = ['api_key', 'petstore_auth']
|
||||
auth_settings = ['petstore_auth', 'api_key']
|
||||
|
||||
response = self.api_client.call_api(resource_path, method,
|
||||
path_params,
|
||||
|
@ -103,7 +103,7 @@ class RESTClientObject(object):
|
||||
and `multipart/form-data`
|
||||
"""
|
||||
method = method.upper()
|
||||
assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', 'PATCH']
|
||||
assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', 'PATCH', 'OPTIONS']
|
||||
|
||||
if post_params and body:
|
||||
raise ValueError(
|
||||
@ -117,8 +117,8 @@ class RESTClientObject(object):
|
||||
headers['Content-Type'] = 'application/json'
|
||||
|
||||
try:
|
||||
# For `POST`, `PUT`, `PATCH`
|
||||
if method in ['POST', 'PUT', 'PATCH']:
|
||||
# For `POST`, `PUT`, `PATCH`, `OPTIONS`
|
||||
if method in ['POST', 'PUT', 'PATCH', 'OPTIONS']:
|
||||
if query_params:
|
||||
url += '?' + urlencode(query_params)
|
||||
if headers['Content-Type'] == 'application/json':
|
||||
@ -172,6 +172,13 @@ class RESTClientObject(object):
|
||||
headers=headers,
|
||||
query_params=query_params)
|
||||
|
||||
def OPTIONS(self, url, headers=None, query_params=None, post_params=None, body=None):
|
||||
return self.request("OPTIONS", url,
|
||||
headers=headers,
|
||||
query_params=query_params,
|
||||
post_params=post_params,
|
||||
body=body)
|
||||
|
||||
def DELETE(self, url, headers=None, query_params=None):
|
||||
return self.request("DELETE", url,
|
||||
headers=headers,
|
||||
@ -226,22 +233,3 @@ class ApiException(Exception):
|
||||
error_message += "HTTP response body: {0}\n".format(self.body)
|
||||
|
||||
return error_message
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user