Skip to content

Commit 07647b1

Browse files
authored
[Java] Decommission Retrofit 1.x support (#6447)
* decommission retrofit 1.x support * remove retrofit 1.x from pom.xml
1 parent 34ccec8 commit 07647b1

File tree

141 files changed

+12
-17745
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+12
-17745
lines changed

bin/java-petstore-all.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
./bin/java-petstore-resteasy.sh
1515
./bin/java-petstore-resttemplate-withxml.sh
1616
./bin/java-petstore-resttemplate.sh
17-
./bin/java-petstore-retrofit.sh
1817
./bin/java-petstore-retrofit2-play24.sh
1918
./bin/java-petstore-retrofit2-play25.sh
2019
./bin/java-petstore-retrofit2-play26.sh

bin/java-petstore-retrofit.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

bin/java-petstore-retrofit.sh

Lines changed: 0 additions & 35 deletions
This file was deleted.

bin/windows/java-petstore-all.bat

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ call .\bin\windows\java-petstore-rest-assured-jackson.bat
1010
call .\bin\windows\java-petstore-resteasy.bat
1111
call .\bin\windows\java-petstore-resttemplate-withxml.bat
1212
call .\bin\windows\java-petstore-resttemplate.bat
13-
call .\bin\windows\java-petstore-retrofit.bat
1413
call .\bin\windows\java-petstore-retrofit2-play24.bat
1514
call .\bin\windows\java-petstore-retrofit2-play25.bat
1615
call .\bin\windows\java-petstore-retrofit2-play26.bat

bin/windows/java-petstore-retrofit.bat

Lines changed: 0 additions & 10 deletions
This file was deleted.

docs/generators/java.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ sidebar_label: java
3131
|invokerPackage|root package for generated code| |org.openapitools.client|
3232
|java8|Use Java8 classes instead of third party equivalents. Starting in 5.x, JDK8 is the default and the support for JDK7, JDK6 has been dropped|<dl><dt>**true**</dt><dd>Use Java 8 classes such as Base64</dd><dt>**false**</dt><dd>Various third party libraries as needed</dd></dl>|true|
3333
|legacyDiscriminatorBehavior|This flag is used by OpenAPITools codegen to influence the processing of the discriminator attribute in OpenAPI documents. This flag has no impact if the OAS document does not use the discriminator attribute. The default value of this flag is set in each language-specific code generator (e.g. Python, Java, go...)using the method toModelName. Note to developers supporting a language generator in OpenAPITools; to fully support the discriminator attribute as defined in the OAS specification 3.x, language generators should set this flag to true by default; however this requires updating the mustache templates to generate a language-specific discriminator lookup function that iterates over {{#mappedModels}} and does not iterate over {{children}}, {{#anyOf}}, or {{#oneOf}}.|<dl><dt>**true**</dt><dd>The mapping in the discriminator includes descendent schemas that allOf inherit from self and the discriminator mapping schemas in the OAS document.</dd><dt>**false**</dt><dd>The mapping in the discriminator includes any descendent schemas that allOf inherit from self, any oneOf schemas, any anyOf schemas, any x-discriminator-values, and the discriminator mapping schemas in the OAS document AND Codegen validates that oneOf and anyOf schemas contain the required discriminator and throws an error if the discriminator is missing.</dd></dl>|true|
34-
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 9.x (deprecated) or 10.x (default). JSON processing: Jackson 2.9.x.</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit**</dt><dd>HTTP client: OkHttp 2.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.10.x. Only for Java 8</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+</dd><dt>**microprofile**</dt><dd>HTTP client: Microprofile client X.x. JSON processing: Jackson 2.9.x</dd></dl>|okhttp-gson|
34+
|library|library template (sub-template) to use|<dl><dt>**jersey1**</dt><dd>HTTP client: Jersey client 1.19.x. JSON processing: Jackson 2.9.x. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'. IMPORTANT NOTE: jersey 1.x is no longer actively maintained so please upgrade to 'jersey2' or other HTTP libaries instead.</dd><dt>**jersey2**</dt><dd>HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x</dd><dt>**feign**</dt><dd>HTTP client: OpenFeign 9.x (deprecated) or 10.x (default). JSON processing: Jackson 2.9.x.</dd><dt>**okhttp-gson**</dt><dd>[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.</dd><dt>**retrofit2**</dt><dd>HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)</dd><dt>**resttemplate**</dt><dd>HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x</dd><dt>**webclient**</dt><dd>HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x</dd><dt>**resteasy**</dt><dd>HTTP client: Resteasy client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**vertx**</dt><dd>HTTP client: VertX client 3.x. JSON processing: Jackson 2.9.x</dd><dt>**google-api-client**</dt><dd>HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x</dd><dt>**rest-assured**</dt><dd>HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.10.x. Only for Java 8</dd><dt>**native**</dt><dd>HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+</dd><dt>**microprofile**</dt><dd>HTTP client: Microprofile client 1.x. JSON processing: Jackson 2.9.x</dd></dl>|okhttp-gson|
3535
|licenseName|The name of the license| |Unlicense|
3636
|licenseUrl|The URL of the license| |http://unlicense.org|
3737
|modelPackage|package for generated models| |org.openapitools.client.model|

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
7878
public static final String RESTTEMPLATE = "resttemplate";
7979
public static final String WEBCLIENT = "webclient";
8080
public static final String REST_ASSURED = "rest-assured";
81-
public static final String RETROFIT_1 = "retrofit";
8281
public static final String RETROFIT_2 = "retrofit2";
8382
public static final String VERTX = "vertx";
8483
public static final String MICROPROFILE = "microprofile";
@@ -149,7 +148,6 @@ public JavaClientCodegen() {
149148
supportedLibraries.put(JERSEY2, "HTTP client: Jersey client 2.25.1. JSON processing: Jackson 2.9.x");
150149
supportedLibraries.put(FEIGN, "HTTP client: OpenFeign 9.x (deprecated) or 10.x (default). JSON processing: Jackson 2.9.x.");
151150
supportedLibraries.put(OKHTTP_GSON, "[DEFAULT] HTTP client: OkHttp 3.x. JSON processing: Gson 2.8.x. Enable Parcelable models on Android using '-DparcelableModel=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.");
152-
supportedLibraries.put(RETROFIT_1, "HTTP client: OkHttp 2.x. JSON processing: Gson 2.x (Retrofit 1.9.0). IMPORTANT NOTE: retrofit1.x is no longer actively maintained so please upgrade to 'retrofit2' instead.");
153151
supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 3.x. JSON processing: Gson 2.x (Retrofit 2.3.0). Enable the RxJava adapter using '-DuseRxJava[2]=true'. (RxJava 1.x or 2.x)");
154152
supportedLibraries.put(RESTTEMPLATE, "HTTP client: Spring RestTemplate 4.x. JSON processing: Jackson 2.9.x");
155153
supportedLibraries.put(WEBCLIENT, "HTTP client: Spring WebClient 5.x. JSON processing: Jackson 2.9.x");
@@ -158,7 +156,7 @@ public JavaClientCodegen() {
158156
supportedLibraries.put(GOOGLE_API_CLIENT, "HTTP client: Google API client 1.x. JSON processing: Jackson 2.9.x");
159157
supportedLibraries.put(REST_ASSURED, "HTTP client: rest-assured : 4.x. JSON processing: Gson 2.x or Jackson 2.10.x. Only for Java 8");
160158
supportedLibraries.put(NATIVE, "HTTP client: Java native HttpClient. JSON processing: Jackson 2.9.x. Only for Java11+");
161-
supportedLibraries.put(MICROPROFILE, "HTTP client: Microprofile client X.x. JSON processing: Jackson 2.9.x");
159+
supportedLibraries.put(MICROPROFILE, "HTTP client: Microprofile client 1.x. JSON processing: Jackson 2.9.x");
162160

163161
CliOption libraryOption = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
164162
libraryOption.setEnum(supportedLibraries);
@@ -192,7 +190,7 @@ public String getName() {
192190

193191
@Override
194192
public String getHelp() {
195-
return "Generates a Java client library (HTTP lib: Jersey (1.x, 2.x), Retrofit (1.x, 2.x), OpenFeign (9.x, 10.x) and more.";
193+
return "Generates a Java client library (HTTP lib: Jersey (1.x, 2.x), Retrofit (2.x), OpenFeign (10.x) and more.";
196194
}
197195

198196
@Override
@@ -325,19 +323,19 @@ public void processOpts() {
325323
setSerializationLibrary(additionalProperties.get(CodegenConstants.SERIALIZATION_LIBRARY).toString());
326324
}
327325

328-
//TODO: add doc to retrofit1 and feign
329-
if (FEIGN.equals(getLibrary()) || RETROFIT_1.equals(getLibrary())) {
326+
//TODO: add auto-generated doc to feign
327+
if (FEIGN.equals(getLibrary())) {
330328
modelDocTemplateFiles.remove("model_doc.mustache");
331329
apiDocTemplateFiles.remove("api_doc.mustache");
332330
}
333331

334-
if (!(FEIGN.equals(getLibrary()) || RESTTEMPLATE.equals(getLibrary()) || usesAnyRetrofitLibrary() || GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()) || WEBCLIENT.equals(getLibrary()) || MICROPROFILE.equals(getLibrary()))) {
332+
if (!(FEIGN.equals(getLibrary()) || RESTTEMPLATE.equals(getLibrary()) || RETROFIT_2.equals(getLibrary()) || GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()) || WEBCLIENT.equals(getLibrary()) || MICROPROFILE.equals(getLibrary()))) {
335333
supportingFiles.add(new SupportingFile("apiException.mustache", invokerFolder, "ApiException.java"));
336334
supportingFiles.add(new SupportingFile("Configuration.mustache", invokerFolder, "Configuration.java"));
337335
supportingFiles.add(new SupportingFile("Pair.mustache", invokerFolder, "Pair.java"));
338336
}
339337

340-
if (!(FEIGN.equals(getLibrary()) || RESTTEMPLATE.equals(getLibrary()) || usesAnyRetrofitLibrary() || GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()) || NATIVE.equals(getLibrary()) || MICROPROFILE.equals(getLibrary()))) {
338+
if (!(FEIGN.equals(getLibrary()) || RESTTEMPLATE.equals(getLibrary()) || RETROFIT_2.equals(getLibrary()) || GOOGLE_API_CLIENT.equals(getLibrary()) || REST_ASSURED.equals(getLibrary()) || NATIVE.equals(getLibrary()) || MICROPROFILE.equals(getLibrary()))) {
341339
supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java"));
342340
}
343341

@@ -358,11 +356,11 @@ public void processOpts() {
358356
//supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient.mustache", authFolder, "OAuthOkHttpClient.java"));
359357
//supportingFiles.add(new SupportingFile("auth/RetryingOAuth.mustache", authFolder, "RetryingOAuth.java"));
360358
forceSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
361-
} else if (usesAnyRetrofitLibrary()) {
359+
} else if (RETROFIT_2.equals(getLibrary())) {
362360
supportingFiles.add(new SupportingFile("auth/OAuthOkHttpClient.mustache", authFolder, "OAuthOkHttpClient.java"));
363361
supportingFiles.add(new SupportingFile("CollectionFormats.mustache", invokerFolder, "CollectionFormats.java"));
364362
forceSerializationLibrary(SERIALIZATION_LIBRARY_GSON);
365-
if ("retrofit2".equals(getLibrary()) && !usePlayWS) {
363+
if (RETROFIT_2.equals(getLibrary()) && !usePlayWS) {
366364
supportingFiles.add(new SupportingFile("JSON.mustache", invokerFolder, "JSON.java"));
367365
}
368366
} else if (JERSEY2.equals(getLibrary())) {
@@ -519,19 +517,11 @@ public void processOpts() {
519517
}
520518
}
521519

522-
private boolean usesAnyRetrofitLibrary() {
523-
return getLibrary() != null && getLibrary().contains(RETROFIT_1);
524-
}
525-
526-
private boolean usesRetrofit2Library() {
527-
return getLibrary() != null && getLibrary().contains(RETROFIT_2);
528-
}
529-
530520
@SuppressWarnings("unchecked")
531521
@Override
532522
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
533523
super.postProcessOperationsWithModels(objs, allModels);
534-
if (usesAnyRetrofitLibrary()) {
524+
if (RETROFIT_2.equals(getLibrary())) {
535525
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
536526
if (operations != null) {
537527
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
@@ -544,7 +534,8 @@ public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> o
544534
operation.prioritizedContentTypes = prioritizeContentTypes(operation.consumes);
545535
}
546536
}
547-
if (usesRetrofit2Library() && StringUtils.isNotEmpty(operation.path) && operation.path.startsWith("/")) {
537+
538+
if (StringUtils.isNotEmpty(operation.path) && operation.path.startsWith("/")) {
548539
operation.path = operation.path.substring(1);
549540
}
550541

pom.xml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -727,18 +727,6 @@
727727
<module>samples/client/petstore/java/okhttp-gson-parcelableModel</module>
728728
</modules>
729729
</profile>
730-
<profile>
731-
<id>java-client-retrofit</id>
732-
<activation>
733-
<property>
734-
<name>env</name>
735-
<value>java</value>
736-
</property>
737-
</activation>
738-
<modules>
739-
<module>samples/client/petstore/java/retrofit</module>
740-
</modules>
741-
</profile>
742730
<profile>
743731
<id>java-client-retrofit2</id>
744732
<activation>
@@ -1265,7 +1253,6 @@
12651253
<module>samples/client/petstore/java/jersey1</module>
12661254
<module>samples/client/petstore/java/jersey2-java8</module>
12671255
<module>samples/client/petstore/java/okhttp-gson</module>
1268-
<module>samples/client/petstore/java/retrofit</module>
12691256
<module>samples/client/petstore/java/retrofit2</module>
12701257
<module>samples/client/petstore/java/retrofit2rx</module>
12711258
<module>samples/client/petstore/java/retrofit2-play25</module>
@@ -1356,7 +1343,6 @@
13561343
<module>samples/client/petstore/scala-httpclient</module>
13571344
<module>samples/client/petstore/java/jersey1</module>
13581345
<module>samples/client/petstore/java/okhttp-gson</module>
1359-
<module>samples/client/petstore/java/retrofit</module>
13601346
<module>samples/client/petstore/java/retrofit2</module>
13611347
<module>samples/client/petstore/java/retrofit2rx</module>
13621348
<module>samples/client/petstore/jaxrs-cxf-client</module>

samples/client/petstore/java/retrofit/.gitignore

Lines changed: 0 additions & 21 deletions
This file was deleted.

samples/client/petstore/java/retrofit/.openapi-generator-ignore

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)