mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 02:55:19 +00:00
Merge pull request #1911 from wing328/mapping_update_binary
Add "binary" mapping in code generators
This commit is contained in:
commit
7b1dde3d85
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,9 @@ 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
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "string");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,6 +76,9 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
typeMapping.put("Date", "DateTime");
|
||||
typeMapping.put("date", "DateTime");
|
||||
typeMapping.put("File", "MultipartFile");
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "String");
|
||||
|
||||
cliOptions.add(new CliOption(BROWSER_CLIENT, "Is the client browser based"));
|
||||
cliOptions.add(new CliOption(PUB_NAME, "Name in generated pubspec"));
|
||||
|
@ -63,6 +63,9 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
typeMapping.put("DateTime", "Date");
|
||||
typeMapping.put("object", "Object");
|
||||
typeMapping.put("file", "File");
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "String");
|
||||
|
||||
importMapping = new HashMap<String, String>();
|
||||
importMapping.put("File", "flash.filesystem.File");
|
||||
|
@ -72,6 +72,9 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
typeMapping.put("array", "ARRAY");
|
||||
typeMapping.put("map", "HASH");
|
||||
typeMapping.put("object", "object");
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "string");
|
||||
|
||||
cliOptions.clear();
|
||||
cliOptions.add(new CliOption(MODULE_NAME, "Perl module name (convention: CamelCase or Long::Module).").defaultValue("SwaggerClient"));
|
||||
|
@ -51,6 +51,9 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
typeMapping.put("DateTime", "datetime");
|
||||
typeMapping.put("object", "object");
|
||||
typeMapping.put("file", "file");
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "str");
|
||||
|
||||
// from https://docs.python.org/release/2.5.4/ref/keywords.html
|
||||
reservedWords = new HashSet<String>(
|
||||
|
@ -121,6 +121,9 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
|
||||
typeMapping.put("map", "QMap");
|
||||
typeMapping.put("file", "SWGHttpRequestInputFileElement");
|
||||
typeMapping.put("object", PREFIX + "Object");
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "QString");
|
||||
|
||||
importMapping = new HashMap<String, String>();
|
||||
|
||||
|
@ -96,6 +96,9 @@ public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
typeMapping.put("double", "Double");
|
||||
typeMapping.put("object", "Any");
|
||||
typeMapping.put("file", "File");
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "String");
|
||||
|
||||
languageSpecificPrimitives = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
|
@ -67,6 +67,9 @@ public class ScalatraServerCodegen extends DefaultCodegen implements CodegenConf
|
||||
|
||||
typeMapping.put("integer", "Int");
|
||||
typeMapping.put("long", "Long");
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "String");
|
||||
|
||||
additionalProperties.put("appName", "Swagger Sample");
|
||||
additionalProperties.put("appName", "Swagger Sample");
|
||||
|
@ -81,6 +81,9 @@ public class SilexServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
typeMapping.put("array", "array");
|
||||
typeMapping.put("list", "array");
|
||||
typeMapping.put("object", "object");
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "string");
|
||||
|
||||
supportingFiles.add(new SupportingFile("README.mustache", packagePath.replace('/', File.separatorChar), "README.md"));
|
||||
supportingFiles.add(new SupportingFile("composer.json", packagePath.replace('/', File.separatorChar), "composer.json"));
|
||||
|
@ -60,6 +60,9 @@ public class SinatraServerCodegen extends DefaultCodegen implements CodegenConfi
|
||||
typeMapping.put("String", "string");
|
||||
typeMapping.put("List", "array");
|
||||
typeMapping.put("map", "map");
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "string");
|
||||
|
||||
// remove modelPackage and apiPackage added by default
|
||||
cliOptions.clear();
|
||||
|
@ -83,6 +83,9 @@ public class SlimFrameworkServerCodegen extends DefaultCodegen implements Codege
|
||||
typeMapping.put("array", "array");
|
||||
typeMapping.put("list", "array");
|
||||
typeMapping.put("object", "object");
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "string");
|
||||
|
||||
supportingFiles.add(new SupportingFile("README.mustache", packagePath.replace('/', File.separatorChar), "README.md"));
|
||||
supportingFiles.add(new SupportingFile("composer.json", packagePath.replace('/', File.separatorChar), "composer.json"));
|
||||
|
@ -120,6 +120,9 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
typeMapping.put("double", "Double");
|
||||
typeMapping.put("object", "String");
|
||||
typeMapping.put("file", "NSURL");
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "String");
|
||||
|
||||
importMapping = new HashMap<String, String>();
|
||||
|
||||
|
@ -76,6 +76,9 @@ public class TizenClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
typeMapping.put("map", "HashMap");
|
||||
typeMapping.put("number", "Long");
|
||||
typeMapping.put("object", PREFIX + "Object");
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "String");
|
||||
|
||||
importMapping = new HashMap<String, 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