diff --git a/modules/swagger-codegen/src/main/resources/JavaVertXServer/MainApiVerticle.mustache b/modules/swagger-codegen/src/main/resources/JavaVertXServer/MainApiVerticle.mustache index 9f834d4e6441..050cb6d57ebe 100644 --- a/modules/swagger-codegen/src/main/resources/JavaVertXServer/MainApiVerticle.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaVertXServer/MainApiVerticle.mustache @@ -19,10 +19,19 @@ import io.vertx.core.Vertx; import io.vertx.ext.web.Router; public class MainApiVerticle extends AbstractVerticle { - final static Logger LOGGER = LoggerFactory.getLogger(MainApiVerticle.class); - + final static Logger LOGGER = LoggerFactory.getLogger(MainApiVerticle.class); + + private int serverPort = {{serverPort}}; protected Router router; + public int getServerPort() { + return serverPort; + } + + public void setServerPort(int serverPort) { + this.serverPort = serverPort; + } + @Override public void init(Vertx vertx, Context context) { super.init(vertx, context); @@ -37,13 +46,18 @@ public class MainApiVerticle extends AbstractVerticle { if (readFile.succeeded()) { Swagger swagger = new SwaggerParser().parse(readFile.result().toString(Charset.forName("utf-8"))); Router swaggerRouter = SwaggerRouter.swaggerRouter(router, swagger, vertx.eventBus(), new OperationIdServiceIdResolver()); - + deployVerticles(startFuture); - - vertx.createHttpServer() + + vertx.createHttpServer() .requestHandler(swaggerRouter::accept) - .listen({{serverPort}}); - startFuture.complete(); + .listen(serverPort, h -> { + if (h.succeeded()) { + startFuture.complete(); + } else { + startFuture.fail(h.cause()); + } + }); } else { startFuture.fail(readFile.cause()); }