Search in sources :

Example 1 with SwaggerRouter

use of com.github.phiz71.vertx.swagger.router.SwaggerRouter in project azure-iot-sdk-java by Azure.

the class MainApiVerticle method start.

@SuppressWarnings("deprecation")
@Override
public void start(Future<Void> startFuture) throws Exception {
    Json.mapper.registerModule(new JavaTimeModule());
    FileSystem vertxFileSystem = vertx.fileSystem();
    vertxFileSystem.readFile("swagger.json", readFile -> {
        if (readFile.succeeded()) {
            Swagger swagger = new SwaggerParser().parse(readFile.result().toString(StandardCharsets.UTF_8));
            Router swaggerRouter = SwaggerRouter.swaggerRouter(router, swagger, vertx.eventBus(), new OperationIdServiceIdResolver(), t -> new DeliveryOptions().setSendTimeout(90000));
            deployVerticles(startFuture);
            vertx.createHttpServer().requestHandler(swaggerRouter::accept).listen(8080);
            startFuture.complete();
        } else {
            startFuture.fail(readFile.cause());
        }
    });
}
Also used : SwaggerParser(io.swagger.parser.SwaggerParser) JavaTimeModule(com.fasterxml.jackson.datatype.jsr310.JavaTimeModule) FileSystem(io.vertx.core.file.FileSystem) Swagger(io.swagger.models.Swagger) SwaggerRouter(com.github.phiz71.vertx.swagger.router.SwaggerRouter) Router(io.vertx.ext.web.Router) DeliveryOptions(io.vertx.core.eventbus.DeliveryOptions) OperationIdServiceIdResolver(com.github.phiz71.vertx.swagger.router.OperationIdServiceIdResolver)

Aggregations

JavaTimeModule (com.fasterxml.jackson.datatype.jsr310.JavaTimeModule)1 OperationIdServiceIdResolver (com.github.phiz71.vertx.swagger.router.OperationIdServiceIdResolver)1 SwaggerRouter (com.github.phiz71.vertx.swagger.router.SwaggerRouter)1 Swagger (io.swagger.models.Swagger)1 SwaggerParser (io.swagger.parser.SwaggerParser)1 DeliveryOptions (io.vertx.core.eventbus.DeliveryOptions)1 FileSystem (io.vertx.core.file.FileSystem)1 Router (io.vertx.ext.web.Router)1