From 4479382ced52f37cc62e5245230e5d9d508bc790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20C=C3=B4t=C3=A9?= Date: Thu, 18 May 2017 04:19:48 -0400 Subject: [PATCH] [Java Play Framework] Fix conversions (#5604) * First commit of the Java Play Framework server generator. It is highly based on Spring so there might me a couple of things that don't make sense (like options or parameters) for the Play Framework. * Fix suggestions in the PR discussion + add .bat and .sh file as requested. * Updated Readme.md file * Remove unused mustache file + fix baseName vs paramName in all the mustache files. * Fix the compilation error when we have a body which is a list or map. Doesn't fix the problem with the annotation itself. * Fix the problem with the Http.MultipartFormData.FilePart * Fix the conversion of boolean type * Add samples for the fix with the boolean * Fix bugs introduced by polci related to the bean validation. * Refactor to use the "beanValidationCore". Asked by @wing328 --- .../resources/JavaPlayFramework/beanValidationCore.mustache | 1 + .../JavaPlayFramework/beanValidationPathParams.mustache | 2 +- .../JavaPlayFramework/beanValidationQueryParams.mustache | 2 +- .../main/resources/JavaPlayFramework/conversionBegin.mustache | 2 +- .../petstore/java-play-framework/.swagger-codegen/VERSION | 1 + 5 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 modules/swagger-codegen/src/main/resources/JavaPlayFramework/beanValidationCore.mustache create mode 100644 samples/server/petstore/java-play-framework/.swagger-codegen/VERSION diff --git a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/beanValidationCore.mustache b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/beanValidationCore.mustache new file mode 100644 index 000000000000..66c525832124 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/beanValidationCore.mustache @@ -0,0 +1 @@ +{{#pattern}} @Pattern(regexp="{{{pattern}}}"){{/pattern}}{{#minLength}}{{#maxLength}} @Size(min={{minLength}},max={{maxLength}}){{/maxLength}}{{/minLength}}{{#minLength}}{{^maxLength}} @Size(min={{minLength}}){{/maxLength}}{{/minLength}}{{^minLength}}{{#maxLength}} @Size(max={{maxLength}}){{/maxLength}}{{/minLength}}{{#minItems}}{{#maxItems}} @Size(min={{minItems}},max={{maxItems}}){{/maxItems}}{{/minItems}}{{#minItems}}{{^maxItems}} @Size(min={{minItems}}){{/maxItems}}{{/minItems}}{{^minItems}}{{#maxItems}} @Size(max={{maxItems}}){{/maxItems}}{{/minItems}}{{#minimum}} @Min({{minimum}}){{/minimum}}{{#maximum}} @Max({{maximum}}){{/maximum}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/beanValidationPathParams.mustache b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/beanValidationPathParams.mustache index 0b4d31b4bf10..051bd53c0a58 100644 --- a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/beanValidationPathParams.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/beanValidationPathParams.mustache @@ -1 +1 @@ -{{! PathParam is always required, no @NotNull necessary }}{{#pattern}} @Pattern(regexp="{{{pattern}}}"){{/pattern}}{{#minLength}}{{#maxLength}} @Size(min={{minLength}},max={{maxLength}}){{/maxLength}}{{/minLength}}{{#minLength}}{{^maxLength}} @Size(min={{minLength}}){{/maxLength}}{{/minLength}}{{^minLength}}{{#maxLength}} @Size(max={{maxLength}}){{/maxLength}}{{/minLength}}{{#minItems}}{{#maxItems}} @Size(min={{minItems}},max={{maxItems}}){{/maxItems}}{{/minItems}}{{#minItems}}{{^maxItems}} @Size(min={{minItems}}){{/maxItems}}{{/minItems}}{{^minItems}}{{#maxItems}} @Size(max={{maxItems}}){{/maxItems}}{{/minItems}}{{#minimum}} @Min({{minimum}}){{/minimum}}{{#maximum}} @Max({{maximum}}){{/maximum}} \ No newline at end of file +{{! PathParam is always required, no @NotNull necessary }}{{>beanValidationCore}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/beanValidationQueryParams.mustache b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/beanValidationQueryParams.mustache index 4bad1be63686..0f99bffde09c 100644 --- a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/beanValidationQueryParams.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/beanValidationQueryParams.mustache @@ -1 +1 @@ -{{#required}} @NotNull{{/required}}{{#pattern}} @Pattern(regexp="{{{pattern}}}"){{/pattern}}{{#minLength}}{{#maxLength}} @Size(min={{minLength}},max={{maxLength}}){{/maxLength}}{{/minLength}}{{#minLength}}{{^maxLength}} @Size(min={{minLength}}){{/maxLength}}{{/minLength}}{{^minLength}}{{#maxLength}} @Size(max={{maxLength}}){{/maxLength}}{{/minLength}}{{#minItems}}{{#maxItems}} @Size(min={{minItems}},max={{maxItems}}){{/maxItems}}{{/minItems}}{{#minItems}}{{^maxItems}} @Size(min={{minItems}}){{/maxItems}}{{/minItems}}{{^minItems}}{{#maxItems}} @Size(max={{maxItems}}){{/maxItems}}{{/minItems}}{{#minimum}} @Min({{minimum}}){{/minimum}}{{#maximum}} @Max({{maximum}}){{/maximum}} \ No newline at end of file +{{#required}} @NotNull {{/required}}{{>beanValidationCore}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/conversionBegin.mustache b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/conversionBegin.mustache index a931bc896f87..1f0301989210 100644 --- a/modules/swagger-codegen/src/main/resources/JavaPlayFramework/conversionBegin.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaPlayFramework/conversionBegin.mustache @@ -1 +1 @@ -{{#isBoolean}}Boolean.getBoolean({{/isBoolean}}{{#isInteger}}Integer.parseInt({{/isInteger}}{{#isDouble}}Double.parseDouble({{/isDouble}}{{#isLong}}Long.parseLong({{/isLong}}{{#isFloat}}Float.parseFloat({{/isFloat}}{{#isString}}(String){{/isString}} \ No newline at end of file +{{#isBoolean}}Boolean.valueOf({{/isBoolean}}{{#isInteger}}Integer.parseInt({{/isInteger}}{{#isDouble}}Double.parseDouble({{/isDouble}}{{#isLong}}Long.parseLong({{/isLong}}{{#isFloat}}Float.parseFloat({{/isFloat}}{{#isString}}(String){{/isString}} \ No newline at end of file diff --git a/samples/server/petstore/java-play-framework/.swagger-codegen/VERSION b/samples/server/petstore/java-play-framework/.swagger-codegen/VERSION new file mode 100644 index 000000000000..7fea99011a6f --- /dev/null +++ b/samples/server/petstore/java-play-framework/.swagger-codegen/VERSION @@ -0,0 +1 @@ +2.2.3-SNAPSHOT \ No newline at end of file