Skip to content

Commit

Permalink
Use Rx2 Completalbe for Void Retrofit2 responses
Browse files Browse the repository at this point in the history
  • Loading branch information
wingsofovnia committed Jan 13, 2018
1 parent 7cc738a commit 642c056
Show file tree
Hide file tree
Showing 49 changed files with 302 additions and 356 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void processOpts() {
this.setUsePlayWS(Boolean.valueOf(additionalProperties.get(USE_PLAY_WS).toString()));
}
additionalProperties.put(USE_PLAY_WS, usePlayWS);

if (additionalProperties.containsKey(PLAY_VERSION)) {
this.setPlayVersion(additionalProperties.get(PLAY_VERSION).toString());
}
Expand Down Expand Up @@ -251,7 +251,7 @@ public void processOpts() {
}

if (usePlayWS) {
// remove unsupported auth
// remove unsupported auth
Iterator<SupportingFile> iter = supportingFiles.iterator();
while (iter.hasNext()) {
SupportingFile sf = iter.next();
Expand All @@ -261,19 +261,19 @@ public void processOpts() {
}

apiTemplateFiles.remove("api.mustache");

if (PLAY_24.equals(playVersion)) {
additionalProperties.put(PLAY_24, true);
apiTemplateFiles.put("play24/api.mustache", ".java");

supportingFiles.add(new SupportingFile("play24/ApiClient.mustache", invokerFolder, "ApiClient.java"));
supportingFiles.add(new SupportingFile("play24/Play24CallFactory.mustache", invokerFolder, "Play24CallFactory.java"));
supportingFiles.add(new SupportingFile("play24/Play24CallAdapterFactory.mustache", invokerFolder,
"Play24CallAdapterFactory.java"));
} else {
additionalProperties.put(PLAY_25, true);
apiTemplateFiles.put("play25/api.mustache", ".java");

supportingFiles.add(new SupportingFile("play25/ApiClient.mustache", invokerFolder, "ApiClient.java"));
supportingFiles.add(new SupportingFile("play25/Play25CallFactory.mustache", invokerFolder, "Play25CallFactory.java"));
supportingFiles.add(new SupportingFile("play25/Play25CallAdapterFactory.mustache", invokerFolder,
Expand All @@ -284,7 +284,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("play-common/auth/ApiKeyAuth.mustache", authFolder, "ApiKeyAuth.java"));
supportingFiles.add(new SupportingFile("auth/Authentication.mustache", authFolder, "Authentication.java"));
supportingFiles.add(new SupportingFile("Pair.mustache", invokerFolder, "Pair.java"));

additionalProperties.put("jackson", "true");
additionalProperties.remove("gson");
}
Expand Down Expand Up @@ -323,9 +323,6 @@ public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
operation.prioritizedContentTypes = prioritizeContentTypes(operation.consumes);
}
}
if (operation.returnType == null) {
operation.returnType = "Void";
}
if (usesRetrofit2Library() && StringUtils.isNotEmpty(operation.path) && operation.path.startsWith("/")){
operation.path = operation.path.substring(1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ public interface {{classname}} {
{{#allParams}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
{{/allParams}}
{{#returnType}}
* @return {{returnType}}
{{/returnType}}
* @return {{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}
{{#externalDocs}}
* {{description}}
* @see <a href="{{url}}">{{summary}} Documentation</a>
Expand All @@ -37,7 +35,7 @@ public interface {{classname}} {
{{#formParams}}{{#-first}}
{{#isMultipart}}@retrofit.http.Multipart{{/isMultipart}}{{^isMultipart}}@retrofit.http.FormUrlEncoded{{/isMultipart}}{{/-first}}{{/formParams}}
@{{httpMethod}}("{{{path}}}")
{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}} {{operationId}}({{^allParams}});{{/allParams}}
{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}} {{operationId}}({{^allParams}});{{/allParams}}
{{#allParams}}{{>libraries/retrofit/queryParams}}{{>libraries/retrofit/pathParams}}{{>libraries/retrofit/headerParams}}{{>libraries/retrofit/bodyParams}}{{>libraries/retrofit/formParams}}{{#hasMore}}, {{/hasMore}}{{^hasMore}}
);{{/hasMore}}{{/allParams}}

Expand All @@ -57,7 +55,7 @@ public interface {{classname}} {
{{#isMultipart}}@retrofit.http.Multipart{{/isMultipart}}{{^isMultipart}}@retrofit.http.FormUrlEncoded{{/isMultipart}}{{/-first}}{{/formParams}}
@{{httpMethod}}("{{{path}}}")
void {{operationId}}(
{{#allParams}}{{>libraries/retrofit/queryParams}}{{>libraries/retrofit/pathParams}}{{>libraries/retrofit/headerParams}}{{>libraries/retrofit/bodyParams}}{{>libraries/retrofit/formParams}}, {{/allParams}}Callback<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}> cb
{{#allParams}}{{>libraries/retrofit/queryParams}}{{>libraries/retrofit/pathParams}}{{>libraries/retrofit/headerParams}}{{>libraries/retrofit/bodyParams}}{{>libraries/retrofit/formParams}}, {{/allParams}}Callback<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> cb
);
{{/operation}}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import rx.Observable;
{{#useRxJava2}}
import io.reactivex.Observable;
{{/useRxJava2}}
{{^returnType}}
{{#useRxJava2}}
import io.reactivex.Completable;
{{/useRxJava2}}
{{/returnType}}
{{#doNotUseRx}}
import retrofit2.Call;
{{/doNotUseRx}}
Expand Down Expand Up @@ -35,7 +40,7 @@ public interface {{classname}} {
{{#allParams}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
{{/allParams}}
* @return Call&lt;{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Object{{/returnType}}&gt;
* @return {{^doNotUseRx}}{{#useRxJava}}Observable&lt;{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}{{/isResponseFile}}&gt;{{/useRxJava}}{{#useRxJava2}}{{#returnType}}Observable&lt;{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{returnType}}{{/isResponseFile}}&gt;{{/returnType}}{{^returnType}}Completable{{/returnType}}{{/useRxJava2}}{{/doNotUseRx}}{{#doNotUseRx}}Call&lt;{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}{{/isResponseFile}}&gt;{{/doNotUseRx}}
{{#externalDocs}}
* {{description}}
* @see <a href="{{url}}">{{summary}} Documentation</a>
Expand All @@ -54,9 +59,9 @@ public interface {{classname}} {
})
{{/-first}}
{{/prioritizedContentTypes}}
{{/formParams}}
{{/formParams}}
@{{httpMethod}}("{{{path}}}")
{{^doNotUseRx}}Observable{{/doNotUseRx}}{{#doNotUseRx}}Call{{/doNotUseRx}}<{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}{{/isResponseFile}}> {{operationId}}({{^allParams}});{{/allParams}}
{{^doNotUseRx}}{{#useRxJava}}Observable<{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}{{/isResponseFile}}>{{/useRxJava}}{{#useRxJava2}}{{#returnType}}Observable<{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}>{{/returnType}}{{^returnType}}Completable{{/returnType}}{{/useRxJava2}}{{/doNotUseRx}}{{#doNotUseRx}}Call<{{#isResponseFile}}ResponseBody{{/isResponseFile}}{{^isResponseFile}}{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}{{/isResponseFile}}>{{/doNotUseRx}} {{operationId}}({{^allParams}});{{/allParams}}
{{#allParams}}{{>libraries/retrofit2/queryParams}}{{>libraries/retrofit2/pathParams}}{{>libraries/retrofit2/headerParams}}{{>libraries/retrofit2/bodyParams}}{{>libraries/retrofit2/formParams}}{{#hasMore}}, {{/hasMore}}{{^hasMore}}
);{{/hasMore}}{{/allParams}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public interface {{classname}} {
{{#allParams}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
{{/allParams}}
* @return Call&lt;{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Object{{/returnType}}&gt;
* @return Call&lt;{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}&gt;
*/
{{#formParams}}
{{#-first}}
Expand All @@ -46,9 +46,9 @@ public interface {{classname}} {
})
{{/-first}}
{{/prioritizedContentTypes}}
{{/formParams}}
{{/formParams}}
@{{httpMethod}}("{{{path}}}")
F.Promise<Response<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>> {{operationId}}({{^allParams}});{{/allParams}}
F.Promise<Response<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>> {{operationId}}({{^allParams}});{{/allParams}}
{{#allParams}}{{>libraries/retrofit2/queryParams}}{{>libraries/retrofit2/pathParams}}{{>libraries/retrofit2/headerParams}}{{>libraries/retrofit2/bodyParams}}{{>libraries/retrofit2/formParams}}{{#hasMore}}, {{/hasMore}}{{^hasMore}}
);{{/hasMore}}{{/allParams}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public interface {{classname}} {
{{#allParams}}
* @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
{{/allParams}}
* @return Call&lt;{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Object{{/returnType}}&gt;
* @return Call&lt;{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Void{{/returnType}}&gt;
*/
{{#formParams}}
{{#-first}}
Expand All @@ -46,9 +46,9 @@ public interface {{classname}} {
})
{{/-first}}
{{/prioritizedContentTypes}}
{{/formParams}}
{{/formParams}}
@{{httpMethod}}("{{{path}}}")
CompletionStage<Response<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>> {{operationId}}({{^allParams}});{{/allParams}}
CompletionStage<Response<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>> {{operationId}}({{^allParams}});{{/allParams}}
{{#allParams}}{{>libraries/retrofit2/queryParams}}{{>libraries/retrofit2/pathParams}}{{>libraries/retrofit2/headerParams}}{{>libraries/retrofit2/bodyParams}}{{>libraries/retrofit2/formParams}}{{#hasMore}}, {{/hasMore}}{{^hasMore}}
);{{/hasMore}}{{/allParams}}

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.0-SNAPSHOT
2.3.1-SNAPSHOT
28 changes: 12 additions & 16 deletions samples/client/petstore/java/retrofit2-play24/docs/FakeApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ No authorization required

<a name="testEndpointParameters"></a>
# **testEndpointParameters**
> Void testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback)
> testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback)
Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트

Expand Down Expand Up @@ -280,8 +280,7 @@ OffsetDateTime dateTime = new OffsetDateTime(); // OffsetDateTime | None
String password = "password_example"; // String | None
String paramCallback = "paramCallback_example"; // String | None
try {
Void result = apiInstance.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);
System.out.println(result);
apiInstance.testEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, string, binary, date, dateTime, password, paramCallback);
} catch (ApiException e) {
System.err.println("Exception when calling FakeApi#testEndpointParameters");
e.printStackTrace();
Expand Down Expand Up @@ -309,7 +308,7 @@ Name | Type | Description | Notes

### Return type

[**Void**](.md)
null (empty response body)

### Authorization

Expand All @@ -322,7 +321,7 @@ Name | Type | Description | Notes

<a name="testEnumParameters"></a>
# **testEnumParameters**
> Void testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble)
> testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble)
To test enum parameters

Expand All @@ -345,8 +344,7 @@ String enumQueryString = "-efg"; // String | Query parameter enum test (string)
Integer enumQueryInteger = 56; // Integer | Query parameter enum test (double)
Double enumQueryDouble = 3.4D; // Double | Query parameter enum test (double)
try {
Void result = apiInstance.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble);
System.out.println(result);
apiInstance.testEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble);
} catch (ApiException e) {
System.err.println("Exception when calling FakeApi#testEnumParameters");
e.printStackTrace();
Expand All @@ -368,7 +366,7 @@ Name | Type | Description | Notes

### Return type

[**Void**](.md)
null (empty response body)

### Authorization

Expand All @@ -381,7 +379,7 @@ No authorization required

<a name="testInlineAdditionalProperties"></a>
# **testInlineAdditionalProperties**
> Void testInlineAdditionalProperties(param)
> testInlineAdditionalProperties(param)
test inline additionalProperties

Expand All @@ -397,8 +395,7 @@ test inline additionalProperties
FakeApi apiInstance = new FakeApi();
Object param = null; // Object | request body
try {
Void result = apiInstance.testInlineAdditionalProperties(param);
System.out.println(result);
apiInstance.testInlineAdditionalProperties(param);
} catch (ApiException e) {
System.err.println("Exception when calling FakeApi#testInlineAdditionalProperties");
e.printStackTrace();
Expand All @@ -413,7 +410,7 @@ Name | Type | Description | Notes

### Return type

[**Void**](.md)
null (empty response body)

### Authorization

Expand All @@ -426,7 +423,7 @@ No authorization required

<a name="testJsonFormData"></a>
# **testJsonFormData**
> Void testJsonFormData(param, param2)
> testJsonFormData(param, param2)
test json serialization of form data

Expand All @@ -443,8 +440,7 @@ FakeApi apiInstance = new FakeApi();
String param = "param_example"; // String | field1
String param2 = "param2_example"; // String | field2
try {
Void result = apiInstance.testJsonFormData(param, param2);
System.out.println(result);
apiInstance.testJsonFormData(param, param2);
} catch (ApiException e) {
System.err.println("Exception when calling FakeApi#testJsonFormData");
e.printStackTrace();
Expand All @@ -460,7 +456,7 @@ Name | Type | Description | Notes

### Return type

[**Void**](.md)
null (empty response body)

### Authorization

Expand Down
Loading

0 comments on commit 642c056

Please sign in to comment.