Merge remote-tracking branch 'refs/remotes/swagger-api/master' into fix-java-warnings

# Conflicts:

#	modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JaxRSServerCodegen.java
This commit is contained in:
Maelig Nantel 2016-01-18 10:10:27 +01:00
commit a39942f43f
31 changed files with 272 additions and 37 deletions

4
.gitignore vendored
View File

@ -59,6 +59,7 @@ samples/client/petstore/perl/deep_module_test/
samples/client/petstore/python/.projectile samples/client/petstore/python/.projectile
samples/client/petstore/python/.venv/ samples/client/petstore/python/.venv/
samples/client/petstore/python/dev-requirements.txt.log
.settings .settings
@ -67,3 +68,6 @@ samples/client/petstore/python/.venv/
*.pm~ *.pm~
*.xml~ *.xml~
*.t~ *.t~
samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/
samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/

View File

@ -63,7 +63,7 @@ Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes
### Prerequisites ### Prerequisites
If you're looking for the latest stable version, you can grab it directly from maven central (you'll need the java 7 runtime): If you're looking for the latest stable version, you can grab it directly from maven central (you'll need java 7 runtime at a minimum):
``` ```
wget http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.1.4/swagger-codegen-cli-2.1.4.jar swagger-codegen-cli.jar wget http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.1.4/swagger-codegen-cli-2.1.4.jar swagger-codegen-cli.jar
@ -237,16 +237,15 @@ This will write, in the folder `output/myLibrary`, all the files you need to get
You would then compile your library in the `output/myLibrary` folder with `mvn package` and execute the codegen like such: You would then compile your library in the `output/myLibrary` folder with `mvn package` and execute the codegen like such:
``` ```
java -cp output/myLibrary/target/myClientCodegen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar io.swagger.codegen.Codegen java -cp output/myLibrary/target/myClientCodegen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar io.swagger.codegen.SwaggerCodegen
``` ```
Note the `myClientCodegen` is an option now, and you can use the usual arguments for generating your library: Note the `myClientCodegen` is an option now, and you can use the usual arguments for generating your library:
``` ```
java -cp output/myLibrary/target/myClientCodegen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar \ java -cp output/myLibrary/target/myClientCodegen-swagger-codegen-1.0.0.jar:modules/swagger-codegen-cli/target/swagger-codegen-cli.jar \
io.swagger.codegen.Codegen generate -l myClientCodegen\ io.swagger.codegen.SwaggerCodegen generate -l myClientCodegen\
-i http://petstore.swagger.io/v2/swagger.json \ -i http://petstore.swagger.io/v2/swagger.json \
-o myClient -o myClient
``` ```

View File

@ -52,7 +52,9 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
typeMapping.put("integer", "number"); typeMapping.put("integer", "number");
typeMapping.put("Map", "any"); typeMapping.put("Map", "any");
typeMapping.put("DateTime", "Date"); typeMapping.put("DateTime", "Date");
//TODO binary should be mapped to byte array
// mapped to String as a workaround
typeMapping.put("binary", "string");
} }
@Override @Override

View File

@ -76,6 +76,9 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("Date", "DateTime"); typeMapping.put("Date", "DateTime");
typeMapping.put("date", "DateTime"); typeMapping.put("date", "DateTime");
typeMapping.put("File", "MultipartFile"); 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(BROWSER_CLIENT, "Is the client browser based"));
cliOptions.add(new CliOption(PUB_NAME, "Name in generated pubspec")); cliOptions.add(new CliOption(PUB_NAME, "Name in generated pubspec"));

View File

@ -63,6 +63,9 @@ public class FlashClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("DateTime", "Date"); typeMapping.put("DateTime", "Date");
typeMapping.put("object", "Object"); typeMapping.put("object", "Object");
typeMapping.put("file", "File"); 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 = new HashMap<String, String>();
importMapping.put("File", "flash.filesystem.File"); importMapping.put("File", "flash.filesystem.File");

View File

@ -21,7 +21,9 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(JavaClientCodegen.class); private static final Logger LOGGER = LoggerFactory.getLogger(JavaClientCodegen.class);
public static final String FULL_JAVA_UTIL = "fullJavaUtil"; public static final String FULL_JAVA_UTIL = "fullJavaUtil";
public static final String DEFAULT_LIBRARY = "<default>"; public static final String DEFAULT_LIBRARY = "<default>";
public static final String DATE_LIBRARY = "dateLibrary";
protected String dateLibrary = "default";
protected String invokerPackage = "io.swagger.client"; protected String invokerPackage = "io.swagger.client";
protected String groupId = "io.swagger"; protected String groupId = "io.swagger";
protected String artifactId = "swagger-java-client"; protected String artifactId = "swagger-java-client";
@ -98,6 +100,14 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
library.setEnum(supportedLibraries); library.setEnum(supportedLibraries);
library.setDefault(DEFAULT_LIBRARY); library.setDefault(DEFAULT_LIBRARY);
cliOptions.add(library); cliOptions.add(library);
CliOption dateLibrary = new CliOption(DATE_LIBRARY, "Option. Date library to use");
Map<String, String> dateOptions = new HashMap<String, String>();
dateOptions.put("java8", "Java 8 native");
dateOptions.put("joda", "Joda");
dateLibrary.setEnum(dateOptions);
cliOptions.add(dateLibrary);
} }
@Override @Override
@ -253,6 +263,26 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
} else if("jersey2".equals(getLibrary())) { } else if("jersey2".equals(getLibrary())) {
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java")); supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
} }
if(additionalProperties.containsKey(DATE_LIBRARY)) {
this.dateLibrary = additionalProperties.get(DATE_LIBRARY).toString();
}
if("joda".equals(dateLibrary)) {
typeMapping.put("date", "LocalDate");
typeMapping.put("DateTime", "DateTime");
importMapping.put("LocalDate", "org.joda.time.LocalDate");
importMapping.put("DateTime", "org.joda.time.DateTime");
}
else if ("java8".equals(dateLibrary)) {
additionalProperties.put("java8", "true");
additionalProperties.put("javaVersion", "1.8");
typeMapping.put("date", "LocalDate");
typeMapping.put("DateTime", "LocalDateTime");
importMapping.put("LocalDate", "java.time.LocalDate");
importMapping.put("LocalDateTime", "java.time.LocalDateTime");
}
} }
private void sanitizeConfig() { private void sanitizeConfig() {
@ -761,4 +791,8 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
public void setFullJavaUtil(boolean fullJavaUtil) { public void setFullJavaUtil(boolean fullJavaUtil) {
this.fullJavaUtil = fullJavaUtil; this.fullJavaUtil = fullJavaUtil;
} }
public void setDateLibrary(String library) {
this.dateLibrary = library;
}
} }

View File

@ -71,6 +71,9 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("array", "ARRAY"); typeMapping.put("array", "ARRAY");
typeMapping.put("map", "HASH"); typeMapping.put("map", "HASH");
typeMapping.put("object", "object"); 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.clear();
cliOptions.add(new CliOption(MODULE_NAME, "Perl module name (convention: CamelCase or Long::Module).").defaultValue("SwaggerClient")); cliOptions.add(new CliOption(MODULE_NAME, "Perl module name (convention: CamelCase or Long::Module).").defaultValue("SwaggerClient"));

View File

@ -51,6 +51,9 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("DateTime", "datetime"); typeMapping.put("DateTime", "datetime");
typeMapping.put("object", "object"); typeMapping.put("object", "object");
typeMapping.put("file", "file"); 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 // from https://docs.python.org/release/2.5.4/ref/keywords.html
reservedWords = new HashSet<String>( reservedWords = new HashSet<String>(

View File

@ -121,6 +121,9 @@ public class Qt5CPPGenerator extends DefaultCodegen implements CodegenConfig {
typeMapping.put("map", "QMap"); typeMapping.put("map", "QMap");
typeMapping.put("file", "SWGHttpRequestInputFileElement"); typeMapping.put("file", "SWGHttpRequestInputFileElement");
typeMapping.put("object", PREFIX + "Object"); 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>(); importMapping = new HashMap<String, String>();

View File

@ -96,6 +96,9 @@ public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("double", "Double"); typeMapping.put("double", "Double");
typeMapping.put("object", "Any"); typeMapping.put("object", "Any");
typeMapping.put("file", "File"); 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>( languageSpecificPrimitives = new HashSet<String>(
Arrays.asList( Arrays.asList(

View File

@ -67,6 +67,9 @@ public class ScalatraServerCodegen extends DefaultCodegen implements CodegenConf
typeMapping.put("integer", "Int"); typeMapping.put("integer", "Int");
typeMapping.put("long", "Long"); 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");
additionalProperties.put("appName", "Swagger Sample"); additionalProperties.put("appName", "Swagger Sample");

View File

@ -81,6 +81,9 @@ public class SilexServerCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("array", "array"); typeMapping.put("array", "array");
typeMapping.put("list", "array"); typeMapping.put("list", "array");
typeMapping.put("object", "object"); 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("README.mustache", packagePath.replace('/', File.separatorChar), "README.md"));
supportingFiles.add(new SupportingFile("composer.json", packagePath.replace('/', File.separatorChar), "composer.json")); supportingFiles.add(new SupportingFile("composer.json", packagePath.replace('/', File.separatorChar), "composer.json"));

View File

@ -57,6 +57,9 @@ public class SinatraServerCodegen extends DefaultCodegen implements CodegenConfi
typeMapping.put("String", "string"); typeMapping.put("String", "string");
typeMapping.put("List", "array"); typeMapping.put("List", "array");
typeMapping.put("map", "map"); 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 // remove modelPackage and apiPackage added by default
cliOptions.clear(); cliOptions.clear();

View File

@ -83,6 +83,9 @@ public class SlimFrameworkServerCodegen extends DefaultCodegen implements Codege
typeMapping.put("array", "array"); typeMapping.put("array", "array");
typeMapping.put("list", "array"); typeMapping.put("list", "array");
typeMapping.put("object", "object"); 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("README.mustache", packagePath.replace('/', File.separatorChar), "README.md"));
supportingFiles.add(new SupportingFile("composer.json", packagePath.replace('/', File.separatorChar), "composer.json")); supportingFiles.add(new SupportingFile("composer.json", packagePath.replace('/', File.separatorChar), "composer.json"));

View File

@ -120,6 +120,9 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("double", "Double"); typeMapping.put("double", "Double");
typeMapping.put("object", "String"); typeMapping.put("object", "String");
typeMapping.put("file", "NSURL"); 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>(); importMapping = new HashMap<String, String>();

View File

@ -76,6 +76,9 @@ public class TizenClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("map", "HashMap"); typeMapping.put("map", "HashMap");
typeMapping.put("number", "Long"); typeMapping.put("number", "Long");
typeMapping.put("object", PREFIX + "Object"); 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>(); importMapping = new HashMap<String, String>();

View File

@ -1 +1 @@
{{#isQueryParam}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}} {{#isQueryParam}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @DefaultValue("{{defaultValue}}") @QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}}

View File

@ -38,7 +38,7 @@ namespace {{packageName}}.Client
) )
{ {
if (apiClient == null) if (apiClient == null)
ApiClient = ApiClient.Default; ApiClient = ApiClient.Default == null ? new ApiClient() : ApiClient.Default;
else else
ApiClient = apiClient; ApiClient = apiClient;

View File

@ -39,6 +39,7 @@ public class JavaOptionsProvider implements OptionsProvider {
.put(JavaClientCodegen.FULL_JAVA_UTIL, FULL_JAVA_UTIL_VALUE) .put(JavaClientCodegen.FULL_JAVA_UTIL, FULL_JAVA_UTIL_VALUE)
.put(CodegenConstants.LIBRARY, LIBRARY_VALUE) .put(CodegenConstants.LIBRARY, LIBRARY_VALUE)
.put(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING, "true") .put(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING, "true")
.put(JavaClientCodegen.DATE_LIBRARY, "joda")
.build(); .build();
} }

View File

@ -1,7 +1,6 @@
package io.swagger.codegen.options; package io.swagger.codegen.options;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import io.swagger.codegen.languages.JaxRSServerCodegen;
import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenConstants;
import java.util.Map; import java.util.Map;
@ -26,8 +25,7 @@ public class JaxRSServerOptionsProvider extends JavaOptionsProvider {
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>(); ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
builder.putAll(options) builder.putAll(options)
.put(CodegenConstants.IMPL_FOLDER, IMPL_FOLDER_VALUE) .put(CodegenConstants.IMPL_FOLDER, IMPL_FOLDER_VALUE);
.put(JaxRSServerCodegen.DATE_LIBRARY, "joda");
return builder.build(); return builder.build();
} }

View File

@ -38,7 +38,7 @@ namespace IO.Swagger.Client
) )
{ {
if (apiClient == null) if (apiClient == null)
ApiClient = ApiClient.Default; ApiClient = ApiClient.Default == null ? new ApiClient() : ApiClient.Default;
else else
ApiClient = apiClient; ApiClient = apiClient;

View File

@ -1,18 +1,9 @@
/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs /Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs
/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.swagger-logo.png /Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.swagger-logo.png
/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb /Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb
/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll /Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll
/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll /Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll
/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb /Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb
/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll /Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll
/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll /Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll
/Users/williamcheng/Code/tmp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll /Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.swagger-logo.png
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll

View File

@ -8,7 +8,7 @@ WWW::SwaggerClient::Role - a Moose role for the Swagger Petstore
Automatically generated by the Perl Swagger Codegen project: 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 - Build package: class io.swagger.codegen.languages.PerlClientCodegen
- Codegen version: - Codegen version:

View File

@ -37,7 +37,7 @@ has version_info => ( is => 'ro',
default => sub { { default => sub { {
app_name => 'Swagger Petstore', app_name => 'Swagger Petstore',
app_version => '1.0.0', 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', generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen',
} }, } },
documentation => 'Information about the application version and the codegen codebase version' 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 =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 =item Build package: class io.swagger.codegen.languages.PerlClientCodegen

View File

@ -50,7 +50,7 @@ is $get_pet->tags->[0]->id, '11', 'stored and retrieved: got the proper tag id';
# API method docs # API method docs
is_deeply( [sort keys %{$api->pet_api->method_documentation}], 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"); "Pet API method_documentation has the correct keys");
is $api->pet_api->method_documentation->{get_pet_by_id}->{params}->{pet_id}->{description}, 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'; '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

View File

@ -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): 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): 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)) 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

View File

@ -679,3 +679,158 @@ class PetApi(object):
auth_settings=auth_settings, auth_settings=auth_settings,
callback=params.get('callback')) callback=params.get('callback'))
return response 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