Skip to content

Commit 136410e

Browse files
committed
wrap promise
1 parent 38eee55 commit 136410e

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

  • modules/openapi-generator/src/main/resources/Java/libraries/vertx

modules/openapi-generator/src/main/resources/Java/libraries/vertx/api.mustache

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public interface {{classname}} {
2828
{{/isDeprecated}}
2929
default Future<{{{returnType}}}{{^returnType}}Void{{/returnType}}> {{operationId}}({{#allParams}}{{>nullable_var_annotations}} {{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}){
3030
Promise<{{{returnType}}}{{^returnType}}Void{{/returnType}}> promise = Promise.promise();
31-
{{operationId}}({{#allParams}}{{paramName}}, {{/allParams}}promise);
31+
{{operationId}}({{#allParams}}{{paramName}}, {{/allParams}}wrapPromise(promise));
3232
return promise.future();
3333
}
3434

@@ -44,11 +44,22 @@ public interface {{classname}} {
4444
{{/isDeprecated}}
4545
default Future<{{{returnType}}}{{^returnType}}Void{{/returnType}}> {{operationId}}({{#allParams}}{{>nullable_var_annotations}} {{{dataType}}} {{paramName}}, {{/allParams}}ApiClient.AuthInfo authInfo){
4646
Promise<{{{returnType}}}{{^returnType}}Void{{/returnType}}> promise = Promise.promise();
47-
{{operationId}}({{#allParams}}{{paramName}}, {{/allParams}}authInfo, promise);
47+
{{operationId}}({{#allParams}}{{paramName}}, {{/allParams}}authInfo, wrapPromise(promise));
4848
return promise.future();
4949
}
5050

5151
{{/supportVertxFuture}}
5252
{{/operation}}
5353
{{/operations}}
54+
{{#supportVertxFuture}}
55+
static <T> Handler<AsyncResult<T>> wrapPromise(Promise<T> promise){
56+
return result -> {
57+
if (result.succeeded()) {
58+
promise.complete(result.result());
59+
} else {
60+
promise.fail(result.cause());
61+
}
62+
};
63+
}
64+
{{/supportVertxFuture}}
5465
}

0 commit comments

Comments
 (0)