-
-
Notifications
You must be signed in to change notification settings - Fork 7k
[Java][Vertx] Add option to generate methods that return Futures #21083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Example of output package org.openapitools.client.api;
import org.openapitools.client.ApiClient;
import org.openapitools.client.model.Order;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
import io.vertx.core.Future;
import io.vertx.core.Promise;
import io.vertx.core.json.JsonObject;
import java.util.*;
public interface StoreApi {
void deleteOrder(@javax.annotation.Nonnull String orderId, Handler<AsyncResult<Void>> handler);
default Future<Void> deleteOrder(@javax.annotation.Nonnull String orderId){
Promise<Void> promise = Promise.promise();
deleteOrder(orderId, promise);
return promise.future();
}
void deleteOrder(@javax.annotation.Nonnull String orderId, ApiClient.AuthInfo authInfo, Handler<AsyncResult<Void>> handler);
default Future<Void> deleteOrder(@javax.annotation.Nonnull String orderId, ApiClient.AuthInfo authInfo){
Promise<Void> promise = Promise.promise();
deleteOrder(orderId, authInfo, promise);
return promise.future();
}
void getInventory(Handler<AsyncResult<Map<String, Integer>>> handler);
default Future<Map<String, Integer>> getInventory(){
Promise<Map<String, Integer>> promise = Promise.promise();
getInventory(promise);
return promise.future();
}
void getInventory(ApiClient.AuthInfo authInfo, Handler<AsyncResult<Map<String, Integer>>> handler);
default Future<Map<String, Integer>> getInventory(ApiClient.AuthInfo authInfo){
Promise<Map<String, Integer>> promise = Promise.promise();
getInventory(authInfo, promise);
return promise.future();
}
void getOrderById(@javax.annotation.Nonnull Long orderId, Handler<AsyncResult<Order>> handler);
default Future<Order> getOrderById(@javax.annotation.Nonnull Long orderId){
Promise<Order> promise = Promise.promise();
getOrderById(orderId, promise);
return promise.future();
}
void getOrderById(@javax.annotation.Nonnull Long orderId, ApiClient.AuthInfo authInfo, Handler<AsyncResult<Order>> handler);
default Future<Order> getOrderById(@javax.annotation.Nonnull Long orderId, ApiClient.AuthInfo authInfo){
Promise<Order> promise = Promise.promise();
getOrderById(orderId, authInfo, promise);
return promise.future();
}
void placeOrder(@javax.annotation.Nonnull Order order, Handler<AsyncResult<Order>> handler);
default Future<Order> placeOrder(@javax.annotation.Nonnull Order order){
Promise<Order> promise = Promise.promise();
placeOrder(order, promise);
return promise.future();
}
void placeOrder(@javax.annotation.Nonnull Order order, ApiClient.AuthInfo authInfo, Handler<AsyncResult<Order>> handler);
default Future<Order> placeOrder(@javax.annotation.Nonnull Order order, ApiClient.AuthInfo authInfo){
Promise<Order> promise = Promise.promise();
placeOrder(order, authInfo, promise);
return promise.future();
}
} |
thanks for the PR can you please add a new config file under ./bin/config with the option enabled, generate the samples, commit the new files and update github workflow to test the output? #21007 is a good reference PR, which has been recently merged doing the above. |
While updating the github workflow, I noticed that |
don't think. likely it's missed please kindly add it as part of this pr when you've time |
please run the command twice to update the samples |
Wouldn't it make more sense to add it in a separate PR? Fixing the missing EDIT: never mind, I incorrectly thought that files were generated by the workflow. |
ci failure not related to this change |
Closes #21068
Added
supportVertxFuture
option to the java generator.Promise
, calls the old method with that promise as the callback, then returns thepromise.future
.PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master
(upcoming7.x.0
minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)@bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @martin-mfg (2023/08)