From bf74de3a5ae04f69900396e17a011ad7e93ed69e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20C=C3=B4t=C3=A9?= Date: Mon, 17 Jul 2017 04:51:02 -0400 Subject: [PATCH] [Java Play Framework] Fix to the default values (#5879) * Fix to the default values. It did not take care of the "default" and also was setting to a bad default when not set. * Just make a difference between string and non string instead of placing all types in the mustache file --- .../JavaPlayFramework/paramDefaultValue.mustache | 2 +- .../app/controllers/PetApiController.java | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/paramDefaultValue.mustache b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/paramDefaultValue.mustache index 733d31a6d72..a5587249639 100644 --- a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/paramDefaultValue.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/paramDefaultValue.mustache @@ -1 +1 @@ -{{#isBoolean}}false{{/isBoolean}}{{#isInteger}}0{{/isInteger}}{{#isDouble}}0.0{{/isDouble}}{{#isLong}}0L{{/isLong}}{{#isFloat}}0.0{{/isFloat}}{{#isString}}""{{/isString}} \ No newline at end of file +{{#defaultValue}}{{#isString}}"{{/isString}}{{{defaultValue}}}{{#isString}}"{{/isString}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java b/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java index 4ee0a235890..c36fe77e3dd 100644 --- a/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java +++ b/samples/server/petstore/java-play-framework/app/controllers/PetApiController.java @@ -53,7 +53,7 @@ public class PetApiController extends Controller { apiKey = (String)valueapiKey; } else { - apiKey = ""; + apiKey = null; } imp.deletePet(petId, apiKey); @@ -116,7 +116,7 @@ public class PetApiController extends Controller { name = (String)valuename; } else { - name = ""; + name = null; } String valuestatus = (request().body().asMultipartFormData().asFormUrlEncoded().get("status"))[0]; String status; @@ -124,7 +124,7 @@ public class PetApiController extends Controller { status = (String)valuestatus; } else { - status = ""; + status = null; } imp.updatePetWithForm(petId, name, status); @@ -139,7 +139,7 @@ public class PetApiController extends Controller { additionalMetadata = (String)valueadditionalMetadata; } else { - additionalMetadata = ""; + additionalMetadata = null; } Http.MultipartFormData.FilePart file = request().body().asMultipartFormData().getFile("file"); ModelApiResponse obj = imp.uploadFile(petId, additionalMetadata, file);