From 701b295fb288cef91d4c4d1047e01391ce0d230f Mon Sep 17 00:00:00 2001 From: Fyro Date: Mon, 26 Dec 2022 18:42:48 +0100 Subject: [PATCH 1/8] add jakarta implementation https://github.com/swagger-api/swagger-codegen-generators/issues/1054 --- .../generators/java/AbstractJavaCodegen.java | 19 +++++++++++++++++++ .../handlebars/Java/ApiClient.mustache | 6 ++++++ .../Java/BeanValidationException.mustache | 7 ++++++- .../handlebars/Java/build.gradle.mustache | 2 +- .../Java/generatedAnnotation.mustache | 2 +- .../libraries/feign/build.gradle.mustache | 2 +- .../Java/libraries/jersey2/ApiClient.mustache | 14 ++++++++++++++ .../Java/libraries/jersey2/JSON.mustache | 5 +++++ .../Java/libraries/jersey2/api.mustache | 5 +++++ .../libraries/jersey2/build.gradle.mustache | 2 +- .../Java/libraries/jersey2/pom.mustache | 6 +++--- .../Java/libraries/okhttp-gson/api.mustache | 15 ++++++++++++++- .../okhttp-gson/build.gradle.mustache | 2 +- .../Java/libraries/okhttp-gson/pom.mustache | 8 ++++---- .../libraries/resteasy/ApiClient.mustache | 14 ++++++++++++++ .../Java/libraries/resteasy/JSON.mustache | 5 +++++ .../Java/libraries/resteasy/api.mustache | 7 ++++++- .../libraries/resteasy/build.gradle.mustache | 2 +- .../resttemplate/build.gradle.mustache | 2 +- .../libraries/retrofit/build.gradle.mustache | 2 +- .../libraries/retrofit2/build.gradle.mustache | 2 +- .../resources/handlebars/Java/model.mustache | 6 ++++++ .../resources/handlebars/Java/pom.mustache | 6 +++--- 23 files changed, 119 insertions(+), 22 deletions(-) diff --git a/src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaCodegen.java index 886a1efc21..b73c4af3a3 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaCodegen.java @@ -62,6 +62,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegenConfig { public static final String WIREMOCK_OPTION = "wiremock"; + public static final String JAKARTA = "jakarta"; + protected String dateLibrary = "threetenbp"; protected boolean java8Mode = false; protected boolean java11Mode = false; @@ -93,6 +95,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegenConfig { protected String apiDocPath = "docs/"; protected String modelDocPath = "docs/"; protected boolean supportJava6= false; + protected boolean jakarta = false; private NotNullAnnotationFeatures notNullOption; public AbstractJavaCodegen() { @@ -194,6 +197,15 @@ public AbstractJavaCodegen() { cliOptions.add(CliOption.newBoolean(CHECK_DUPLICATED_MODEL_NAME, "Check if there are duplicated model names (ignoring case)")); cliOptions.add(CliOption.newBoolean(WIREMOCK_OPTION, "Use wiremock to generate endpoint calls to mock on generated tests.")); + + cliOptions.add(CliOption.newBoolean(JAKARTA, "Use Jakarta EE (package jakarta.*) instead of Java EE (javax.*)")); + + CliOption jeeSpec = CliOption.newBoolean(JAKARTA, "Use Jakarta EE (package jakarta.*) instead of Java EE (javax.*)"); + Map jeeSpecModeOptions = new HashMap(); + jeeSpecModeOptions.put("true", "Use Jakarta EE (package jakarta.*)"); + jeeSpecModeOptions.put("false", "Use Java EE (javax.*)"); + jeeSpec.setEnum(jeeSpecModeOptions); + cliOptions.add(jeeSpec); } @Override @@ -490,6 +502,9 @@ public void processOpts() { } else if (dateLibrary.equals("legacy")) { additionalProperties.put("legacyDates", true); } + + setJakarta(Boolean.parseBoolean(String.valueOf(additionalProperties.get(JAKARTA)))); + additionalProperties.put(JAKARTA, jakarta); } private void sanitizeConfig() { @@ -1564,6 +1579,10 @@ public void setJava11Mode(boolean java11Mode) { this.java11Mode = java11Mode; } + public void setJakarta(boolean jakarta) { + this.jakarta = jakarta; + } + @Override public String escapeQuotationMark(String input) { // remove " to avoid code injection diff --git a/src/main/resources/handlebars/Java/ApiClient.mustache b/src/main/resources/handlebars/Java/ApiClient.mustache index a30bdb1dfa..8002803fb2 100644 --- a/src/main/resources/handlebars/Java/ApiClient.mustache +++ b/src/main/resources/handlebars/Java/ApiClient.mustache @@ -29,8 +29,14 @@ import com.sun.jersey.api.client.WebResource.Builder; import com.sun.jersey.multipart.FormDataMultiPart; import com.sun.jersey.multipart.file.FileDataBodyPart; +{{#jakarta}} +import jakarta.ws.rs.core.Response.Status.Family; +import jakarta.ws.rs.core.MediaType; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.core.Response.Status.Family; import javax.ws.rs.core.MediaType; +{{/jakarta}} import java.util.Collection; import java.util.Collections; diff --git a/src/main/resources/handlebars/Java/BeanValidationException.mustache b/src/main/resources/handlebars/Java/BeanValidationException.mustache index ab8ef30b69..9bb486a758 100644 --- a/src/main/resources/handlebars/Java/BeanValidationException.mustache +++ b/src/main/resources/handlebars/Java/BeanValidationException.mustache @@ -1,9 +1,14 @@ package {{invokerPackage}}; import java.util.Set; - +{{#jakarta}} +import jakarta.validation.ConstraintViolation; +import jakarta.validation.ValidationException; +{{/jakarta}} +{{^jakarta}} import javax.validation.ConstraintViolation; import javax.validation.ValidationException; +{{/jakarta}} public class BeanValidationException extends ValidationException { /** diff --git a/src/main/resources/handlebars/Java/build.gradle.mustache b/src/main/resources/handlebars/Java/build.gradle.mustache index 756984ca30..2efb02049b 100644 --- a/src/main/resources/handlebars/Java/build.gradle.mustache +++ b/src/main/resources/handlebars/Java/build.gradle.mustache @@ -54,7 +54,7 @@ if(hasProperty('target') && target == 'android') { } dependencies { - provided 'javax.annotation:jsr250-api:1.0' + provided 'jakarta.annotation:jakarta.annotation-api:{{#jakarta}}2.1.1{{/jakarta}}{{^jakarta}}1.3.5{{/jakarta}}' } } diff --git a/src/main/resources/handlebars/Java/generatedAnnotation.mustache b/src/main/resources/handlebars/Java/generatedAnnotation.mustache index a47b6faa85..c6c0883bcb 100644 --- a/src/main/resources/handlebars/Java/generatedAnnotation.mustache +++ b/src/main/resources/handlebars/Java/generatedAnnotation.mustache @@ -1 +1 @@ -{{^hideGenerationTimestamp}}@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}} \ No newline at end of file +{{^hideGenerationTimestamp}}@{{#jakarta}}jakarta{{/jakarta}}{{^jakarta}}javax{{/jakarta}}.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}} diff --git a/src/main/resources/handlebars/Java/libraries/feign/build.gradle.mustache b/src/main/resources/handlebars/Java/libraries/feign/build.gradle.mustache index e42fd857f5..d0f9fc6a92 100644 --- a/src/main/resources/handlebars/Java/libraries/feign/build.gradle.mustache +++ b/src/main/resources/handlebars/Java/libraries/feign/build.gradle.mustache @@ -54,7 +54,7 @@ if(hasProperty('target') && target == 'android') { } dependencies { - provided 'javax.annotation:jsr250-api:1.0' + provided 'jakarta.annotation:jakarta.annotation-api:{{#jakarta}}2.1.1{{/jakarta}}{{^jakarta}}1.3.5{{/jakarta}}' } } diff --git a/src/main/resources/handlebars/Java/libraries/jersey2/ApiClient.mustache b/src/main/resources/handlebars/Java/libraries/jersey2/ApiClient.mustache index ae57563b55..46a113c45d 100644 --- a/src/main/resources/handlebars/Java/libraries/jersey2/ApiClient.mustache +++ b/src/main/resources/handlebars/Java/libraries/jersey2/ApiClient.mustache @@ -1,5 +1,18 @@ package {{invokerPackage}}; +{{#jakarta}} +import jakarta.ws.rs.client.Client; +import jakarta.ws.rs.client.ClientBuilder; +import jakarta.ws.rs.client.Entity; +import jakarta.ws.rs.client.Invocation; +import jakarta.ws.rs.client.WebTarget; +import jakarta.ws.rs.core.Form; +import jakarta.ws.rs.core.GenericType; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Entity; @@ -10,6 +23,7 @@ import javax.ws.rs.core.GenericType; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +{{/jakarta}} import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.client.ClientProperties; diff --git a/src/main/resources/handlebars/Java/libraries/jersey2/JSON.mustache b/src/main/resources/handlebars/Java/libraries/jersey2/JSON.mustache index 911391a6ba..e094645607 100644 --- a/src/main/resources/handlebars/Java/libraries/jersey2/JSON.mustache +++ b/src/main/resources/handlebars/Java/libraries/jersey2/JSON.mustache @@ -17,7 +17,12 @@ import com.fasterxml.jackson.datatype.threetenbp.ThreeTenModule; import java.text.DateFormat; +{{#jakarta}} +import jakarta.ws.rs.ext.ContextResolver; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.ext.ContextResolver; +{{/jakarta}} {{>generatedAnnotation}} public class JSON implements ContextResolver { diff --git a/src/main/resources/handlebars/Java/libraries/jersey2/api.mustache b/src/main/resources/handlebars/Java/libraries/jersey2/api.mustache index a2538f0e32..6e0dda863e 100644 --- a/src/main/resources/handlebars/Java/libraries/jersey2/api.mustache +++ b/src/main/resources/handlebars/Java/libraries/jersey2/api.mustache @@ -5,7 +5,12 @@ import {{invokerPackage}}.ApiClient; import {{invokerPackage}}.Configuration; import {{invokerPackage}}.Pair; +{{#jakarta}} +import jakarta.ws.rs.core.GenericType; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.core.GenericType; +{{/jakarta}} {{#imports}}import {{import}}; {{/imports}} diff --git a/src/main/resources/handlebars/Java/libraries/jersey2/build.gradle.mustache b/src/main/resources/handlebars/Java/libraries/jersey2/build.gradle.mustache index 759a1603bc..772b0ecbc9 100644 --- a/src/main/resources/handlebars/Java/libraries/jersey2/build.gradle.mustache +++ b/src/main/resources/handlebars/Java/libraries/jersey2/build.gradle.mustache @@ -54,7 +54,7 @@ if(hasProperty('target') && target == 'android') { } dependencies { - provided 'javax.annotation:jsr250-api:1.0' + provided 'jakarta.annotation:jakarta.annotation-api:{{#jakarta}}2.1.1{{/jakarta}}{{^jakarta}}1.3.5{{/jakarta}}' } } diff --git a/src/main/resources/handlebars/Java/libraries/jersey2/pom.mustache b/src/main/resources/handlebars/Java/libraries/jersey2/pom.mustache index d5b0ee31a9..b5e20a58b6 100644 --- a/src/main/resources/handlebars/Java/libraries/jersey2/pom.mustache +++ b/src/main/resources/handlebars/Java/libraries/jersey2/pom.mustache @@ -290,9 +290,9 @@ {{#useBeanValidation}} - javax.validation - validation-api - 1.1.0.Final + jakarta.validation + jakarta.validation-api + {{#jakarta}}3.0.2{{/jakarta}}{{^jakarta}}2.0.2{{/jakarta}} provided {{/useBeanValidation}} diff --git a/src/main/resources/handlebars/Java/libraries/okhttp-gson/api.mustache b/src/main/resources/handlebars/Java/libraries/okhttp-gson/api.mustache index eb25fa7d62..b1033181f5 100644 --- a/src/main/resources/handlebars/Java/libraries/okhttp-gson/api.mustache +++ b/src/main/resources/handlebars/Java/libraries/okhttp-gson/api.mustache @@ -19,13 +19,26 @@ import com.google.gson.reflect.TypeToken; import java.io.IOException; {{#useBeanValidation}} +{{#jakarta}} +import jakarta.validation.constraints.*; +{{/jakarta}} +{{^jakarta}} import javax.validation.constraints.*; +{{/jakarta}} {{/useBeanValidation}} {{#performBeanValidation}} +{{#jakarta}} +import jakarta.validation.ConstraintViolation; +import jakarta.validation.Validation; +import jakarta.validation.ValidatorFactory; +import jakarta.validation.executable.ExecutableValidator; +{{/jakarta}} +{{^jakarta}} import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.ValidatorFactory; import javax.validation.executable.ExecutableValidator; +{{/jakarta}} import java.util.Set; import java.lang.reflect.Method; import java.lang.reflect.Type; @@ -248,4 +261,4 @@ public class {{classname}} { {{/contents}} {{/operation}} } -{{/operations}} \ No newline at end of file +{{/operations}} diff --git a/src/main/resources/handlebars/Java/libraries/okhttp-gson/build.gradle.mustache b/src/main/resources/handlebars/Java/libraries/okhttp-gson/build.gradle.mustache index 2bb4b26834..8be168ba35 100644 --- a/src/main/resources/handlebars/Java/libraries/okhttp-gson/build.gradle.mustache +++ b/src/main/resources/handlebars/Java/libraries/okhttp-gson/build.gradle.mustache @@ -54,7 +54,7 @@ if(hasProperty('target') && target == 'android') { } dependencies { - provided 'javax.annotation:jsr250-api:1.0' + provided 'jakarta.annotation:jakarta.annotation-api:{{#jakarta}}2.1.1{{/jakarta}}{{^jakarta}}1.3.5{{/jakarta}}' } } diff --git a/src/main/resources/handlebars/Java/libraries/okhttp-gson/pom.mustache b/src/main/resources/handlebars/Java/libraries/okhttp-gson/pom.mustache index 63e171a7d0..defa90516b 100644 --- a/src/main/resources/handlebars/Java/libraries/okhttp-gson/pom.mustache +++ b/src/main/resources/handlebars/Java/libraries/okhttp-gson/pom.mustache @@ -255,10 +255,10 @@ {{#useBeanValidation}} - javax.validation - validation-api - 1.1.0.Final - provided + jakarta.validation + jakarta.validation-api + {{#jakarta}}3.0.2{{/jakarta}}{{^jakarta}}2.0.2{{/jakarta}} + provided {{/useBeanValidation}} {{#performBeanValidation}} diff --git a/src/main/resources/handlebars/Java/libraries/resteasy/ApiClient.mustache b/src/main/resources/handlebars/Java/libraries/resteasy/ApiClient.mustache index cc8ad4af25..110f07e3a8 100644 --- a/src/main/resources/handlebars/Java/libraries/resteasy/ApiClient.mustache +++ b/src/main/resources/handlebars/Java/libraries/resteasy/ApiClient.mustache @@ -23,6 +23,19 @@ import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; +{{#jakarta}} +import jakarta.ws.rs.client.Client; +import jakarta.ws.rs.client.ClientBuilder; +import jakarta.ws.rs.client.Entity; +import jakarta.ws.rs.client.Invocation; +import jakarta.ws.rs.client.WebTarget; +import jakarta.ws.rs.core.Form; +import jakarta.ws.rs.core.GenericType; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.client.Entity; @@ -33,6 +46,7 @@ import javax.ws.rs.core.GenericType; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +{{/jakarta}} import org.jboss.logging.Logger; import org.jboss.resteasy.client.jaxrs.internal.ClientConfiguration; diff --git a/src/main/resources/handlebars/Java/libraries/resteasy/JSON.mustache b/src/main/resources/handlebars/Java/libraries/resteasy/JSON.mustache index 27d2aa65d2..ae8f9dd597 100644 --- a/src/main/resources/handlebars/Java/libraries/resteasy/JSON.mustache +++ b/src/main/resources/handlebars/Java/libraries/resteasy/JSON.mustache @@ -11,7 +11,12 @@ import com.fasterxml.jackson.datatype.joda.*; import java.text.DateFormat; +{{#jakarta}} +import jakarta.ws.rs.ext.ContextResolver; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.ext.ContextResolver; +{{/jakarta}} {{>generatedAnnotation}} public class JSON implements ContextResolver { diff --git a/src/main/resources/handlebars/Java/libraries/resteasy/api.mustache b/src/main/resources/handlebars/Java/libraries/resteasy/api.mustache index 9aaa14a33e..ab1aa90ec8 100644 --- a/src/main/resources/handlebars/Java/libraries/resteasy/api.mustache +++ b/src/main/resources/handlebars/Java/libraries/resteasy/api.mustache @@ -5,7 +5,12 @@ import {{invokerPackage}}.ApiClient; import {{invokerPackage}}.Configuration; import {{invokerPackage}}.Pair; -import javax.ws.rs.core.GenericType; +{{#jakarta}} + import jakarta.ws.rs.core.GenericType; +{{/jakarta}} +{{^jakarta}} + import javax.ws.rs.core.GenericType; +{{/jakarta}} {{#imports}}import {{import}}; {{/imports}} diff --git a/src/main/resources/handlebars/Java/libraries/resteasy/build.gradle.mustache b/src/main/resources/handlebars/Java/libraries/resteasy/build.gradle.mustache index 1b068f6d6d..9a23261294 100644 --- a/src/main/resources/handlebars/Java/libraries/resteasy/build.gradle.mustache +++ b/src/main/resources/handlebars/Java/libraries/resteasy/build.gradle.mustache @@ -54,7 +54,7 @@ if(hasProperty('target') && target == 'android') { } dependencies { - provided 'javax.annotation:jsr250-api:1.0' + provided 'jakarta.annotation:jakarta.annotation-api:{{#jakarta}}2.1.1{{/jakarta}}{{^jakarta}}1.3.5{{/jakarta}}' } } diff --git a/src/main/resources/handlebars/Java/libraries/resttemplate/build.gradle.mustache b/src/main/resources/handlebars/Java/libraries/resttemplate/build.gradle.mustache index 65b10eb5bf..45542f754f 100644 --- a/src/main/resources/handlebars/Java/libraries/resttemplate/build.gradle.mustache +++ b/src/main/resources/handlebars/Java/libraries/resttemplate/build.gradle.mustache @@ -54,7 +54,7 @@ if(hasProperty('target') && target == 'android') { } dependencies { - provided 'javax.annotation:jsr250-api:1.0' + provided 'jakarta.annotation:jakarta.annotation-api:{{#jakarta}}2.1.1{{/jakarta}}{{^jakarta}}1.3.5{{/jakarta}}' } } diff --git a/src/main/resources/handlebars/Java/libraries/retrofit/build.gradle.mustache b/src/main/resources/handlebars/Java/libraries/retrofit/build.gradle.mustache index a449413991..008e53728f 100644 --- a/src/main/resources/handlebars/Java/libraries/retrofit/build.gradle.mustache +++ b/src/main/resources/handlebars/Java/libraries/retrofit/build.gradle.mustache @@ -54,7 +54,7 @@ if(hasProperty('target') && target == 'android') { } dependencies { - provided 'javax.annotation:jsr250-api:1.0' + provided 'jakarta.annotation:jakarta.annotation-api:{{#jakarta}}2.1.1{{/jakarta}}{{^jakarta}}1.3.5{{/jakarta}}' } } diff --git a/src/main/resources/handlebars/Java/libraries/retrofit2/build.gradle.mustache b/src/main/resources/handlebars/Java/libraries/retrofit2/build.gradle.mustache index 8a711098c4..0306e7b2af 100644 --- a/src/main/resources/handlebars/Java/libraries/retrofit2/build.gradle.mustache +++ b/src/main/resources/handlebars/Java/libraries/retrofit2/build.gradle.mustache @@ -54,7 +54,7 @@ if(hasProperty('target') && target == 'android') { } dependencies { - provided 'javax.annotation:jsr250-api:1.0' + provided 'jakarta.annotation:jakarta.annotation-api:{{#jakarta}}2.1.1{{/jakarta}}{{^jakarta}}1.3.5{{/jakarta}}' } } diff --git a/src/main/resources/handlebars/Java/model.mustache b/src/main/resources/handlebars/Java/model.mustache index 6c006f921b..9321e5e574 100644 --- a/src/main/resources/handlebars/Java/model.mustache +++ b/src/main/resources/handlebars/Java/model.mustache @@ -29,8 +29,14 @@ import android.os.Parcelable; import android.os.Parcel; {{/parcelableModel}} {{#useBeanValidation}} +{{#jakarta}} import javax.validation.constraints.*; import javax.validation.Valid; +{{/jakarta}} +{{^jakarta}} +import javax.validation.constraints.*; +import javax.validation.Valid; +{{/jakarta}} {{/useBeanValidation}} {{/x-is-composed-model}} {{#models}} diff --git a/src/main/resources/handlebars/Java/pom.mustache b/src/main/resources/handlebars/Java/pom.mustache index c2bf8383ec..a23134d45b 100644 --- a/src/main/resources/handlebars/Java/pom.mustache +++ b/src/main/resources/handlebars/Java/pom.mustache @@ -302,9 +302,9 @@ {{#useBeanValidation}} - javax.validation - validation-api - 1.1.0.Final + jakarta.validation + jakarta.validation-api + {{#jakarta}}3.0.2{{/jakarta}}{{^jakarta}}2.0.2{{/jakarta}} provided {{/useBeanValidation}} From 052511a10c2c53784a1ef4c3cc056926dab112a7 Mon Sep 17 00:00:00 2001 From: Fyro Date: Mon, 26 Dec 2022 19:56:21 +0100 Subject: [PATCH 2/8] add jakarta implementation https://github.com/swagger-api/swagger-codegen-generators/issues/1054 --- .../handlebars/JavaInflector/api.mustache | 5 +++ .../generatedAnnotation.mustache | 2 +- .../handlebars/JavaInflector/web.mustache | 4 +-- .../JavaJaxRS/ApiOriginFilter.mustache | 10 ++++-- .../JavaJaxRS/ApiResponseMessage.mustache | 7 ++++ .../JavaJaxRS/JodaDateTimeProvider.mustache | 13 ++++++- .../JavaJaxRS/JodaLocalDateProvider.mustache | 13 ++++++- .../handlebars/JavaJaxRS/api.mustache | 14 ++++++++ .../handlebars/JavaJaxRS/apiService.mustache | 11 ++++++ .../JavaJaxRS/apiServiceImpl.mustache | 11 ++++++ .../handlebars/JavaJaxRS/bootstrap.mustache | 10 +++++- .../cxf-cdi/RestApplication.mustache | 8 ++++- .../handlebars/JavaJaxRS/cxf-cdi/api.mustache | 15 ++++++++ .../JavaJaxRS/cxf-cdi/apiService.mustache | 6 ++++ .../JavaJaxRS/cxf-cdi/apiServiceImpl.mustache | 7 ++++ .../cxf-cdi/generatedAnnotation.mustache | 2 +- .../JavaJaxRS/cxf-cdi/model.mustache | 5 +++ .../JavaJaxRS/cxf-cdi/pojo.mustache | 5 +++ .../handlebars/JavaJaxRS/cxf-cdi/pom.mustache | 6 ++-- .../cxf/CXF2InterfaceComparator.mustache | 34 ++++++++++++++----- .../handlebars/JavaJaxRS/cxf/api.mustache | 13 +++++++ .../JavaJaxRS/cxf/apiServiceImpl.mustache | 6 ++++ .../JavaJaxRS/cxf/api_test.mustache | 5 +++ .../JavaJaxRS/cxf/enumOuterClass.mustache | 7 ++++ .../cxf/generatedAnnotation.mustache | 2 +- .../handlebars/JavaJaxRS/cxf/model.mustache | 5 +++ .../handlebars/JavaJaxRS/cxf/pojo.mustache | 11 ++++++ .../handlebars/JavaJaxRS/cxf/pom.mustache | 10 +++--- .../server/ApplicationContext.xml.mustache | 2 +- .../JavaJaxRS/cxf/server/pom.mustache | 27 +++++++++------ .../handlebars/JavaJaxRS/di/api.mustache | 15 +++++++- .../JavaJaxRS/di/apiService.mustache | 11 ++++++ .../JavaJaxRS/generatedAnnotation.mustache | 2 +- .../JavaJaxRS/jacksonJsonProvider.mustache | 9 ++++- .../jersey1/LocalDateProvider.mustache | 13 ++++++- .../jersey1/OffsetDateTimeProvider.mustache | 13 ++++++- .../JavaJaxRS/libraries/jersey1/api.mustache | 13 +++++++ .../libraries/jersey1/apiService.mustache | 11 ++++++ .../libraries/jersey1/apiServiceImpl.mustache | 11 ++++++ .../JavaJaxRS/libraries/jersey1/pom.mustache | 21 ++++++++---- .../jersey2/LocalDateProvider.mustache | 9 ++++- .../jersey2/OffsetDateTimeProvider.mustache | 9 ++++- .../handlebars/JavaJaxRS/model.mustache | 6 ++++ .../handlebars/JavaJaxRS/pom.mustache | 10 +++--- .../resteasy/ApiOriginFilter.mustache | 8 ++++- .../resteasy/ApiResponseMessage.mustache | 7 ++++ .../JavaJaxRS/resteasy/JacksonConfig.mustache | 6 ++++ .../resteasy/JodaDateTimeProvider.mustache | 15 ++++++-- .../resteasy/JodaLocalDateProvider.mustache | 15 ++++++-- .../resteasy/LocalDateProvider.mustache | 9 ++++- .../resteasy/OffsetDateTimeProvider.mustache | 9 ++++- .../resteasy/RestApplication.mustache | 8 ++++- .../JavaJaxRS/resteasy/api.mustache | 14 ++++++++ .../JavaJaxRS/resteasy/apiService.mustache | 6 ++++ .../resteasy/apiServiceImpl.mustache | 7 ++++ .../resteasy/eap/JacksonConfig.mustache | 10 +++++- .../resteasy/eap/RestApplication.mustache | 14 ++++++-- .../JavaJaxRS/resteasy/eap/api.mustache | 13 +++++++ .../resteasy/eap/apiServiceImpl.mustache | 6 ++++ .../resteasy/eap/generatedAnnotation.mustache | 2 +- .../JavaJaxRS/resteasy/eap/gradle.mustache | 4 +-- .../JavaJaxRS/resteasy/eap/model.mustache | 5 +++ .../JavaJaxRS/resteasy/eap/pom.mustache | 18 +++++----- .../resteasy/generatedAnnotation.mustache | 2 +- .../JavaJaxRS/resteasy/gradle.mustache | 4 +-- .../JavaJaxRS/resteasy/model.mustache | 5 +++ .../JavaJaxRS/resteasy/pom.mustache | 24 +++++++++---- .../JavaJaxRS/spec/RestApplication.mustache | 6 ++++ .../handlebars/JavaJaxRS/spec/api.mustache | 20 +++++++++-- .../spec/generatedAnnotation.mustache | 4 +-- .../handlebars/JavaJaxRS/spec/model.mustache | 6 ++++ .../handlebars/JavaJaxRS/spec/pom.mustache | 12 +++---- 72 files changed, 583 insertions(+), 105 deletions(-) diff --git a/src/main/resources/handlebars/JavaInflector/api.mustache b/src/main/resources/handlebars/JavaInflector/api.mustache index 055ef574eb..48101979ba 100644 --- a/src/main/resources/handlebars/JavaInflector/api.mustache +++ b/src/main/resources/handlebars/JavaInflector/api.mustache @@ -2,7 +2,12 @@ package {{invokerPackage}}; import io.swagger.oas.inflector.models.RequestContext; import io.swagger.oas.inflector.models.ResponseContext; +{{#jakarta}} +import jakarta.ws.rs.core.Response.Status; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.core.Response.Status; +{{/jakarta}} import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import java.io.File; diff --git a/src/main/resources/handlebars/JavaInflector/generatedAnnotation.mustache b/src/main/resources/handlebars/JavaInflector/generatedAnnotation.mustache index a47b6faa85..c6c0883bcb 100644 --- a/src/main/resources/handlebars/JavaInflector/generatedAnnotation.mustache +++ b/src/main/resources/handlebars/JavaInflector/generatedAnnotation.mustache @@ -1 +1 @@ -{{^hideGenerationTimestamp}}@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}} \ No newline at end of file +{{^hideGenerationTimestamp}}@{{#jakarta}}jakarta{{/jakarta}}{{^jakarta}}javax{{/jakarta}}.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}} diff --git a/src/main/resources/handlebars/JavaInflector/web.mustache b/src/main/resources/handlebars/JavaInflector/web.mustache index 16a254d111..cbe4875d9d 100644 --- a/src/main/resources/handlebars/JavaInflector/web.mustache +++ b/src/main/resources/handlebars/JavaInflector/web.mustache @@ -4,7 +4,7 @@ swagger-inflector org.glassfish.jersey.servlet.ServletContainer - javax.ws.rs.Application + {{#jakarta}}jakarta{{/jakarta}}javax{{^jakarta}}.ws.rs.Application io.swagger.oas.inflector.OpenAPIInflector 1 @@ -21,4 +21,4 @@ CORSFilter /* - \ No newline at end of file + diff --git a/src/main/resources/handlebars/JavaJaxRS/ApiOriginFilter.mustache b/src/main/resources/handlebars/JavaJaxRS/ApiOriginFilter.mustache index b8af270a05..f9ef60c3ee 100644 --- a/src/main/resources/handlebars/JavaJaxRS/ApiOriginFilter.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/ApiOriginFilter.mustache @@ -2,11 +2,17 @@ package {{apiPackage}}; import java.io.IOException; +{{#jakarta}} +import jakarta.servlet.*; +import jakarta.servlet.http.HttpServletResponse; +{{/jakarta}} +{{^jakarta}} import javax.servlet.*; import javax.servlet.http.HttpServletResponse; +{{/jakarta}} {{>generatedAnnotation}} -public class ApiOriginFilter implements javax.servlet.Filter { +public class ApiOriginFilter implements Filter { public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletResponse res = (HttpServletResponse) response; @@ -19,4 +25,4 @@ public class ApiOriginFilter implements javax.servlet.Filter { public void destroy() {} public void init(FilterConfig filterConfig) throws ServletException {} -} \ No newline at end of file +} diff --git a/src/main/resources/handlebars/JavaJaxRS/ApiResponseMessage.mustache b/src/main/resources/handlebars/JavaJaxRS/ApiResponseMessage.mustache index c883e16b5e..50f428a3aa 100644 --- a/src/main/resources/handlebars/JavaJaxRS/ApiResponseMessage.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/ApiResponseMessage.mustache @@ -1,8 +1,15 @@ package {{apiPackage}}; +{{#jakarta}} +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.xml.bind.annotation.XmlRootElement +{{/jakarta}} +{{^jakarta}} import javax.xml.bind.annotation.XmlTransient; @javax.xml.bind.annotation.XmlRootElement +{{/jakarta}} {{>generatedAnnotation}} public class ApiResponseMessage { public static final int ERROR = 1; diff --git a/src/main/resources/handlebars/JavaJaxRS/JodaDateTimeProvider.mustache b/src/main/resources/handlebars/JavaJaxRS/JodaDateTimeProvider.mustache index f942179098..2e81525879 100644 --- a/src/main/resources/handlebars/JavaJaxRS/JodaDateTimeProvider.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/JodaDateTimeProvider.mustache @@ -4,6 +4,16 @@ import com.sun.jersey.core.spi.component.ComponentContext; import com.sun.jersey.spi.inject.Injectable; import com.sun.jersey.spi.inject.PerRequestTypeInjectableProvider; +{{#jakarta}} +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.WebApplicationException; +import jakarta.ws.rs.core.Context; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; +import jakarta.ws.rs.core.UriInfo; +import jakarta.ws.rs.ext.Provider; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.QueryParam; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Context; @@ -11,6 +21,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.UriInfo; import javax.ws.rs.ext.Provider; +{{/jakarta}} import org.joda.time.DateTime; import java.util.List; @@ -41,4 +52,4 @@ public class JodaDateTimeProvider extends PerRequestTypeInjectableProvidergeneratedAnnotation}} {{#operations}} diff --git a/src/main/resources/handlebars/JavaJaxRS/apiServiceImpl.mustache b/src/main/resources/handlebars/JavaJaxRS/apiServiceImpl.mustache index 7c9bc7c412..4ae2646850 100644 --- a/src/main/resources/handlebars/JavaJaxRS/apiServiceImpl.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/apiServiceImpl.mustache @@ -14,10 +14,21 @@ import java.io.InputStream; import org.glassfish.jersey.media.multipart.FormDataContentDisposition; +{{#jakarta}} +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; +{{/jakarta}} {{#useBeanValidation}} +{{#jakarta}} import javax.validation.constraints.*; +{{/jakarta}} +{{^jakarta}} +import javax.validation.constraints.*; +{{/jakarta}} {{/useBeanValidation}} {{>generatedAnnotation}} {{#operations}} diff --git a/src/main/resources/handlebars/JavaJaxRS/bootstrap.mustache b/src/main/resources/handlebars/JavaJaxRS/bootstrap.mustache index 433c0389c3..72f020fcc6 100644 --- a/src/main/resources/handlebars/JavaJaxRS/bootstrap.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/bootstrap.mustache @@ -1,9 +1,17 @@ package {{apiPackage}}; +{{#jakarta}} +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.ServletContext; +import jakarta.servlet.ServletConfig; +import jakarta.servlet.ServletException; +{{/jakarta}} +{{^jakarta}} import javax.servlet.http.HttpServlet; import javax.servlet.ServletContext; import javax.servlet.ServletConfig; import javax.servlet.ServletException; +{{/jakarta}} {{#useOas2}} import io.swagger.jaxrs.config.SwaggerContextService; @@ -52,4 +60,4 @@ import io.swagger.v3.oas.annotations.info.License; ) public class Bootstrap { } -{{/useOas2}} \ No newline at end of file +{{/useOas2}} diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/RestApplication.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/RestApplication.mustache index d3d8b238d7..722cb94e47 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/RestApplication.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/RestApplication.mustache @@ -1,9 +1,15 @@ package {{invokerPackage}}; +{{#jakarta}} +import jakarta.ws.rs.ApplicationPath; +import jakarta.ws.rs.core.Application; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; +{{/jakarta}} @ApplicationPath("/") public class RestApplication extends Application { // Add implementation-specific details here -} \ No newline at end of file +} diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/api.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/api.mustache index 0cb1b1445f..41780bfce4 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/api.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/api.mustache @@ -4,12 +4,22 @@ package {{package}}; {{/imports}} import {{package}}.{{classname}}Service; +{{#jakarta}} +import jakarta.ws.rs.*; +import jakarta.ws.rs.core.Context; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.*; import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; import javax.enterprise.context.RequestScoped; import javax.inject.Inject; +{{/jakarta}} {{#useOas2}} import io.swagger.annotations.*; @@ -32,7 +42,12 @@ import org.apache.cxf.jaxrs.ext.multipart.Multipart; import java.util.Map; import java.util.List; {{#useBeanValidation}} +{{#jakarta}} +import jakarta.validation.constraints.*; +{{/jakarta}} +{{^jakarta}} import javax.validation.constraints.*; +{{/jakarta}} {{/useBeanValidation}} @Path("/{{{baseName}}}") @RequestScoped diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/apiService.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/apiService.mustache index d75faaca09..7055bc34d6 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/apiService.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/apiService.mustache @@ -13,8 +13,14 @@ import java.util.List; import java.io.InputStream; +{{#jakarta}} +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; +{{/jakarta}} {{>generatedAnnotation}} {{#operations}} diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/apiServiceImpl.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/apiServiceImpl.mustache index b0af063d33..812338de91 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/apiServiceImpl.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/apiServiceImpl.mustache @@ -12,9 +12,16 @@ import java.util.List; import java.io.InputStream; +{{#jakarta}} +import jakarta.enterprise.context.RequestScoped; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +{{/jakarta}} +{{^jakarta}} import javax.enterprise.context.RequestScoped; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; +{{/jakarta}} @RequestScoped {{>generatedAnnotation}} diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/generatedAnnotation.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/generatedAnnotation.mustache index a47b6faa85..c6c0883bcb 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/generatedAnnotation.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/generatedAnnotation.mustache @@ -1 +1 @@ -{{^hideGenerationTimestamp}}@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}} \ No newline at end of file +{{^hideGenerationTimestamp}}@{{#jakarta}}jakarta{{/jakarta}}{{^jakarta}}javax{{/jakarta}}.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}} diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/model.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/model.mustache index abbe476515..5edf75f7d8 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/model.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/model.mustache @@ -4,7 +4,12 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} {{#useBeanValidation}} +{{#jakarta}} +import jakarta.validation.constraints.*; +{{/jakarta}} +{{^jakarta}} import javax.validation.constraints.*; +{{/jakarta}} {{/useBeanValidation}} {{/x-is-composed-model}} {{#models}} diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pojo.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pojo.mustache index 78b3ec8ca0..d8cc0f03f1 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pojo.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pojo.mustache @@ -6,7 +6,12 @@ import io.swagger.v3.oas.annotations.media.Schema; {{/useOas2}} import java.util.Objects; +{{#jakarta}} +import jakarta.xml.bind.annotation.*; +{{/jakarta}} +{{^jakarta}} import javax.xml.bind.annotation.*; +{{/jakarta}} {{#description}}{{#useOas2}}@ApiModel{{/useOas2}}{{^useOas2}}@Schema{{/useOas2}}(description = "{{{description}}}"){{/description}} diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pom.mustache index 9851b195cb..596f172a32 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pom.mustache @@ -89,9 +89,9 @@ {{#useBeanValidation}} - javax.validation - validation-api - 1.1.0.Final + jakarta.validation + jakarta.validation-api + {{#jakarta}}3.0.2{{/jakarta}}{{^jakarta}}2.0.2{{/jakarta}} provided {{/useBeanValidation}} diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf/CXF2InterfaceComparator.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf/CXF2InterfaceComparator.mustache index d1fd0bf82c..8e4f060577 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf/CXF2InterfaceComparator.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf/CXF2InterfaceComparator.mustache @@ -5,8 +5,26 @@ import java.lang.reflect.Method; import java.util.regex.Matcher; import java.util.regex.Pattern; +{{#jakarta}} +import jakarta.ws.rs.DELETE; +import jakarta.ws.rs.HEAD; +import jakarta.ws.rs.HttpMethod; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.OPTIONS; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.PUT; +{{/jakarta}} +{{^jakarta}} +import javax.ws.rs.DELETE; +import javax.ws.rs.HEAD; import javax.ws.rs.HttpMethod; +import javax.ws.rs.GET; +import javax.ws.rs.OPTIONS; import javax.ws.rs.Path; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +{{/jakarta}} import org.apache.cxf.jaxrs.ext.ResourceComparator; import org.apache.cxf.jaxrs.model.ClassResourceInfo; @@ -60,7 +78,7 @@ public class CXFInterfaceComparator implements ResourceComparator { Method[] methods = cri.getServiceClass().getInterfaces()[0].getMethods(); // Java reflexion. Check all the methods of an interface. for (Method method : methods) { - Path pathAnnotation = method.getAnnotation(javax.ws.rs.Path.class); + Path pathAnnotation = method.getAnnotation(Path.class); if (pathAnnotation != null && pathAnnotation.value() != null) { String pathValue = pathAnnotation.value(); String methodHttpVerb = getMethodHttpVerb(method); @@ -79,17 +97,17 @@ public class CXFInterfaceComparator implements ResourceComparator { } private static String getMethodHttpVerb(Method method) { - if (method.getAnnotation(javax.ws.rs.POST.class) != null) { + if (method.getAnnotation(POST.class) != null) { return HttpMethod.POST; - } else if (method.getAnnotation(javax.ws.rs.GET.class) != null) { + } else if (method.getAnnotation(GET.class) != null) { return HttpMethod.GET; - } else if (method.getAnnotation(javax.ws.rs.PUT.class) != null) { + } else if (method.getAnnotation(PUT.class) != null) { return HttpMethod.PUT; - } else if (method.getAnnotation(javax.ws.rs.OPTIONS.class) != null) { + } else if (method.getAnnotation(OPTIONS.class) != null) { return HttpMethod.OPTIONS; - } else if (method.getAnnotation(javax.ws.rs.DELETE.class) != null) { + } else if (method.getAnnotation(DELETE.class) != null) { return HttpMethod.DELETE; - } else if (method.getAnnotation(javax.ws.rs.HEAD.class) != null) { + } else if (method.getAnnotation(HEAD.class) != null) { return HttpMethod.HEAD; } assert false; @@ -117,4 +135,4 @@ public class CXFInterfaceComparator implements ResourceComparator { public int compare(OperationResourceInfo ori1, OperationResourceInfo ori2, Message message) { return 0; // Leave CXF decision } -} \ No newline at end of file +} diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf/api.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf/api.mustache index e9cf1dc7e4..f0f52851eb 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf/api.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf/api.mustache @@ -7,9 +7,16 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.List; import java.util.Map; +{{#jakarta}} +import jakarta.ws.rs.*; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.MediaType; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.*; import javax.ws.rs.core.Response; import javax.ws.rs.core.MediaType; +{{/jakarta}} import org.apache.cxf.jaxrs.ext.multipart.*; {{#useOas2}} @@ -28,8 +35,14 @@ import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; {{/useOas2}} {{#useBeanValidation}} +{{#jakarta}} +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; +{{/jakarta}} +{{^jakarta}} import javax.validation.constraints.*; import javax.validation.Valid; +{{/jakarta}} {{/useBeanValidation}} {{#appName}} diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf/apiServiceImpl.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf/apiServiceImpl.mustache index 82ebd6da18..d0397b6f1f 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf/apiServiceImpl.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf/apiServiceImpl.mustache @@ -8,8 +8,14 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.List; import java.util.Map; +{{#jakarta}} +import jakarta.ws.rs.*; +import jakarta.ws.rs.core.Response; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.*; import javax.ws.rs.core.Response; +{{/jakarta}} import org.apache.cxf.jaxrs.model.wadl.Description; import org.apache.cxf.jaxrs.model.wadl.DocTarget; diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf/api_test.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf/api_test.mustache index e265b96996..b1b6bbacac 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf/api_test.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf/api_test.mustache @@ -8,7 +8,12 @@ import org.junit.Test; import org.junit.Before; import static org.junit.Assert.*; +{{#jakarta}} +import jakarta.ws.rs.core.Response; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.core.Response; +{{/jakarta}} import org.apache.cxf.jaxrs.client.JAXRSClientFactory; import org.apache.cxf.jaxrs.client.ClientConfiguration; import org.apache.cxf.jaxrs.client.WebClient; diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf/enumOuterClass.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf/enumOuterClass.mustache index 491a199e09..5973e0434e 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf/enumOuterClass.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf/enumOuterClass.mustache @@ -3,9 +3,16 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; {{/jackson}} {{#withXml}} +{{#jakarta}} +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlEnum; +import jakarta.xml.bind.annotation.XmlEnumValue; +{{/jakarta}} +{{^jakarta}} import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; +{{/jakarta}} {{/withXml}} /** diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf/generatedAnnotation.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf/generatedAnnotation.mustache index 49110fc1ad..c6c0883bcb 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf/generatedAnnotation.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf/generatedAnnotation.mustache @@ -1 +1 @@ -@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}") \ No newline at end of file +{{^hideGenerationTimestamp}}@{{#jakarta}}jakarta{{/jakarta}}{{^jakarta}}javax{{/jakarta}}.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}} diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf/model.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf/model.mustache index fe9f571dd2..8642b990ba 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf/model.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf/model.mustache @@ -4,7 +4,12 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} {{#useBeanValidation}} +{{#jakarta}} +import jakarta.validation.constraints.*; +{{/jakarta}} +{{^jakarta}} import javax.validation.constraints.*; +{{/jakarta}} {{/useBeanValidation}} {{/isComposedModel}} diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf/pojo.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf/pojo.mustache index 6c8429248f..656f475a03 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf/pojo.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf/pojo.mustache @@ -4,6 +4,16 @@ import io.swagger.annotations.ApiModelProperty; {{^useOas2}} import io.swagger.v3.oas.annotations.media.Schema; {{/useOas2}} +{{#jakarta}} +import jakarta.xml.bind.annotation.XmlElement; +import jakarta.xml.bind.annotation.XmlRootElement; +import jakarta.xml.bind.annotation.XmlAccessType; +import jakarta.xml.bind.annotation.XmlAccessorType; +import jakarta.xml.bind.annotation.XmlType; +import jakarta.xml.bind.annotation.XmlEnum; +import jakarta.xml.bind.annotation.XmlEnumValue; +{{/jakarta}} +{{^jakarta}} import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; @@ -11,6 +21,7 @@ import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; +{{/jakarta}} import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.annotation.JsonCreator; diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf/pom.mustache index 24aea6d203..f8de92160a 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf/pom.mustache @@ -42,8 +42,8 @@ {{#useBeanValidation}} - javax.validation - validation-api + jakarta.validation + jakarta.validation-api ${beanvalidation-version} @@ -128,8 +128,8 @@ {{#useBeanValidation}} - javax.validation - validation-api + jakarta.validation + jakarta.validation-api ${beanvalidation-version} provided @@ -229,7 +229,7 @@ 1.2.9 2.5 {{#useBeanValidation}} - 1.1.0.Final + {{#jakarta}}3.0.2{{/jakarta}}{{^jakarta}}2.0.2{{/jakarta}} {{/useBeanValidation}} 3.2.4 2.9.1 diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf/server/ApplicationContext.xml.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf/server/ApplicationContext.xml.mustache index fd1b6d6f8f..1fa7aea495 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf/server/ApplicationContext.xml.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf/server/ApplicationContext.xml.mustache @@ -84,7 +84,7 @@ {{/useGzipFeature}} - + diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf/server/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf/server/pom.mustache index b59e397af1..b89cdc7b7d 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf/server/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf/server/pom.mustache @@ -42,8 +42,8 @@ {{#useBeanValidation}} - javax.validation - validation-api + jakarta.validation + jakarta.validation-api ${beanvalidation-version} @@ -137,8 +137,8 @@ {{#useBeanValidation}} - javax.validation - validation-api + jakarta.validation + jakarta.validation-api ${beanvalidation-version} provided @@ -256,14 +256,19 @@ {{/useSwaggerUI}} - javax.xml.bind - jaxb-api - 2.2.6 + jakarta.xml.bind + jakarta.xml.bind-api + {{#jakarta}}4.0.0{{/jakarta}}{{^jakarta}}2.3.3{{/jakarta}} - javax.activation - activation - 1.1.1 + com.sun.xml.bind + jaxb-impl + {{#jakarta}}4.0.1{{/jakarta}}{{^jakarta}}2.3.7{{/jakarta}} + + + jakarta.activation + jakarta.activation-api + {{#jakarta}}2.1.0{{/jakarta}}{{^jakarta}}1.2.2{{/jakarta}} @@ -290,7 +295,7 @@ 1.2.9 2.5 {{#useBeanValidation}} - 1.1.0.Final + {{#jakarta}}3.0.2{{/jakarta}}{{^jakarta}}2.0.2{{/jakarta}} {{/useBeanValidation}} {{#generateSpringApplication}} 4.3.13.RELEASE diff --git a/src/main/resources/handlebars/JavaJaxRS/di/api.mustache b/src/main/resources/handlebars/JavaJaxRS/di/api.mustache index fae82cbd69..6c79865b54 100644 --- a/src/main/resources/handlebars/JavaJaxRS/di/api.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/di/api.mustache @@ -29,12 +29,25 @@ import java.io.InputStream; import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataParam; +{{#jakarta}} +import jakarta.ws.rs.core.Context; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +import jakarta.ws.rs.*; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; import javax.ws.rs.*; +{{/jakarta}} {{#useBeanValidation}} +{{#jakarta}} +import jakarta.validation.constraints.*; +{{/jakarta}} +{{^jakarta}} import javax.validation.constraints.*; +{{/jakarta}} {{/useBeanValidation}} @Path("/{{{baseName}}}") @@ -52,7 +65,7 @@ public class {{classname}} { protected {{classname}}() { } - @javax.inject.Inject + @{{#jakarta}}jakarta{{/jakarta}}{{^jakarta}}javax{{/jakarta}}.inject.Inject public {{classname}}({{classname}}Service delegate) { this.delegate = delegate; } diff --git a/src/main/resources/handlebars/JavaJaxRS/di/apiService.mustache b/src/main/resources/handlebars/JavaJaxRS/di/apiService.mustache index 56092f5e7c..414550b752 100644 --- a/src/main/resources/handlebars/JavaJaxRS/di/apiService.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/di/apiService.mustache @@ -13,10 +13,21 @@ import java.util.List; import java.io.InputStream; +{{#jakarta}} +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; +{{/jakarta}} {{#useBeanValidation}} +{{#jakarta}} +import jakarta.validation.constraints.*; +{{/jakarta}} +{{^jakarta}} import javax.validation.constraints.*; +{{/jakarta}} {{/useBeanValidation}} {{>generatedAnnotation}} {{#operations}} diff --git a/src/main/resources/handlebars/JavaJaxRS/generatedAnnotation.mustache b/src/main/resources/handlebars/JavaJaxRS/generatedAnnotation.mustache index a47b6faa85..c6c0883bcb 100644 --- a/src/main/resources/handlebars/JavaJaxRS/generatedAnnotation.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/generatedAnnotation.mustache @@ -1 +1 @@ -{{^hideGenerationTimestamp}}@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}} \ No newline at end of file +{{^hideGenerationTimestamp}}@{{#jakarta}}jakarta{{/jakarta}}{{^jakarta}}javax{{/jakarta}}.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}} diff --git a/src/main/resources/handlebars/JavaJaxRS/jacksonJsonProvider.mustache b/src/main/resources/handlebars/JavaJaxRS/jacksonJsonProvider.mustache index 5fa284e809..132341ff36 100644 --- a/src/main/resources/handlebars/JavaJaxRS/jacksonJsonProvider.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/jacksonJsonProvider.mustache @@ -13,9 +13,16 @@ import com.fasterxml.jackson.datatype.joda.*; import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; +{{#jakarta}} +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.ext.Provider; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.ext.Provider; +{{/jakarta}} @Provider @Produces({MediaType.APPLICATION_JSON}) @@ -36,4 +43,4 @@ public class JacksonJsonProvider extends JacksonJaxbJsonProvider { setMapper(objectMapper); } -} \ No newline at end of file +} diff --git a/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/LocalDateProvider.mustache b/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/LocalDateProvider.mustache index 8c4cd4cbd1..a264da486f 100644 --- a/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/LocalDateProvider.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/LocalDateProvider.mustache @@ -4,6 +4,16 @@ import com.sun.jersey.core.spi.component.ComponentContext; import com.sun.jersey.spi.inject.Injectable; import com.sun.jersey.spi.inject.PerRequestTypeInjectableProvider; +{{#jakarta}} +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.WebApplicationException; +import jakarta.ws.rs.core.Context; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; +import jakarta.ws.rs.core.UriInfo; +import jakarta.ws.rs.ext.Provider; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.QueryParam; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Context; @@ -11,6 +21,7 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.UriInfo; import javax.ws.rs.ext.Provider; +{{/jakarta}} import java.time.LocalDate; import java.util.List; @@ -41,4 +52,4 @@ public class LocalDateProvider extends PerRequestTypeInjectableProvidergeneratedAnnotation}} {{#operations}} diff --git a/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/apiServiceImpl.mustache b/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/apiServiceImpl.mustache index d22f98fb8c..ba8b4156d8 100644 --- a/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/apiServiceImpl.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/apiServiceImpl.mustache @@ -17,10 +17,21 @@ import java.io.InputStream; import com.sun.jersey.core.header.FormDataContentDisposition; import com.sun.jersey.multipart.FormDataParam; +{{#jakarta}} +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; +{{/jakarta}} {{#useBeanValidation}} +{{#jakarta}} +import jakarta.validation.constraints.*; +{{/jakarta}} +{{^jakarta}} import javax.validation.constraints.*; +{{/jakarta}} {{/useBeanValidation}} {{>generatedAnnotation}} {{#operations}} diff --git a/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/pom.mustache index 4c03cfddc7..ea169f4130 100644 --- a/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/libraries/jersey1/pom.mustache @@ -45,8 +45,8 @@ {{#useBeanValidation}} - javax.validation - validation-api + jakarta.validation + jakarta.validation-api ${beanvalidation-version} @@ -129,11 +129,20 @@ jersey-server ${jersey-version} +{{#jakarta}} + + jakarta.servlet + jakarta-api + ${servlet-api-version} + +{{/jakarta}} +{{^jakarta}} javax.servlet servlet-api ${servlet-api-version} +{{/jakarta}} junit @@ -180,8 +189,8 @@ {{#useBeanValidation}} - javax.validation - validation-api + jakarta.validation + jakarta.validation-api ${beanvalidation-version} provided @@ -206,9 +215,9 @@ 2.8.9 1.7.21 4.13.1 - 2.5 + {{#jakarta}}6.0.0{{/jakarta}}{{^jakarta}}3.1.0{{/jakarta}} {{#useBeanValidation}} - 1.1.0.Final + {{#jakarta}}3.0.2{{/jakarta}}{{^jakarta}}2.0.2{{/jakarta}} {{/useBeanValidation}} UTF-8 diff --git a/src/main/resources/handlebars/JavaJaxRS/libraries/jersey2/LocalDateProvider.mustache b/src/main/resources/handlebars/JavaJaxRS/libraries/jersey2/LocalDateProvider.mustache index 90a5fb6208..45a30ffee6 100644 --- a/src/main/resources/handlebars/JavaJaxRS/libraries/jersey2/LocalDateProvider.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/libraries/jersey2/LocalDateProvider.mustache @@ -1,8 +1,15 @@ package {{apiPackage}}; +{{#jakarta}} +import jakarta.ws.rs.ext.ParamConverter; +import jakarta.ws.rs.ext.ParamConverterProvider; +import jakarta.ws.rs.ext.Provider; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.ext.ParamConverter; import javax.ws.rs.ext.ParamConverterProvider; import javax.ws.rs.ext.Provider; +{{/jakarta}} import java.lang.annotation.Annotation; import java.lang.reflect.Type; import java.time.LocalDate; @@ -25,4 +32,4 @@ public class LocalDateProvider implements ParamConverterProvider { } return null; } -} \ No newline at end of file +} diff --git a/src/main/resources/handlebars/JavaJaxRS/libraries/jersey2/OffsetDateTimeProvider.mustache b/src/main/resources/handlebars/JavaJaxRS/libraries/jersey2/OffsetDateTimeProvider.mustache index fccb0deb16..6ab5876892 100644 --- a/src/main/resources/handlebars/JavaJaxRS/libraries/jersey2/OffsetDateTimeProvider.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/libraries/jersey2/OffsetDateTimeProvider.mustache @@ -1,8 +1,15 @@ package {{apiPackage}}; +{{#jakarta}} +import jakarta.ws.rs.ext.ParamConverter; +import jakarta.ws.rs.ext.ParamConverterProvider; +import jakarta.ws.rs.ext.Provider; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.ext.ParamConverter; import javax.ws.rs.ext.ParamConverterProvider; import javax.ws.rs.ext.Provider; +{{/jakarta}} import java.lang.annotation.Annotation; import java.lang.reflect.Type; import java.time.OffsetDateTime; @@ -25,4 +32,4 @@ public class OffsetDateTimeProvider implements ParamConverterProvider { } return null; } -} \ No newline at end of file +} diff --git a/src/main/resources/handlebars/JavaJaxRS/model.mustache b/src/main/resources/handlebars/JavaJaxRS/model.mustache index 833c4a9c04..36b27798e7 100644 --- a/src/main/resources/handlebars/JavaJaxRS/model.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/model.mustache @@ -15,8 +15,14 @@ import org.apache.commons.lang3.ObjectUtils; import java.io.Serializable; {{/serializableModel}} {{#useBeanValidation}} +{{#jakarta}} +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; +{{/jakarta}} +{{^jakarta}} import javax.validation.constraints.*; import javax.validation.Valid; +{{/jakarta}} {{/useBeanValidation}} {{/x-is-composed-model}} diff --git a/src/main/resources/handlebars/JavaJaxRS/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/pom.mustache index d7865064d3..c16743bf36 100644 --- a/src/main/resources/handlebars/JavaJaxRS/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/pom.mustache @@ -54,8 +54,8 @@ {{#useBeanValidation}} - javax.validation - validation-api + jakarta.validation + jakarta.validation-api ${beanvalidation-version} @@ -205,8 +205,8 @@ {{#useBeanValidation}} - javax.validation - validation-api + jakarta.validation + jakarta.validation-api ${beanvalidation-version} provided @@ -243,7 +243,7 @@ 1.2.9 2.5 {{#useBeanValidation}} - 1.1.0.Final + {{#jakarta}}3.0.2{{/jakarta}}{{^jakarta}}2.0.2{{/jakarta}} {{/useBeanValidation}} UTF-8 diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/ApiOriginFilter.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/ApiOriginFilter.mustache index 090fd8cb55..f9ef60c3ee 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/ApiOriginFilter.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/ApiOriginFilter.mustache @@ -2,11 +2,17 @@ package {{apiPackage}}; import java.io.IOException; +{{#jakarta}} +import jakarta.servlet.*; +import jakarta.servlet.http.HttpServletResponse; +{{/jakarta}} +{{^jakarta}} import javax.servlet.*; import javax.servlet.http.HttpServletResponse; +{{/jakarta}} {{>generatedAnnotation}} -public class ApiOriginFilter implements javax.servlet.Filter { +public class ApiOriginFilter implements Filter { public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletResponse res = (HttpServletResponse) response; diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/ApiResponseMessage.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/ApiResponseMessage.mustache index f47a535094..5851bdd03f 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/ApiResponseMessage.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/ApiResponseMessage.mustache @@ -1,8 +1,15 @@ package {{apiPackage}}; +{{#jakarta}} +import jakarta.xml.bind.annotation.XmlTransient; + +@jakarta.xml.bind.annotation.XmlRootElement +{{/jakarta}} +{{^jakarta}} import javax.xml.bind.annotation.XmlTransient; @javax.xml.bind.annotation.XmlRootElement +{{/jakarta}} {{>generatedAnnotation}} public class ApiResponseMessage { public static final int ERROR = 1; diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/JacksonConfig.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/JacksonConfig.mustache index 1be7abd835..abcbaac4e3 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/JacksonConfig.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/JacksonConfig.mustache @@ -15,8 +15,14 @@ import org.joda.time.LocalDate; import org.joda.time.format.ISODateTimeFormat; {{/joda}} +{{#jakarta}} +import jakarta.ws.rs.ext.ContextResolver; +import jakarta.ws.rs.ext.Provider; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.ext.ContextResolver; import javax.ws.rs.ext.Provider; +{{/jakarta}} import java.io.IOException; @Provider diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/JodaDateTimeProvider.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/JodaDateTimeProvider.mustache index 74c24c8777..b0a115a41f 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/JodaDateTimeProvider.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/JodaDateTimeProvider.mustache @@ -1,13 +1,22 @@ package {{apiPackage}}; import org.joda.time.DateTime; +{{#jakarta}} +import jakarta.ws.rs.ext.ParamConverter; +import jakarta.ws.rs.ext.ParamConverterProvider; +import jakarta.ws.rs.ext.Provider; +import jakarta.ws.rs.WebApplicationException; +import javax.ws.rs.core.Response; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.ext.ParamConverter; import javax.ws.rs.ext.ParamConverterProvider; import javax.ws.rs.ext.Provider; -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; +{{/jakarta}} +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; @Provider @@ -36,4 +45,4 @@ public class JodaDateTimeProvider implements ParamConverterProvider { } return null; } -} \ No newline at end of file +} diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/JodaLocalDateProvider.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/JodaLocalDateProvider.mustache index 0b28c915dd..6d51e070a6 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/JodaLocalDateProvider.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/JodaLocalDateProvider.mustache @@ -1,13 +1,22 @@ package {{apiPackage}}; import org.joda.time.LocalDate; +{{#jakarta}} +import jakarta.ws.rs.ext.ParamConverter; +import jakarta.ws.rs.ext.ParamConverterProvider; +import jakarta.ws.rs.ext.Provider; +import jakarta.ws.rs.WebApplicationException; +import javax.ws.rs.core.Response; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.ext.ParamConverter; import javax.ws.rs.ext.ParamConverterProvider; import javax.ws.rs.ext.Provider; -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; +{{/jakarta}} +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; @Provider @@ -36,4 +45,4 @@ public class JodaLocalDateProvider implements ParamConverterProvider { } return null; } -} \ No newline at end of file +} diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/LocalDateProvider.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/LocalDateProvider.mustache index a57e3e7475..86350d230e 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/LocalDateProvider.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/LocalDateProvider.mustache @@ -1,9 +1,16 @@ package {{apiPackage}}; import java.time.LocalDate; +{{#jakarta}} +import jakarta.ws.rs.ext.ParamConverter; +import jakarta.ws.rs.ext.ParamConverterProvider; +import jakarta.ws.rs.ext.Provider; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.ext.ParamConverter; import javax.ws.rs.ext.ParamConverterProvider; import javax.ws.rs.ext.Provider; +{{/jakarta}} import java.lang.annotation.Annotation; import java.lang.reflect.Type; @@ -28,4 +35,4 @@ public class LocalDateProvider implements ParamConverterProvider { } return null; } -} \ No newline at end of file +} diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/OffsetDateTimeProvider.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/OffsetDateTimeProvider.mustache index a3974c3c53..d3093bae45 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/OffsetDateTimeProvider.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/OffsetDateTimeProvider.mustache @@ -1,9 +1,16 @@ package {{apiPackage}}; import java.time.OffsetDateTime; +{{#jakarta}} +import jakarta.ws.rs.ext.ParamConverter; +import jakarta.ws.rs.ext.ParamConverterProvider; +import jakarta.ws.rs.ext.Provider; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.ext.ParamConverter; import javax.ws.rs.ext.ParamConverterProvider; import javax.ws.rs.ext.Provider; +{{/jakarta}} import java.lang.annotation.Annotation; import java.lang.reflect.Type; @@ -28,4 +35,4 @@ public class OffsetDateTimeProvider implements ParamConverterProvider { } return null; } -} \ No newline at end of file +} diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/RestApplication.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/RestApplication.mustache index df9a31434b..74127894d7 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/RestApplication.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/RestApplication.mustache @@ -1,9 +1,15 @@ package {{invokerPackage}}; +{{#jakarta}} +import jakarta.ws.rs.ApplicationPath; +import jakarta.ws.rs.core.Application; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; +{{/jakarta}} @ApplicationPath("/") public class RestApplication extends Application { -} \ No newline at end of file +} diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/api.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/api.mustache index 57ebfa65d6..2154dffa6d 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/api.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/api.mustache @@ -27,14 +27,28 @@ import {{package}}.NotFoundException; import java.io.InputStream; +{{#jakarta}} +import jakarta.ws.rs.core.Context; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +import jakarta.ws.rs.*; +import jakarta.inject.Inject; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; import javax.ws.rs.*; import javax.inject.Inject; +{{/jakarta}} {{#useBeanValidation}} +{{#jakarta}} +import jakarta.validation.constraints.*; +{{/jakarta}} +{{^jakarta}} import javax.validation.constraints.*; +{{/jakarta}} {{/useBeanValidation}} {{#operations}} {{#operation}} diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/apiService.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/apiService.mustache index 83741b6ec0..9ccd249952 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/apiService.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/apiService.mustache @@ -13,8 +13,14 @@ import {{package}}.NotFoundException; import java.io.InputStream; +{{#jakarta}} +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; +{{/jakarta}} {{>generatedAnnotation}} {{#operations}} diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/apiServiceImpl.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/apiServiceImpl.mustache index aa22aae714..040406a8db 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/apiServiceImpl.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/apiServiceImpl.mustache @@ -13,9 +13,16 @@ import {{package}}.NotFoundException; import java.io.InputStream; +{{#jakarta}} +import jakarta.enterprise.context.RequestScoped; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +{{/jakarta}} +{{^jakarta}} import javax.enterprise.context.RequestScoped; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; +{{/jakarta}} @RequestScoped {{>generatedAnnotation}} diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/JacksonConfig.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/JacksonConfig.mustache index 923d26477d..e2eda9dc19 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/JacksonConfig.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/JacksonConfig.mustache @@ -1,9 +1,17 @@ package {{invokerPackage}}; +{{#jakarta}} +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.ext.ContextResolver; +import jakarta.ws.rs.ext.Provider; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.ext.ContextResolver; import javax.ws.rs.ext.Provider; +{{/jakarta}} import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,4 +49,4 @@ public class JacksonConfig implements ContextResolver { public ObjectMapper getContext(Class objectType) { return objectMapper; } -} \ No newline at end of file +} diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/RestApplication.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/RestApplication.mustache index f208b4e4da..1ddfaf8946 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/RestApplication.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/RestApplication.mustache @@ -1,7 +1,17 @@ package {{invokerPackage}}; +{{#jakarta}} +import jakarta.ws.rs.ApplicationPath; +import jakarta.ws.rs.core.Application; +import jakarta.servlet.ServletConfig; +import jakarta.ws.rs.core.Context; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; +import javax.servlet.ServletConfig; +import javax.ws.rs.core.Context; +{{/jakarta}} import java.util.Set; import java.util.HashSet; @@ -10,7 +20,6 @@ import java.util.HashSet; import io.swagger.jaxrs.config.BeanConfig; {{/useOas2}} {{^useOas2}} -import javax.servlet.ServletConfig; import io.swagger.v3.jaxrs2.integration.JaxrsOpenApiContextBuilder; import io.swagger.v3.oas.integration.OpenApiConfigurationException; import io.swagger.v3.oas.integration.SwaggerConfiguration; @@ -18,7 +27,6 @@ import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.info.Contact; import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.info.License; -import javax.ws.rs.core.Context; import java.util.stream.Collectors; import java.util.stream.Stream; {{/useOas2}} @@ -98,4 +106,4 @@ public class RestApplication extends Application { -} \ No newline at end of file +} diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/api.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/api.mustache index 6785626684..0bb116e491 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/api.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/api.mustache @@ -25,12 +25,25 @@ import java.util.Map; import java.io.InputStream; +{{#jakarta}} +import jakarta.ws.rs.core.Context; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +import jakarta.ws.rs.*; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; import javax.ws.rs.*; +{{/jakarta}} {{#useBeanValidation}} +{{#jakarta}} +import jakarta.validation.constraints.*; +{{/jakarta}} +{{^jakarta}} import javax.validation.constraints.*; +{{/jakarta}} {{/useBeanValidation}} {{#operations}} {{#operation}} diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/apiServiceImpl.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/apiServiceImpl.mustache index b37b1cf289..29558d2992 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/apiServiceImpl.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/apiServiceImpl.mustache @@ -12,8 +12,14 @@ import java.util.List; import java.io.InputStream; +{{#jakarta}} +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; +{{/jakarta}} {{>generatedAnnotation}} {{#operations}} diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/generatedAnnotation.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/generatedAnnotation.mustache index a47b6faa85..c6c0883bcb 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/generatedAnnotation.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/generatedAnnotation.mustache @@ -1 +1 @@ -{{^hideGenerationTimestamp}}@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}} \ No newline at end of file +{{^hideGenerationTimestamp}}@{{#jakarta}}jakarta{{/jakarta}}{{^jakarta}}javax{{/jakarta}}.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}} diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/gradle.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/gradle.mustache index 7ffb519dbe..f0d8e3d9d8 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/gradle.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/gradle.mustache @@ -12,11 +12,11 @@ dependencies { providedCompile 'org.jboss.resteasy:jaxrs-api:3.0.11.Final' providedCompile 'org.jboss.resteasy:resteasy-validator-provider-11:3.0.11.Final' providedCompile 'org.jboss.resteasy:resteasy-multipart-provider:3.0.11.Final' - providedCompile 'javax.annotation:javax.annotation-api:1.2' + providedCompile 'jakarta.annotation:jakarta.annotation-api:{{#jakarta}}2.1.1{{/jakarta}}{{^jakarta}}1.3.5{{/jakarta}}' providedCompile 'org.jboss.spec.javax.servlet:jboss-servlet-api_3.0_spec:1.0.0.Final' compile 'org.jboss.resteasy:resteasy-jackson2-provider:3.0.11.Final' {{#useBeanValidation}} - providedCompile 'javax.validation:validation-api:1.1.0.Final' + providedCompile 'jakarta.validation:jakarta.validation-api:{{#jakarta}}3.0.2{{/jakarta}}{{^jakarta}}2.0.2{{/jakarta}}' {{/useBeanValidation}} {{^java8}} compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.10.1' diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/model.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/model.mustache index 41abb664d0..5efaee7d00 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/model.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/model.mustache @@ -9,7 +9,12 @@ import java.util.ArrayList; import java.io.Serializable; {{/serializableModel}} {{#useBeanValidation}} +{{#jakarta}} +import jakarta.validation.constraints.*; +{{/jakarta}} +{{^jakarta}} import javax.validation.constraints.*; +{{/jakarta}} {{/useBeanValidation}} {{/x-is-composed-model}} {{#models}} diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/pom.mustache index 2b3e981440..134cdd7d4e 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/eap/pom.mustache @@ -98,8 +98,8 @@ ${slf4j-version} - javax.servlet - servlet-api + jakarta.servlet + jakarta-api ${servlet-api-version} @@ -134,9 +134,9 @@ ${resteasy-version} - javax.annotation - javax.annotation-api - 1.2 + jakarta.annotation + jakarta.annotation-api + {{#jakarta}}2.1.1{{/jakarta}}{{^jakarta}}1.3.5{{/jakarta}} {{#useOas2}} @@ -181,9 +181,9 @@ {{#useBeanValidation}} - javax.validation - validation-api - 1.1.0.Final + jakarta.validation + jakarta.validation-api + {{#jakarta}}3.0.2{{/jakarta}}{{^jakarta}}2.0.2{{/jakarta}} {{/useBeanValidation}} {{^java8}} @@ -248,6 +248,6 @@ 3.0.11.Final 1.6.3 4.13.1 - 2.5 + {{#jakarta}}6.0.0{{/jakarta}}{{^jakarta}}3.1.0{{/jakarta}} diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/generatedAnnotation.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/generatedAnnotation.mustache index a47b6faa85..c6c0883bcb 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/generatedAnnotation.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/generatedAnnotation.mustache @@ -1 +1 @@ -{{^hideGenerationTimestamp}}@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}} \ No newline at end of file +{{^hideGenerationTimestamp}}@{{#jakarta}}jakarta{{/jakarta}}{{^jakarta}}javax{{/jakarta}}.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}} diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/gradle.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/gradle.mustache index 2bb67d8638..a2f37b6e42 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/gradle.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/gradle.mustache @@ -12,7 +12,7 @@ dependencies { providedCompile 'org.jboss.resteasy:jaxrs-api:3.0.11.Final' providedCompile 'org.jboss.resteasy:resteasy-validator-provider-11:3.0.11.Final' providedCompile 'org.jboss.resteasy:resteasy-multipart-provider:3.0.11.Final' - providedCompile 'javax.annotation:javax.annotation-api:1.2' + providedCompile 'jakarta.annotation:jakarta.annotation-api:{{#jakarta}}2.1.1{{/jakarta}}{{^jakarta}}1.3.5{{/jakarta}}' providedCompile 'javax:javaee-api:7.0' providedCompile 'org.jboss.spec.javax.servlet:jboss-servlet-api_3.0_spec:1.0.0.Final' {{#useOas2}} @@ -24,7 +24,7 @@ dependencies { compile 'org.jboss.resteasy:resteasy-jackson2-provider:3.0.11.Final' compile 'org.apache.httpcomponents:httpclient:4.5.10' {{#useBeanValidation}} - providedCompile 'javax.validation:validation-api:1.1.0.Final' + providedCompile 'jakarta.validation:jakarta.validation-api:{{#jakarta}}3.0.2{{/jakarta}}{{^jakarta}}2.0.2{{/jakarta}}' {{/useBeanValidation}} {{^java8}} compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.10.1' diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/model.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/model.mustache index 41abb664d0..5efaee7d00 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/model.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/model.mustache @@ -9,7 +9,12 @@ import java.util.ArrayList; import java.io.Serializable; {{/serializableModel}} {{#useBeanValidation}} +{{#jakarta}} +import jakarta.validation.constraints.*; +{{/jakarta}} +{{^jakarta}} import javax.validation.constraints.*; +{{/jakarta}} {{/useBeanValidation}} {{/x-is-composed-model}} {{#models}} diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/pom.mustache index 70a6016cfe..b7cc782eb1 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/pom.mustache @@ -84,12 +84,22 @@ slf4j-log4j12 ${slf4j-version} + {{#jakarta}} + + jakarta.servlet + jakarta-api + ${servlet-api-version} + provided + + {{/jakarta}} + {{^jakarta}} javax.servlet servlet-api ${servlet-api-version} provided + {{/jakarta}} org.jboss.resteasy @@ -121,9 +131,9 @@ provided - javax.annotation - javax.annotation-api - 1.2 + jakarta.annotation + jakarta.annotation-api + {{#jakarta}}2.1.1{{/jakarta}}{{^jakarta}}1.3.5{{/jakarta}} provided {{#java8}} @@ -194,9 +204,9 @@ {{#useBeanValidation}} - javax.validation - validation-api - 1.1.0.Final + jakarta.validation + jakarta.validation-api + {{#jakarta}}3.0.2{{/jakarta}}{{^jakarta}}2.0.2{{/jakarta}} provided {{/useBeanValidation}} @@ -222,7 +232,7 @@ 3.0.11.Final 1.6.3 4.13.1 - 2.5 + {{#jakarta}}6.0.0{{/jakarta}}{{^jakarta}}3.1.0{{/jakarta}} {{#java8}}2.10.1{{/java8}} diff --git a/src/main/resources/handlebars/JavaJaxRS/spec/RestApplication.mustache b/src/main/resources/handlebars/JavaJaxRS/spec/RestApplication.mustache index 82b8d9533e..74127894d7 100644 --- a/src/main/resources/handlebars/JavaJaxRS/spec/RestApplication.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/spec/RestApplication.mustache @@ -1,7 +1,13 @@ package {{invokerPackage}}; +{{#jakarta}} +import jakarta.ws.rs.ApplicationPath; +import jakarta.ws.rs.core.Application; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; +{{/jakarta}} @ApplicationPath("/") public class RestApplication extends Application { diff --git a/src/main/resources/handlebars/JavaJaxRS/spec/api.mustache b/src/main/resources/handlebars/JavaJaxRS/spec/api.mustache index 305d2ac928..e942aa61e7 100644 --- a/src/main/resources/handlebars/JavaJaxRS/spec/api.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/spec/api.mustache @@ -3,8 +3,14 @@ package {{package}}; {{#imports}}import {{import}}; {{/imports}} +{{#jakarta}} +import jakarta.ws.rs.*; +import jakarta.ws.rs.core.Response; +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.*; import javax.ws.rs.core.Response; +{{/jakarta}} {{#useOas2}} import io.swagger.annotations.*; @@ -22,8 +28,16 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement; import java.util.Map; import java.util.List; -{{#useBeanValidation}}import javax.validation.constraints.*; -import javax.validation.Valid;{{/useBeanValidation}} +{{#useBeanValidation}} +{{#jakarta}} +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; +{{/jakarta}} +{{^jakarta}} +import javax.validation.constraints.*; +import javax.validation.Valid; +{{/jakarta}} +{{/useBeanValidation}} @Path("/{{{baseName}}}") {{#useOas2}} @@ -40,4 +54,4 @@ import javax.validation.Valid;{{/useBeanValidation}} {{/contents}} {{/operation}} } -{{/operations}} \ No newline at end of file +{{/operations}} diff --git a/src/main/resources/handlebars/JavaJaxRS/spec/generatedAnnotation.mustache b/src/main/resources/handlebars/JavaJaxRS/spec/generatedAnnotation.mustache index ad17a426e9..c6c0883bcb 100644 --- a/src/main/resources/handlebars/JavaJaxRS/spec/generatedAnnotation.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/spec/generatedAnnotation.mustache @@ -1,3 +1 @@ -{{^hideGenerationTimestamp}} -@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}") -{{/hideGenerationTimestamp}} \ No newline at end of file +{{^hideGenerationTimestamp}}@{{#jakarta}}jakarta{{/jakarta}}{{^jakarta}}javax{{/jakarta}}.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}} diff --git a/src/main/resources/handlebars/JavaJaxRS/spec/model.mustache b/src/main/resources/handlebars/JavaJaxRS/spec/model.mustache index 12a22e18ee..67a3c2dd73 100644 --- a/src/main/resources/handlebars/JavaJaxRS/spec/model.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/spec/model.mustache @@ -7,8 +7,14 @@ package {{package}}; import java.io.Serializable; {{/serializableModel}} {{#useBeanValidation}} +{{#jakarta}} +import jakarta.validation.constraints.*; +import jakarta.validation.Valid; +{{/jakarta}} +{{^jakarta}} import javax.validation.constraints.*; import javax.validation.Valid; +{{/jakarta}} {{/useBeanValidation}} {{/x-is-composed-model}} diff --git a/src/main/resources/handlebars/JavaJaxRS/spec/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/spec/pom.mustache index 4a8e89beb4..2a3d8cdfc0 100644 --- a/src/main/resources/handlebars/JavaJaxRS/spec/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/spec/pom.mustache @@ -55,9 +55,9 @@ {{/java11}} - javax.ws.rs - javax.ws.rs-api - 2.0 + jakarta.ws.rs + jakarta.ws.rs-api + {{#jakarta}}3.1.0{{/jakarta}}{{^jakarta}}2.1.6{{/jakarta}} provided {{#useOas2}} @@ -105,9 +105,9 @@ {{#useBeanValidation}} - javax.validation - validation-api - 1.1.0.Final + jakarta.validation + jakarta.validation-api + {{#jakarta}}3.0.2{{/jakarta}}{{^jakarta}}2.0.2{{/jakarta}} provided {{/useBeanValidation}} From 0bc7a1ee2e6d4ac7ee076f8e99ed800ad56016c1 Mon Sep 17 00:00:00 2001 From: Fyro Date: Mon, 26 Dec 2022 20:07:05 +0100 Subject: [PATCH 3/8] add jakarta implementation https://github.com/swagger-api/swagger-codegen-generators/issues/1054 --- .../handlebars/JavaMicronaut/api.mustache | 7 +++++++ .../handlebars/JavaMicronaut/api_test.mustache | 5 +++++ .../JavaMicronaut/generatedAnnotation.mustache | 4 +--- .../handlebars/JavaMicronaut/model.mustache | 11 +++++++++++ ...nsupportedOperationExceptionHandler.mustache | 7 ++++++- .../handlebars/JavaSpring/api.mustache | 6 ++++++ .../JavaSpring/apiController.mustache | 10 ++++++++-- .../JavaSpring/apiOriginFilter.mustache | 8 +++++++- .../JavaSpring/apiResponseMessage.mustache | 10 ++++++++++ .../JavaSpring/generatedAnnotation.mustache | 4 +--- .../libraries/spring-boot/pom.mustache | 4 ++-- .../libraries/spring-cloud/pom.mustache | 17 +++++++++++++---- .../libraries/spring-mvc/pom.mustache | 11 ++++++++++- .../handlebars/JavaSpring/model.mustache | 11 +++++++++++ 14 files changed, 98 insertions(+), 17 deletions(-) diff --git a/src/main/resources/handlebars/JavaMicronaut/api.mustache b/src/main/resources/handlebars/JavaMicronaut/api.mustache index f10469f744..64f65fa789 100644 --- a/src/main/resources/handlebars/JavaMicronaut/api.mustache +++ b/src/main/resources/handlebars/JavaMicronaut/api.mustache @@ -17,9 +17,16 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; {{#useBeanValidation}} +{{#jakarta}} +import jakarta.annotation.Nullable; +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +{{/jakarta}} +{{^jakarta}} import javax.annotation.Nullable; import javax.validation.Valid; import javax.validation.constraints.*; +{{/jakarta}} {{/useBeanValidation}} import java.io.IOException; import java.util.List; diff --git a/src/main/resources/handlebars/JavaMicronaut/api_test.mustache b/src/main/resources/handlebars/JavaMicronaut/api_test.mustache index d965ccbd92..9bb78225f2 100644 --- a/src/main/resources/handlebars/JavaMicronaut/api_test.mustache +++ b/src/main/resources/handlebars/JavaMicronaut/api_test.mustache @@ -8,7 +8,12 @@ import io.micronaut.http.HttpStatus; import io.micronaut.test.annotation.MicronautTest; import org.junit.jupiter.api.Test; +{{#jakarta}} +import jakarta.inject.Inject; +{{/jakarta}} +{{^jakarta}} import javax.inject.Inject; +{{/jakarta}} import java.util.*; diff --git a/src/main/resources/handlebars/JavaMicronaut/generatedAnnotation.mustache b/src/main/resources/handlebars/JavaMicronaut/generatedAnnotation.mustache index ad17a426e9..c6c0883bcb 100644 --- a/src/main/resources/handlebars/JavaMicronaut/generatedAnnotation.mustache +++ b/src/main/resources/handlebars/JavaMicronaut/generatedAnnotation.mustache @@ -1,3 +1 @@ -{{^hideGenerationTimestamp}} -@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}") -{{/hideGenerationTimestamp}} \ No newline at end of file +{{^hideGenerationTimestamp}}@{{#jakarta}}jakarta{{/jakarta}}{{^jakarta}}javax{{/jakarta}}.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}} diff --git a/src/main/resources/handlebars/JavaMicronaut/model.mustache b/src/main/resources/handlebars/JavaMicronaut/model.mustache index b34290e15e..c2debf22ad 100644 --- a/src/main/resources/handlebars/JavaMicronaut/model.mustache +++ b/src/main/resources/handlebars/JavaMicronaut/model.mustache @@ -8,8 +8,14 @@ import java.io.Serializable; {{/serializableModel}} {{#useBeanValidation}} import io.micronaut.validation.Validated; +{{#jakarta}} +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +{{/jakarta}} +{{^jakarta}} import javax.validation.Valid; import javax.validation.constraints.*; +{{/jakarta}} {{/useBeanValidation}} {{#jackson}} {{#withXml}} @@ -18,7 +24,12 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; {{/withXml}} {{/jackson}} {{#withXml}} +{{#jakarta}} +import jakarta.xml.bind.annotation.*; +{{/jakarta}} +{{^jakarta}} import javax.xml.bind.annotation.*; +{{/jakarta}} {{/withXml}} {{#models}} diff --git a/src/main/resources/handlebars/JavaMicronaut/unsupportedOperationExceptionHandler.mustache b/src/main/resources/handlebars/JavaMicronaut/unsupportedOperationExceptionHandler.mustache index 8322cd7af4..98d04d41a4 100644 --- a/src/main/resources/handlebars/JavaMicronaut/unsupportedOperationExceptionHandler.mustache +++ b/src/main/resources/handlebars/JavaMicronaut/unsupportedOperationExceptionHandler.mustache @@ -8,7 +8,12 @@ import io.micronaut.http.HttpStatus; import io.micronaut.http.annotation.Produces; import io.micronaut.http.server.exceptions.ExceptionHandler; +{{#jakarta}} +import jakarta.inject.Singleton; +{{/jakarta}} +{{^jakarta}} import javax.inject.Singleton; +{{/jakarta}} @Produces @Singleton @@ -19,4 +24,4 @@ public class UnsupportedOperationExceptionHandler implements ExceptionHandlergeneratedAnnotation}} -public class ApiOriginFilter implements javax.servlet.Filter { +public class ApiOriginFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { diff --git a/src/main/resources/handlebars/JavaSpring/apiResponseMessage.mustache b/src/main/resources/handlebars/JavaSpring/apiResponseMessage.mustache index 17b155f3b6..a978341556 100644 --- a/src/main/resources/handlebars/JavaSpring/apiResponseMessage.mustache +++ b/src/main/resources/handlebars/JavaSpring/apiResponseMessage.mustache @@ -1,9 +1,19 @@ package {{apiPackage}}; +{{#jakarta}} +import jakarta.xml.bind.annotation.XmlTransient; +{{/jakarta}} +{{^jakarta}} import javax.xml.bind.annotation.XmlTransient; +{{/jakarta}} {{>generatedAnnotation}} +{{#jakarta}} +@jakarta.xml.bind.annotation.XmlRootElement +{{/jakarta}} +{{^jakarta}} @javax.xml.bind.annotation.XmlRootElement +{{/jakarta}} public class ApiResponseMessage { public static final int ERROR = 1; public static final int WARNING = 2; diff --git a/src/main/resources/handlebars/JavaSpring/generatedAnnotation.mustache b/src/main/resources/handlebars/JavaSpring/generatedAnnotation.mustache index ad17a426e9..c6c0883bcb 100644 --- a/src/main/resources/handlebars/JavaSpring/generatedAnnotation.mustache +++ b/src/main/resources/handlebars/JavaSpring/generatedAnnotation.mustache @@ -1,3 +1 @@ -{{^hideGenerationTimestamp}} -@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}") -{{/hideGenerationTimestamp}} \ No newline at end of file +{{^hideGenerationTimestamp}}@{{#jakarta}}jakarta{{/jakarta}}{{^jakarta}}javax{{/jakarta}}.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}} diff --git a/src/main/resources/handlebars/JavaSpring/libraries/spring-boot/pom.mustache b/src/main/resources/handlebars/JavaSpring/libraries/spring-boot/pom.mustache index 6a504ed061..c3c48e39ff 100644 --- a/src/main/resources/handlebars/JavaSpring/libraries/spring-boot/pom.mustache +++ b/src/main/resources/handlebars/JavaSpring/libraries/spring-boot/pom.mustache @@ -147,8 +147,8 @@ - javax.validation - validation-api + jakarta.validation + jakarta.validation-api {{/useBeanValidation}} {{#notNullJacksonAnnotation}} diff --git a/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/pom.mustache b/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/pom.mustache index b545860edb..e7b529d005 100644 --- a/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/pom.mustache +++ b/src/main/resources/handlebars/JavaSpring/libraries/spring-cloud/pom.mustache @@ -114,9 +114,9 @@ {{#useBeanValidation}} - javax.validation - validation-api - 1.1.0.Final + jakarta.validation + jakarta.validation-api + {{#jakarta}}3.0.2{{/jakarta}}{{^jakarta}}2.0.2{{/jakarta}} provided {{/useBeanValidation}} @@ -132,12 +132,21 @@ 2.10.1 {{/notNullJacksonAnnotation}} - + +{{#jakarta}} + + jakarta.servlet + jakarta-api + provided + +{{/jakarta}} +{{^jakarta}} javax.servlet javax.servlet-api provided +{{/jakarta}} {{#wiremock}} com.github.tomakehurst diff --git a/src/main/resources/handlebars/JavaSpring/libraries/spring-mvc/pom.mustache b/src/main/resources/handlebars/JavaSpring/libraries/spring-mvc/pom.mustache index 4d85d3a3b9..a7746c0cca 100644 --- a/src/main/resources/handlebars/JavaSpring/libraries/spring-mvc/pom.mustache +++ b/src/main/resources/handlebars/JavaSpring/libraries/spring-mvc/pom.mustache @@ -175,11 +175,20 @@ ${junit-version} test +{{#jakarta}} + + jakarta.servlet + jakarta-api + ${servlet-api-version} + +{{/jakarta}} +{{^jakarta}} javax.servlet servlet-api ${servlet-api-version} +{{/jakarta}} {{#useBeanValidation}} @@ -230,7 +239,7 @@ 9.3.28.v20191105 1.7.21 4.13.1 - 2.5 + {{#jakarta}}6.0.0{{/jakarta}}{{^jakarta}}3.1.0{{/jakarta}} {{#useOas2}} 2.9.2 {{/useOas2}} diff --git a/src/main/resources/handlebars/JavaSpring/model.mustache b/src/main/resources/handlebars/JavaSpring/model.mustache index c0f606fb66..681b07890c 100644 --- a/src/main/resources/handlebars/JavaSpring/model.mustache +++ b/src/main/resources/handlebars/JavaSpring/model.mustache @@ -9,8 +9,14 @@ import java.io.Serializable; {{/serializableModel}} {{#useBeanValidation}} import org.springframework.validation.annotation.Validated; +{{#jakarta}} +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +{{/jakarta}} +{{^jakarta}} import javax.validation.Valid; import javax.validation.constraints.*; +{{/jakarta}} {{/useBeanValidation}} {{#jackson}} {{#withXml}} @@ -19,7 +25,12 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; {{/withXml}} {{/jackson}} {{#withXml}} +{{#jakarta}} +import jakarta.xml.bind.annotation.*; +{{/jakarta}} +{{^jakarta}} import javax.xml.bind.annotation.*; +{{/jakarta}} {{/withXml}} {{/x-is-composed-model}} From 47fa4930f3072b20271fbbc3f507f0ece8ce1821 Mon Sep 17 00:00:00 2001 From: Fyro Date: Mon, 26 Dec 2022 20:09:01 +0100 Subject: [PATCH 4/8] add jakarta implementation https://github.com/swagger-api/swagger-codegen-generators/issues/1054 --- src/main/resources/handlebars/scala/client/api.mustache | 5 +++++ .../resources/handlebars/scala/client/apiInvoker.mustache | 5 +++++ .../resources/handlebars/scala/client/build.gradle.mustache | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/resources/handlebars/scala/client/api.mustache b/src/main/resources/handlebars/scala/client/api.mustache index f67133052c..a82699f9f5 100644 --- a/src/main/resources/handlebars/scala/client/api.mustache +++ b/src/main/resources/handlebars/scala/client/api.mustache @@ -10,7 +10,12 @@ import {{invokerPackage}}.{ApiInvoker, ApiException} import com.sun.jersey.multipart.FormDataMultiPart import com.sun.jersey.multipart.file.FileDataBodyPart +{{#jakarta}} +import jakarta.ws.rs.core.MediaType +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.core.MediaType +{{/jakarta}} import java.io.File import java.util.Date diff --git a/src/main/resources/handlebars/scala/client/apiInvoker.mustache b/src/main/resources/handlebars/scala/client/apiInvoker.mustache index 23dcba8562..c93b0680f0 100644 --- a/src/main/resources/handlebars/scala/client/apiInvoker.mustache +++ b/src/main/resources/handlebars/scala/client/apiInvoker.mustache @@ -14,7 +14,12 @@ import com.sun.jersey.multipart.file.FileDataBodyPart import java.io.File import java.net.URLEncoder import java.util.UUID +{{#jakarta}} +import jakarta.ws.rs.core.MediaType +{{/jakarta}} +{{^jakarta}} import javax.ws.rs.core.MediaType +{{/jakarta}} import scala.collection.JavaConverters._ import scala.collection.mutable diff --git a/src/main/resources/handlebars/scala/client/build.gradle.mustache b/src/main/resources/handlebars/scala/client/build.gradle.mustache index e124eb0a5c..74337b226d 100644 --- a/src/main/resources/handlebars/scala/client/build.gradle.mustache +++ b/src/main/resources/handlebars/scala/client/build.gradle.mustache @@ -48,7 +48,7 @@ if(hasProperty('target') && target == 'android') { } dependencies { - provided 'javax.annotation:jsr250-api:1.0' + provided 'jakarta.annotation:jakarta.annotation-api:{{#jakarta}}2.1.1{{/jakarta}}{{^jakarta}}1.3.5{{/jakarta}}' } } From 7b341ac67b487423525f7ccd93557a9a0e0f4efa Mon Sep 17 00:00:00 2001 From: Fyro Date: Mon, 26 Dec 2022 20:14:43 +0100 Subject: [PATCH 5/8] add jakarta implementation https://github.com/swagger-api/swagger-codegen-generators/issues/1054 --- .../resources/handlebars/JavaJaxRS/cxf-cdi/pom.mustache | 8 ++++---- .../resources/handlebars/JavaJaxRS/resteasy/pom.mustache | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pom.mustache index 596f172a32..2a74fcb13c 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf-cdi/pom.mustache @@ -47,9 +47,9 @@ - javax - javaee-api - 7.0 + jakarta.platform + jakarta.jakartaee-api + {{#jakarta}}10.0.0{{/jakarta}}{{^jakarta}}8.0.0{{/jakarta}} provided @@ -59,7 +59,7 @@ cxf-rt-frontend-jaxrs - 3.0.2 + {{#jakarta}}4.0.0{{/jakarta}}{{^jakarta}}3.5.5{{/jakarta}} provided diff --git a/src/main/resources/handlebars/JavaJaxRS/resteasy/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/resteasy/pom.mustache index b7cc782eb1..43bc08ad5b 100644 --- a/src/main/resources/handlebars/JavaJaxRS/resteasy/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/resteasy/pom.mustache @@ -60,9 +60,9 @@ - javax - javaee-api - 7.0 + jakarta.platform + jakarta.jakartaee-api + {{#jakarta}}10.0.0{{/jakarta}}{{^jakarta}}8.0.0{{/jakarta}} provided {{#useOas2}} From 970e1c366015ad38f0057540762b8df5786cdd94 Mon Sep 17 00:00:00 2001 From: Fyro Date: Mon, 26 Dec 2022 20:33:48 +0100 Subject: [PATCH 6/8] update deps --- .../Java/build.gradle.java11.mustache | 6 +++--- .../handlebars/Java/build.gradle.mustache | 2 +- .../feign/build.gradle.java11.mustache | 4 ++-- .../Java/libraries/feign/pom.mustache | 2 +- .../jersey2/build.gradle.java11.mustache | 2 +- .../libraries/jersey2/build.gradle.mustache | 2 +- .../okhttp-gson/build.gradle.java11.mustache | 2 +- .../Java/libraries/okhttp-gson/pom.mustache | 13 ++++++++++-- .../libraries/resteasy/build.gradle.mustache | 2 +- .../resttemplate/build.gradle.java11.mustache | 4 ++-- .../Java/libraries/resttemplate/pom.mustache | 2 +- .../retrofit/build.gradle.java11.mustache | 2 +- .../Java/libraries/retrofit/pom.mustache | 2 +- .../retrofit2/build.gradle.java11.mustache | 2 +- .../Java/libraries/retrofit2/pom.mustache | 2 +- .../resources/handlebars/Java/pom.mustache | 2 +- .../handlebars/JavaJaxRS/cxf/pom.mustache | 21 ++++++++++++------- .../JavaJaxRS/cxf/server/pom.mustache | 2 +- .../handlebars/JavaJaxRS/spec/pom.mustache | 2 +- .../libraries/spring-boot/pom.mustache | 2 +- .../options/JavaOptionsProvider.java | 1 + 21 files changed, 47 insertions(+), 32 deletions(-) diff --git a/src/main/resources/handlebars/Java/build.gradle.java11.mustache b/src/main/resources/handlebars/Java/build.gradle.java11.mustache index 5e7621a111..3b86cfec6f 100644 --- a/src/main/resources/handlebars/Java/build.gradle.java11.mustache +++ b/src/main/resources/handlebars/Java/build.gradle.java11.mustache @@ -13,7 +13,7 @@ repositories { ext { swagger_annotations_version = "{{#useOas2}}1.5.24{{/useOas2}}{{^useOas2}}2.0.0{{/useOas2}}" jackson_version = "{{^threetenbp}}2.11.4{{/threetenbp}}{{#threetenbp}}2.6.4{{/threetenbp}}" - jersey_version = "1.19.4" + jersey_version = "{{#jakarta}}3.1.0{{/jakarta}}{{^jakarta}}1.19.4{{/jakarta}}" jodatime_version = "2.10.5" junit_version = "4.13.1" } @@ -38,7 +38,7 @@ dependencies { {{#threetenbp}} implementation "com.github.joschi.jackson:jackson-datatype-threetenbp:$jackson_version" {{/threetenbp}} - implementation 'com.sun.xml.ws:jaxws-rt:2.3.3' + implementation 'com.sun.xml.ws:jaxws-rt:{{#jakarta}}4.0.0{{/jakarta}}{{^jakarta}}2.3.3{{/jakarta}}' testImplementation "junit:junit:$junit_version" {{#wiremock}} testImplementation "com.github.tomakehurst:wiremock:2.27.2" @@ -73,4 +73,4 @@ publishing { tasks.withType(JavaCompile) { options.encoding = 'UTF-8' -} \ No newline at end of file +} diff --git a/src/main/resources/handlebars/Java/build.gradle.mustache b/src/main/resources/handlebars/Java/build.gradle.mustache index 2efb02049b..40eec0f705 100644 --- a/src/main/resources/handlebars/Java/build.gradle.mustache +++ b/src/main/resources/handlebars/Java/build.gradle.mustache @@ -113,7 +113,7 @@ ext { swagger_annotations_version = "2.0.0" {{/useOas2}} jackson_version = "2.10.1" - jersey_version = "1.19.4" + jersey_version = "{{#jakarta}}3.1.0{{/jakarta}}{{^jakarta}}1.19.4{{/jakarta}}" jodatime_version = "2.9.9" junit_version = "4.12" } diff --git a/src/main/resources/handlebars/Java/libraries/feign/build.gradle.java11.mustache b/src/main/resources/handlebars/Java/libraries/feign/build.gradle.java11.mustache index 8338de5d2f..4807c37713 100644 --- a/src/main/resources/handlebars/Java/libraries/feign/build.gradle.java11.mustache +++ b/src/main/resources/handlebars/Java/libraries/feign/build.gradle.java11.mustache @@ -50,7 +50,7 @@ dependencies { } implementation "org.json:json:20180130" implementation "com.brsanthu:migbase64:2.2" - implementation "com.sun.xml.ws:jaxws-rt:2.3.3" + implementation "com.sun.xml.ws:jaxws-rt:{{#jakarta}}4.0.0{{/jakarta}}{{^jakarta}}2.3.3{{/jakarta}}" testImplementation "junit:junit:$junit_version" testImplementation "com.squareup.okhttp3:mockwebserver:3.6.0" testImplementation "org.assertj:assertj-core:1.7.1" @@ -87,4 +87,4 @@ publishing { tasks.withType(JavaCompile) { options.encoding = 'UTF-8' -} \ No newline at end of file +} diff --git a/src/main/resources/handlebars/Java/libraries/feign/pom.mustache b/src/main/resources/handlebars/Java/libraries/feign/pom.mustache index d212388bd2..fb7f3e4c0d 100644 --- a/src/main/resources/handlebars/Java/libraries/feign/pom.mustache +++ b/src/main/resources/handlebars/Java/libraries/feign/pom.mustache @@ -175,7 +175,7 @@ com.sun.xml.ws jaxws-rt - 2.3.3 + {{#jakarta}}4.0.0{{/jakarta}}{{^jakarta}}2.3.3{{/jakarta}} pom diff --git a/src/main/resources/handlebars/Java/libraries/jersey2/build.gradle.java11.mustache b/src/main/resources/handlebars/Java/libraries/jersey2/build.gradle.java11.mustache index dd7a6aeda1..a4ccb154df 100644 --- a/src/main/resources/handlebars/Java/libraries/jersey2/build.gradle.java11.mustache +++ b/src/main/resources/handlebars/Java/libraries/jersey2/build.gradle.java11.mustache @@ -13,7 +13,7 @@ repositories { ext { swagger_annotations_version = "{{#useOas2}}1.5.24{{/useOas2}}{{^useOas2}}2.0.0{{/useOas2}}" jackson_version = "2.6.4" - jersey_version = "2.29.1" + jersey_version = "{{#jakarta}}3.1.0{{/jakarta}}{{^jakarta}}2.29.1{{/jakarta}}" junit_version = "4.13.1" } diff --git a/src/main/resources/handlebars/Java/libraries/jersey2/build.gradle.mustache b/src/main/resources/handlebars/Java/libraries/jersey2/build.gradle.mustache index 772b0ecbc9..118c930951 100644 --- a/src/main/resources/handlebars/Java/libraries/jersey2/build.gradle.mustache +++ b/src/main/resources/handlebars/Java/libraries/jersey2/build.gradle.mustache @@ -112,7 +112,7 @@ ext { swagger_annotations_version = "2.0.0" {{/useOas2}} jackson_version = "2.10.1" - jersey_version = "2.26" + jersey_version = "{{#jakarta}}3.1.0{{/jakarta}}{{^jakarta}}2.26{{/jakarta}}" {{#supportJava6}} commons_io_version=2.5 commons_lang3_version=3.6 diff --git a/src/main/resources/handlebars/Java/libraries/okhttp-gson/build.gradle.java11.mustache b/src/main/resources/handlebars/Java/libraries/okhttp-gson/build.gradle.java11.mustache index 3d98e49209..8208643f6a 100644 --- a/src/main/resources/handlebars/Java/libraries/okhttp-gson/build.gradle.java11.mustache +++ b/src/main/resources/handlebars/Java/libraries/okhttp-gson/build.gradle.java11.mustache @@ -27,7 +27,7 @@ dependencies { {{#threetenbp}} implementation 'org.threeten:threetenbp:1.3.5' {{/threetenbp}} - implementation 'com.sun.xml.ws:jaxws-rt:2.3.3' + implementation 'com.sun.xml.ws:jaxws-rt:{{#jakarta}}4.0.0{{/jakarta}}{{^jakarta}}2.3.3{{/jakarta}}' testImplementation 'junit:junit:4.13.1' {{#wiremock}} testImplementation "com.github.tomakehurst:wiremock:2.27.2" diff --git a/src/main/resources/handlebars/Java/libraries/okhttp-gson/pom.mustache b/src/main/resources/handlebars/Java/libraries/okhttp-gson/pom.mustache index defa90516b..e284c84307 100644 --- a/src/main/resources/handlebars/Java/libraries/okhttp-gson/pom.mustache +++ b/src/main/resources/handlebars/Java/libraries/okhttp-gson/pom.mustache @@ -176,7 +176,7 @@ com.sun.xml.ws jaxws-rt - 2.3.3 + {{#jakarta}}4.0.0{{/jakarta}}{{^jakarta}}2.3.3{{/jakarta}} pom @@ -266,13 +266,22 @@ org.hibernate hibernate-validator - 5.4.1.Final + {{#jakarta}}8.0.0.Final{{/jakarta}}{{^jakarta}}5.4.1.Final{{/jakarta}} + {{#jakarta}} + + jakarta.el + jakarta.el-api + 5.0.1 + + {{/jakarta}} + {{^jakarta}} javax.el el-api 2.2 + {{/jakarta}} {{/performBeanValidation}} {{#parcelableModel}} diff --git a/src/main/resources/handlebars/Java/libraries/resteasy/build.gradle.mustache b/src/main/resources/handlebars/Java/libraries/resteasy/build.gradle.mustache index 9a23261294..fb20d58b24 100644 --- a/src/main/resources/handlebars/Java/libraries/resteasy/build.gradle.mustache +++ b/src/main/resources/handlebars/Java/libraries/resteasy/build.gradle.mustache @@ -112,7 +112,7 @@ ext { swagger_annotations_version = "2.0.0" {{/useOas2}} jackson_version = "2.10.1" - jersey_version = "2.22.2" + jersey_version = "{{#jakarta}}3.1.0{{/jakarta}}{{^jakarta}}2.22.2{{/jakarta}}" {{^java8}} jodatime_version = "2.9.4" {{/java8}} diff --git a/src/main/resources/handlebars/Java/libraries/resttemplate/build.gradle.java11.mustache b/src/main/resources/handlebars/Java/libraries/resttemplate/build.gradle.java11.mustache index d78adeb215..7f04f3cbdf 100644 --- a/src/main/resources/handlebars/Java/libraries/resttemplate/build.gradle.java11.mustache +++ b/src/main/resources/handlebars/Java/libraries/resttemplate/build.gradle.java11.mustache @@ -43,7 +43,7 @@ dependencies { {{#withXml}} implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:$jackson_version" {{/withXml}} - implementation "com.sun.xml.ws:jaxws-rt:2.3.3" + implementation "com.sun.xml.ws:jaxws-rt:{{#jakarta}}4.0.0{{/jakarta}}{{^jakarta}}2.3.3{{/jakarta}}" testImplementation "junit:junit:$junit_version" {{#wiremock}} testImplementation "com.github.tomakehurst:wiremock:2.27.2" @@ -78,4 +78,4 @@ publishing { tasks.withType(JavaCompile) { options.encoding = 'UTF-8' -} \ No newline at end of file +} diff --git a/src/main/resources/handlebars/Java/libraries/resttemplate/pom.mustache b/src/main/resources/handlebars/Java/libraries/resttemplate/pom.mustache index 247b7251e9..bdeb2052e5 100644 --- a/src/main/resources/handlebars/Java/libraries/resttemplate/pom.mustache +++ b/src/main/resources/handlebars/Java/libraries/resttemplate/pom.mustache @@ -191,7 +191,7 @@ com.sun.xml.ws jaxws-rt - 2.3.3 + {{#jakarta}}4.0.0{{/jakarta}}{{^jakarta}}2.3.3{{/jakarta}} pom diff --git a/src/main/resources/handlebars/Java/libraries/retrofit/build.gradle.java11.mustache b/src/main/resources/handlebars/Java/libraries/retrofit/build.gradle.java11.mustache index 6219999f5a..69654df15c 100644 --- a/src/main/resources/handlebars/Java/libraries/retrofit/build.gradle.java11.mustache +++ b/src/main/resources/handlebars/Java/libraries/retrofit/build.gradle.java11.mustache @@ -33,7 +33,7 @@ dependencies { } implementation "org.json:json:20180130" implementation "joda-time:joda-time:$jodatime_version" - implementation "com.sun.xml.ws:jaxws-rt:2.3.3" + implementation "com.sun.xml.ws:jaxws-rt:{{#jakarta}}4.0.0{{/jakarta}}{{^jakarta}}2.3.3{{/jakarta}}" testImplementation "junit:junit:$junit_version" {{#wiremock}} testImplementation "com.github.tomakehurst:wiremock:2.27.2" diff --git a/src/main/resources/handlebars/Java/libraries/retrofit/pom.mustache b/src/main/resources/handlebars/Java/libraries/retrofit/pom.mustache index 4f1ad53552..c099b11501 100644 --- a/src/main/resources/handlebars/Java/libraries/retrofit/pom.mustache +++ b/src/main/resources/handlebars/Java/libraries/retrofit/pom.mustache @@ -184,7 +184,7 @@ com.sun.xml.ws jaxws-rt - 2.3.3 + {{#jakarta}}4.0.0{{/jakarta}}{{^jakarta}}2.3.3{{/jakarta}} pom diff --git a/src/main/resources/handlebars/Java/libraries/retrofit2/build.gradle.java11.mustache b/src/main/resources/handlebars/Java/libraries/retrofit2/build.gradle.java11.mustache index 8c02430156..cc2368e844 100644 --- a/src/main/resources/handlebars/Java/libraries/retrofit2/build.gradle.java11.mustache +++ b/src/main/resources/handlebars/Java/libraries/retrofit2/build.gradle.java11.mustache @@ -77,7 +77,7 @@ dependencies { implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version" implementation "com.fasterxml.jackson.datatype:jackson-datatype-joda:$jackson_version" {{/usePlayWS}} - implementation "com.sun.xml.ws:jaxws-rt:2.3.3" + implementation "com.sun.xml.ws:jaxws-rt:{{#jakarta}}4.0.0{{/jakarta}}{{^jakarta}}2.3.3{{/jakarta}}" {{#wiremock}} testImplementation "com.github.tomakehurst:wiremock:2.27.2" {{/wiremock}} diff --git a/src/main/resources/handlebars/Java/libraries/retrofit2/pom.mustache b/src/main/resources/handlebars/Java/libraries/retrofit2/pom.mustache index 75033db69a..3404e55b5b 100644 --- a/src/main/resources/handlebars/Java/libraries/retrofit2/pom.mustache +++ b/src/main/resources/handlebars/Java/libraries/retrofit2/pom.mustache @@ -176,7 +176,7 @@ com.sun.xml.ws jaxws-rt - 2.3.3 + {{#jakarta}}4.0.0{{/jakarta}}{{^jakarta}}2.3.3{{/jakarta}} pom diff --git a/src/main/resources/handlebars/Java/pom.mustache b/src/main/resources/handlebars/Java/pom.mustache index a23134d45b..d16d182cda 100644 --- a/src/main/resources/handlebars/Java/pom.mustache +++ b/src/main/resources/handlebars/Java/pom.mustache @@ -191,7 +191,7 @@ com.sun.xml.ws jaxws-rt - 2.3.3 + {{#jakarta}}4.0.0{{/jakarta}}{{^jakarta}}2.3.3{{/jakarta}} pom diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf/pom.mustache index f8de92160a..1adfc639de 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf/pom.mustache @@ -191,18 +191,23 @@ org.hibernate hibernate-validator - 5.2.2.Final + {{#jakarta}}8.0.0.Final{{/jakarta}}{{^jakarta}}5.2.2.Final{{/jakarta}} {{/useBeanValidationFeature}} - javax.xml.bind - jaxb-api - 2.2.6 + jakarta.xml.bind + jakarta.xml.bind-api + {{#jakarta}}4.0.0{{/jakarta}}{{^jakarta}}2.3.3{{/jakarta}} - javax.activation - activation - 1.1.1 + com.sun.xml.bind + jaxb-impl + {{#jakarta}}4.0.1{{/jakarta}}{{^jakarta}}2.3.7{{/jakarta}} + + + jakarta.activation + jakarta.activation-api + {{#jakarta}}2.1.0{{/jakarta}}{{^jakarta}}1.2.2{{/jakarta}} @@ -231,7 +236,7 @@ {{#useBeanValidation}} {{#jakarta}}3.0.2{{/jakarta}}{{^jakarta}}2.0.2{{/jakarta}} {{/useBeanValidation}} - 3.2.4 + {{#jakarta}}4.0.0{{/jakarta}}{{^jakarta}}3.2.4.Final{{/jakarta}} 2.9.1 UTF-8 diff --git a/src/main/resources/handlebars/JavaJaxRS/cxf/server/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/cxf/server/pom.mustache index b89cdc7b7d..d72ed47f13 100644 --- a/src/main/resources/handlebars/JavaJaxRS/cxf/server/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/cxf/server/pom.mustache @@ -303,7 +303,7 @@ {{#generateSpringBootApplication}} 1.5.9.RELEASE {{/generateSpringBootApplication}} - 3.2.4 + {{#jakarta}}4.0.0{{/jakarta}}{{^jakarta}}3.2.42.Final{{/jakarta}} 2.9.1 UTF-8 diff --git a/src/main/resources/handlebars/JavaJaxRS/spec/pom.mustache b/src/main/resources/handlebars/JavaJaxRS/spec/pom.mustache index 2a3d8cdfc0..25da51bbe1 100644 --- a/src/main/resources/handlebars/JavaJaxRS/spec/pom.mustache +++ b/src/main/resources/handlebars/JavaJaxRS/spec/pom.mustache @@ -46,7 +46,7 @@ com.sun.xml.ws jaxws-rt - 2.3.3 + {{#jakarta}}4.0.0{{/jakarta}}{{^jakarta}}2.3.3{{/jakarta}} pom diff --git a/src/main/resources/handlebars/JavaSpring/libraries/spring-boot/pom.mustache b/src/main/resources/handlebars/JavaSpring/libraries/spring-boot/pom.mustache index c3c48e39ff..9580ca03cc 100644 --- a/src/main/resources/handlebars/JavaSpring/libraries/spring-boot/pom.mustache +++ b/src/main/resources/handlebars/JavaSpring/libraries/spring-boot/pom.mustache @@ -55,7 +55,7 @@ com.sun.xml.ws jaxws-rt - 2.3.3 + {{#jakarta}}4.0.0{{/jakarta}}{{^jakarta}}2.3.3{{/jakarta}} pom diff --git a/src/test/java/io/swagger/codegen/v3/generators/options/JavaOptionsProvider.java b/src/test/java/io/swagger/codegen/v3/generators/options/JavaOptionsProvider.java index 11d6a31817..94fad80e39 100644 --- a/src/test/java/io/swagger/codegen/v3/generators/options/JavaOptionsProvider.java +++ b/src/test/java/io/swagger/codegen/v3/generators/options/JavaOptionsProvider.java @@ -78,6 +78,7 @@ public JavaOptionsProvider() { .put(CodegenConstants.USE_OAS2, "true") .put(JavaClientCodegen.CHECK_DUPLICATED_MODEL_NAME, "false") .put(JavaClientCodegen.WIREMOCK_OPTION, "false") + .put(JavaClientCodegen.JAKARTA, "false") //.put("supportJava6", "true") .build(); } From 80b17514b7b2cd8fa021579be0cae21530b9be8d Mon Sep 17 00:00:00 2001 From: Fyro Date: Wed, 28 Dec 2022 20:32:22 +0100 Subject: [PATCH 7/8] fix --- .../handlebars/java/JavaHelper.java | 12 ++- .../generators/java/AbstractJavaCodegen.java | 25 +++--- .../java/JavaJAXRSCXFCDIServerCodegen.java | 11 ++- .../JavaSpring/apiController.mustache | 21 +++-- .../java/SpringGeneratorCodegenTest.java | 81 +++++++++++++++++++ 5 files changed, 124 insertions(+), 26 deletions(-) diff --git a/src/main/java/io/swagger/codegen/v3/generators/handlebars/java/JavaHelper.java b/src/main/java/io/swagger/codegen/v3/generators/handlebars/java/JavaHelper.java index 7c6ba8b2a7..554bc96ab3 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/handlebars/java/JavaHelper.java +++ b/src/main/java/io/swagger/codegen/v3/generators/handlebars/java/JavaHelper.java @@ -79,20 +79,26 @@ public CharSequence getModelImports(Map templateData, Options op boolean withXml = Boolean.valueOf(String.valueOf(templateData.get("withXml"))); boolean parcelableModel = Boolean.valueOf(String.valueOf(templateData.get("parcelableModel"))); boolean useBeanValidation = Boolean.valueOf(String.valueOf(templateData.get("useBeanValidation"))); + boolean jakarta = Boolean.valueOf(String.valueOf(templateData.get("jakarta"))); if (serializableMode) { builder.append("import java.io.Serializable;\n"); } if (jackson && withXml) { builder.append("import com.fasterxml.jackson.dataformat.xml.annotation.*;\n"); } - if (withXml) { - builder.append("import javax.xml.bind.annotation.*;\n"); + if (withXml && jakarta) { + builder.append("import jakarta.xml.bind.annotation.*;\n"); + } else if (withXml) { + builder.append("import jakarta.xml.bind.annotation.*;\n"); } if (parcelableModel) { builder.append("import android.os.Parcelable;\n"); builder.append("import android.os.Parcel;\n"); } - if (useBeanValidation) { + if (useBeanValidation && jakarta) { + builder.append("import jakarta.validation.constraints.*;\n"); + builder.append("import jakarta.validation.Valid;\n"); + } else if (useBeanValidation) { builder.append("import javax.validation.constraints.*;\n"); builder.append("import javax.validation.Valid;\n"); } diff --git a/src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaCodegen.java index b73c4af3a3..8bcafb687f 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/java/AbstractJavaCodegen.java @@ -1,5 +1,10 @@ package io.swagger.codegen.v3.generators.java; +import static io.swagger.codegen.v3.CodegenConstants.HAS_ENUMS_EXT_NAME; +import static io.swagger.codegen.v3.CodegenConstants.IS_ENUM_EXT_NAME; +import static io.swagger.codegen.v3.generators.features.NotNullAnnotationFeatures.NOT_NULL_JACKSON_ANNOTATION; +import static io.swagger.codegen.v3.generators.handlebars.ExtensionHelper.getBooleanValue; + import com.github.jknack.handlebars.Handlebars; import io.swagger.codegen.v3.CliOption; import io.swagger.codegen.v3.CodegenArgument; @@ -26,11 +31,6 @@ import io.swagger.v3.oas.models.parameters.RequestBody; import io.swagger.v3.oas.models.responses.ApiResponse; import io.swagger.v3.parser.util.SchemaTypeUtil; -import org.apache.commons.lang3.BooleanUtils; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.File; import java.util.Arrays; import java.util.HashMap; @@ -42,11 +42,10 @@ import java.util.Objects; import java.util.Optional; import java.util.regex.Pattern; - -import static io.swagger.codegen.v3.CodegenConstants.HAS_ENUMS_EXT_NAME; -import static io.swagger.codegen.v3.CodegenConstants.IS_ENUM_EXT_NAME; -import static io.swagger.codegen.v3.generators.features.NotNullAnnotationFeatures.NOT_NULL_JACKSON_ANNOTATION; -import static io.swagger.codegen.v3.generators.handlebars.ExtensionHelper.getBooleanValue; +import org.apache.commons.lang3.BooleanUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public abstract class AbstractJavaCodegen extends DefaultCodegenConfig { private static Logger LOGGER = LoggerFactory.getLogger(AbstractJavaCodegen.class); @@ -503,8 +502,10 @@ public void processOpts() { additionalProperties.put("legacyDates", true); } - setJakarta(Boolean.parseBoolean(String.valueOf(additionalProperties.get(JAKARTA)))); - additionalProperties.put(JAKARTA, jakarta); + if (additionalProperties.containsKey(JAKARTA)) { + setJakarta(Boolean.parseBoolean(String.valueOf(additionalProperties.get(JAKARTA)))); + additionalProperties.put(JAKARTA, jakarta); + } } private void sanitizeConfig() { diff --git a/src/main/java/io/swagger/codegen/v3/generators/java/JavaJAXRSCXFCDIServerCodegen.java b/src/main/java/io/swagger/codegen/v3/generators/java/JavaJAXRSCXFCDIServerCodegen.java index 031bd0e102..3e632ba8e6 100644 --- a/src/main/java/io/swagger/codegen/v3/generators/java/JavaJAXRSCXFCDIServerCodegen.java +++ b/src/main/java/io/swagger/codegen/v3/generators/java/JavaJAXRSCXFCDIServerCodegen.java @@ -5,8 +5,6 @@ import io.swagger.codegen.v3.CodegenProperty; import io.swagger.codegen.v3.SupportingFile; import io.swagger.codegen.v3.generators.features.BeanValidationFeatures; -import org.apache.commons.lang3.StringUtils; - import java.io.File; /** @@ -48,7 +46,14 @@ public void processOpts() { super.processOpts(); - importMapping.put("Valid", "javax.validation.Valid"); + if (additionalProperties.containsKey(JAKARTA)) { + setJakarta(convertPropertyToBoolean(JAKARTA)); + } + if (jakarta) { + importMapping.put("Valid", "jakarta.validation.Valid"); + } else { + importMapping.put("Valid", "javax.validation.Valid"); + } // Three API templates to support CDI injection apiTemplateFiles.put("apiService.mustache", ".java"); diff --git a/src/main/resources/handlebars/JavaSpring/apiController.mustache b/src/main/resources/handlebars/JavaSpring/apiController.mustache index 4a3c46cbed..0ef9f4f16c 100644 --- a/src/main/resources/handlebars/JavaSpring/apiController.mustache +++ b/src/main/resources/handlebars/JavaSpring/apiController.mustache @@ -41,18 +41,23 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; {{#useBeanValidation}} - {{#jakarta}} - import jakarta.validation.Valid; - import jakarta.validation.constraints.*; - {{/jakarta}} - {{^jakarta}} - import javax.validation.Valid; - import javax.validation.constraints.*; - {{/jakarta}} +{{#jakarta}} +import jakarta.validation.Valid; +import jakarta.validation.constraints.*; +{{/jakarta}} +{{^jakarta}} +import javax.validation.Valid; +import javax.validation.constraints.*; +{{/jakarta}} {{/useBeanValidation}} {{/fullController}} {{^isDelegate}} + {{#jakarta}} +import jakarta.servlet.http.HttpServletRequest; + {{/jakarta}} + {{^jakarta}} import javax.servlet.http.HttpServletRequest; + {{/jakarta}} {{#isJava8or11}} import java.util.Optional; {{/isJava8or11}} diff --git a/src/test/java/io/swagger/codegen/v3/generators/java/SpringGeneratorCodegenTest.java b/src/test/java/io/swagger/codegen/v3/generators/java/SpringGeneratorCodegenTest.java index 4eb132aefe..8ebeb1fc54 100644 --- a/src/test/java/io/swagger/codegen/v3/generators/java/SpringGeneratorCodegenTest.java +++ b/src/test/java/io/swagger/codegen/v3/generators/java/SpringGeneratorCodegenTest.java @@ -1,5 +1,7 @@ package io.swagger.codegen.v3.generators.java; +import static io.swagger.codegen.v3.generators.java.AbstractJavaCodegen.JAKARTA; + import io.swagger.codegen.v3.ClientOptInput; import io.swagger.codegen.v3.CodegenArgument; import io.swagger.codegen.v3.CodegenConstants; @@ -41,6 +43,12 @@ public void testParameterOrdersUseOas2() throws Exception { Assert.assertTrue(content.contains("ResponseEntity updateTest(@ApiParam(value = \"description\", required=true) @PathVariable(\"id\") Long id")); Assert.assertTrue(content.contains("@ApiParam(value = \"Localized Text object containing updated data.\", required=true ) @Valid @RequestBody LocalizedText body")); + final File adminApiControllerFile = new File(output, "/src/main/java/io/swagger/api/AdminApiController.java"); + final String contentAdminApiController = FileUtils.readFileToString(adminApiControllerFile); + + Assert.assertFalse(contentAdminApiController.contains("jakarta")); + Assert.assertTrue(contentAdminApiController.contains("javax")); + folder.delete(); } @@ -64,6 +72,79 @@ public void testParameterOrdersUseOas3() throws Exception { Assert.assertTrue(content.contains("ResponseEntity updateTest(@Parameter(in = ParameterIn.PATH, description = \"description\", required=true, schema=@Schema()) @PathVariable(\"id\") Long id")); Assert.assertTrue(content.contains("@Parameter(in = ParameterIn.DEFAULT, description = \"Localized Text object containing updated data.\", required=true, schema=@Schema()) @Valid @RequestBody LocalizedText body")); + final File adminApiControllerFile = new File(output, "/src/main/java/io/swagger/api/AdminApiController.java"); + final String contentAdminApiController = FileUtils.readFileToString(adminApiControllerFile); + + Assert.assertFalse(contentAdminApiController.contains("jakarta")); + Assert.assertTrue(contentAdminApiController.contains("javax")); + + folder.delete(); + } + + @Test(description = "verify oas2 & jakarta") + public void testOas2AndJakarta() throws Exception { + final TemporaryFolder folder = new TemporaryFolder(); + folder.create(); + final File output = folder.getRoot(); + + final CodegenConfigurator configurator = new CodegenConfigurator() + .setLang("spring") + .setInputSpecURL("src/test/resources/3_0_0/parameterOrder.yaml") + .setOutputDir(output.getAbsolutePath()) + .addAdditionalProperty(JAKARTA, true); + + configurator.setCodegenArguments(Collections.singletonList( + new CodegenArgument() + .option(CodegenConstants.USE_OAS2_OPTION) + .type("boolean") + .value(Boolean.TRUE.toString()))); + + final ClientOptInput clientOptInput = configurator.toClientOptInput(); + new DefaultGenerator().opts(clientOptInput).generate(); + + final File adminApiFile = new File(output, "/src/main/java/io/swagger/api/AdminApi.java"); + final String contentAdminApi = FileUtils.readFileToString(adminApiFile); + + Assert.assertTrue(contentAdminApi.contains("ResponseEntity updateTest(@ApiParam(value = \"description\", required=true) @PathVariable(\"id\") Long id")); + Assert.assertTrue(contentAdminApi.contains("@ApiParam(value = \"Localized Text object containing updated data.\", required=true ) @Valid @RequestBody LocalizedText body")); + + final File adminApiControllerFile = new File(output, "/src/main/java/io/swagger/api/AdminApiController.java"); + final String contentAdminApiController = FileUtils.readFileToString(adminApiControllerFile); + + Assert.assertTrue(contentAdminApiController.contains("jakarta")); + Assert.assertFalse(contentAdminApiController.contains("javax")); + + folder.delete(); + } + + @Test(description = "verify oas3 & jakarta") + public void testUseOas3AndJakarta() throws Exception { + final TemporaryFolder folder = new TemporaryFolder(); + folder.create(); + final File output = folder.getRoot(); + + final CodegenConfigurator configurator = new CodegenConfigurator() + .setLang("spring") + .setInputSpecURL("src/test/resources/3_0_0/parameterOrder.yaml") + .setOutputDir(output.getAbsolutePath()) + .addAdditionalProperty(JAKARTA, true); + + final ClientOptInput clientOptInput = configurator.toClientOptInput(); + new DefaultGenerator().opts(clientOptInput).generate(); + + final File adminApiFile = new File(output, "/src/main/java/io/swagger/api/AdminApi.java"); + final String contentAdminApi = FileUtils.readFileToString(adminApiFile); + + Assert.assertTrue(contentAdminApi.contains("ResponseEntity updateTest(@Parameter(in = ParameterIn.PATH, description = \"description\", required=true, schema=@Schema()) @PathVariable(\"id\") Long id")); + Assert.assertTrue(contentAdminApi.contains("@Parameter(in = ParameterIn.DEFAULT, description = \"Localized Text object containing updated data.\", required=true, schema=@Schema()) @Valid @RequestBody LocalizedText body")); + + + final File adminApiControllerFile = new File(output, "/src/main/java/io/swagger/api/AdminApiController.java"); + final String contentAdminApiController = FileUtils.readFileToString(adminApiControllerFile); + + Assert.assertTrue(contentAdminApiController.contains("jakarta")); + Assert.assertFalse(contentAdminApiController.contains("javax")); + folder.delete(); } From f26d736de96b5831a5b80cb538374a274fd2e27d Mon Sep 17 00:00:00 2001 From: Fyro Date: Wed, 28 Dec 2022 20:37:20 +0100 Subject: [PATCH 8/8] fix --- .../resources/handlebars/JavaSpring/apiDelegate.mustache | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/resources/handlebars/JavaSpring/apiDelegate.mustache b/src/main/resources/handlebars/JavaSpring/apiDelegate.mustache index 6c752ac7d1..3654d6ee78 100644 --- a/src/main/resources/handlebars/JavaSpring/apiDelegate.mustache +++ b/src/main/resources/handlebars/JavaSpring/apiDelegate.mustache @@ -30,7 +30,12 @@ import java.io.IOException; {{/isJava8or11}} {{#isJava8or11}} +{{#jakarta}} +import jakarta.servlet.http.HttpServletRequest; +{{/jakarta}} +{{^jakarta}} import javax.servlet.http.HttpServletRequest; +{{/jakarta}} {{/isJava8or11}} import java.util.List; import java.util.Map;