mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 19:33:55 +00:00
fix indent, update perl & python sample
This commit is contained in:
parent
f4639f4b7b
commit
275269e72a
1
.gitignore
vendored
1
.gitignore
vendored
@ -59,6 +59,7 @@ samples/client/petstore/perl/deep_module_test/
|
||||
|
||||
samples/client/petstore/python/.projectile
|
||||
samples/client/petstore/python/.venv/
|
||||
samples/client/petstore/python/dev-requirements.txt.log
|
||||
|
||||
.settings
|
||||
|
||||
|
@ -52,7 +52,7 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
typeMapping.put("integer", "number");
|
||||
typeMapping.put("Map", "any");
|
||||
typeMapping.put("DateTime", "Date");
|
||||
//TODO binary should be mapped to byte array
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "string");
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ WWW::SwaggerClient::Role - a Moose role for the Swagger Petstore
|
||||
|
||||
Automatically generated by the Perl Swagger Codegen project:
|
||||
|
||||
- Build date: 2016-01-15T15:57:32.150+08:00
|
||||
- Build date: 2016-01-17T19:21:19.346+08:00
|
||||
- Build package: class io.swagger.codegen.languages.PerlClientCodegen
|
||||
- Codegen version:
|
||||
|
||||
|
@ -37,7 +37,7 @@ has version_info => ( is => 'ro',
|
||||
default => sub { {
|
||||
app_name => 'Swagger Petstore',
|
||||
app_version => '1.0.0',
|
||||
generated_date => '2016-01-15T15:57:32.150+08:00',
|
||||
generated_date => '2016-01-17T19:21:19.346+08:00',
|
||||
generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen',
|
||||
} },
|
||||
documentation => 'Information about the application version and the codegen codebase version'
|
||||
@ -103,7 +103,7 @@ Automatically generated by the Perl Swagger Codegen project:
|
||||
|
||||
=over 4
|
||||
|
||||
=item Build date: 2016-01-15T15:57:32.150+08:00
|
||||
=item Build date: 2016-01-17T19:21:19.346+08:00
|
||||
|
||||
=item Build package: class io.swagger.codegen.languages.PerlClientCodegen
|
||||
|
||||
|
@ -50,7 +50,7 @@ is $get_pet->tags->[0]->id, '11', 'stored and retrieved: got the proper tag id';
|
||||
|
||||
# API method docs
|
||||
is_deeply( [sort keys %{$api->pet_api->method_documentation}],
|
||||
[ 'add_pet', 'delete_pet', 'find_pets_by_status', 'find_pets_by_tags', 'get_pet_by_id', 'update_pet', 'update_pet_with_form', 'upload_file'],
|
||||
[ 'add_pet', 'add_pet_using_byte_array', 'delete_pet', 'find_pets_by_status', 'find_pets_by_tags', 'get_pet_by_id', 'get_pet_by_id_with_byte_array', 'update_pet', 'update_pet_with_form', 'upload_file'],
|
||||
"Pet API method_documentation has the correct keys");
|
||||
is $api->pet_api->method_documentation->{get_pet_by_id}->{params}->{pet_id}->{description},
|
||||
'ID of pet that needs to be fetched', 'get_pet_by_id parameter pet_id description is correct';
|
||||
|
File diff suppressed because one or more lines are too long
@ -146,3 +146,18 @@ Requirement already satisfied (use --upgrade to upgrade): randomize in /private/
|
||||
Requirement already satisfied (use --upgrade to upgrade): virtualenv>=1.11.2 in /private/var/tmp/pr/Tengah/swagger-codegen/samples/client/petstore/python/venv/lib/python2.7/site-packages (from tox->-r dev-requirements.txt (line 2))
|
||||
Requirement already satisfied (use --upgrade to upgrade): py>=1.4.17 in /private/var/tmp/pr/Tengah/swagger-codegen/samples/client/petstore/python/venv/lib/python2.7/site-packages (from tox->-r dev-requirements.txt (line 2))
|
||||
Requirement already satisfied (use --upgrade to upgrade): pluggy<0.4.0,>=0.3.0 in /private/var/tmp/pr/Tengah/swagger-codegen/samples/client/petstore/python/venv/lib/python2.7/site-packages (from tox->-r dev-requirements.txt (line 2))
|
||||
Collecting nose (from -r dev-requirements.txt (line 1))
|
||||
Using cached nose-1.3.7-py2-none-any.whl
|
||||
Collecting tox (from -r dev-requirements.txt (line 2))
|
||||
Using cached tox-2.3.1-py2.py3-none-any.whl
|
||||
Collecting coverage (from -r dev-requirements.txt (line 3))
|
||||
Collecting randomize (from -r dev-requirements.txt (line 4))
|
||||
Using cached randomize-0.13-py2.py3-none-any.whl
|
||||
Collecting virtualenv>=1.11.2 (from tox->-r dev-requirements.txt (line 2))
|
||||
Using cached virtualenv-13.1.2-py2.py3-none-any.whl
|
||||
Collecting py>=1.4.17 (from tox->-r dev-requirements.txt (line 2))
|
||||
Using cached py-1.4.31-py2.py3-none-any.whl
|
||||
Collecting pluggy<0.4.0,>=0.3.0 (from tox->-r dev-requirements.txt (line 2))
|
||||
Using cached pluggy-0.3.1-py2.py3-none-any.whl
|
||||
Installing collected packages: nose, virtualenv, py, pluggy, tox, coverage, randomize
|
||||
Successfully installed coverage-4.0.3 nose-1.3.7 pluggy-0.3.1 py-1.4.31 randomize-0.13 tox-2.3.1 virtualenv-13.1.2
|
||||
|
@ -679,3 +679,158 @@ class PetApi(object):
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'))
|
||||
return response
|
||||
|
||||
def get_pet_by_id_with_byte_array(self, pet_id, **kwargs):
|
||||
"""
|
||||
Fake endpoint to test byte array return by 'Find pet by ID'
|
||||
Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||
|
||||
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.get_pet_by_id_with_byte_array(pet_id, callback=callback_function)
|
||||
|
||||
:param callback function: The callback function
|
||||
for asynchronous request. (optional)
|
||||
:param int pet_id: ID of pet that needs to be fetched (required)
|
||||
:return: Binary
|
||||
If the method is called asynchronously,
|
||||
returns the request thread.
|
||||
"""
|
||||
|
||||
all_params = ['pet_id']
|
||||
all_params.append('callback')
|
||||
|
||||
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 get_pet_by_id_with_byte_array" % key
|
||||
)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
# verify the required parameter 'pet_id' is set
|
||||
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_with_byte_array`")
|
||||
|
||||
resource_path = '/pet/{petId}?testing_byte_array=true'.replace('{format}', 'json')
|
||||
method = 'GET'
|
||||
|
||||
path_params = {}
|
||||
if 'pet_id' in params:
|
||||
path_params['petId'] = params['pet_id']
|
||||
|
||||
query_params = {}
|
||||
|
||||
header_params = {}
|
||||
|
||||
form_params = {}
|
||||
files = {}
|
||||
|
||||
body_params = None
|
||||
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.\
|
||||
select_header_accept(['application/json', 'application/xml'])
|
||||
if not header_params['Accept']:
|
||||
del header_params['Accept']
|
||||
|
||||
# HTTP header `Content-Type`
|
||||
header_params['Content-Type'] = self.api_client.\
|
||||
select_header_content_type([])
|
||||
|
||||
# Authentication setting
|
||||
auth_settings = ['api_key']
|
||||
|
||||
response = self.api_client.call_api(resource_path, method,
|
||||
path_params,
|
||||
query_params,
|
||||
header_params,
|
||||
body=body_params,
|
||||
post_params=form_params,
|
||||
files=files,
|
||||
response_type='Binary',
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'))
|
||||
return response
|
||||
|
||||
def add_pet_using_byte_array(self, **kwargs):
|
||||
"""
|
||||
Fake endpoint to test byte array in body parameter for adding a new pet to the store
|
||||
|
||||
|
||||
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.add_pet_using_byte_array(callback=callback_function)
|
||||
|
||||
:param callback function: The callback function
|
||||
for asynchronous request. (optional)
|
||||
:param Binary body: Pet object in the form of byte array
|
||||
:return: None
|
||||
If the method is called asynchronously,
|
||||
returns the request thread.
|
||||
"""
|
||||
|
||||
all_params = ['body']
|
||||
all_params.append('callback')
|
||||
|
||||
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 add_pet_using_byte_array" % key
|
||||
)
|
||||
params[key] = val
|
||||
del params['kwargs']
|
||||
|
||||
|
||||
resource_path = '/pet?testing_byte_array=true'.replace('{format}', 'json')
|
||||
method = 'POST'
|
||||
|
||||
path_params = {}
|
||||
|
||||
query_params = {}
|
||||
|
||||
header_params = {}
|
||||
|
||||
form_params = {}
|
||||
files = {}
|
||||
|
||||
body_params = None
|
||||
if 'body' in params:
|
||||
body_params = params['body']
|
||||
|
||||
# HTTP header `Accept`
|
||||
header_params['Accept'] = self.api_client.\
|
||||
select_header_accept(['application/json', 'application/xml'])
|
||||
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', 'application/xml'])
|
||||
|
||||
# Authentication setting
|
||||
auth_settings = ['petstore_auth']
|
||||
|
||||
response = self.api_client.call_api(resource_path, method,
|
||||
path_params,
|
||||
query_params,
|
||||
header_params,
|
||||
body=body_params,
|
||||
post_params=form_params,
|
||||
files=files,
|
||||
response_type=None,
|
||||
auth_settings=auth_settings,
|
||||
callback=params.get('callback'))
|
||||
return response
|
||||
|
Loading…
Reference in New Issue
Block a user