Class RouterBuilder


  • public class RouterBuilder
    extends Object
    Interface to build a Vert.x Web from an OpenAPI 3 contract.
    To add an handler, use operation(java.lang.String) (String, Handler)}
    Usage example:
     RouterBuilder.create(vertx, "src/resources/spec.yaml", asyncResult -> {
      if (!asyncResult.succeeded()) {
         // IO failure or spec invalid else {
         RouterBuilder routerBuilder = asyncResult.result();
         RouterBuilder.operation("operation_id").handler(routingContext -> {
            // Do something
         }, routingContext -> {
            // Do something with failure handler
         });
         Router router = routerBuilder.createRouter();
      }
     });
     }
     

    Handlers are loaded in this order:
    1. Body handler (Customizable with
    2. Custom global handlers configurable with
    3. Global security handlers defined in upper spec level
    4. Operation specific security handlers
    5. Generated validation handler
    6. User handlers or "Not implemented" handler

    NOTE: This class has been automatically generated from the original non Mutiny-ified interface using Vert.x codegen.

    • Constructor Detail

      • RouterBuilder

        public RouterBuilder​(io.vertx.ext.web.openapi.RouterBuilder delegate)
      • RouterBuilder

        public RouterBuilder​(Object delegate)
    • Method Detail

      • getDelegate

        public io.vertx.ext.web.openapi.RouterBuilder getDelegate()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • operation

        public Operation operation​(String operationId)
        Parameters:
        operationId - the id of the operation
        Returns:
        the requested operation
      • operations

        public List<Operation> operations()
        Returns:
        all operations defined in the contract
      • bodyHandler

        @Deprecated
        public RouterBuilder bodyHandler​(BodyHandler bodyHandler)
        Deprecated.
        Use #rootHandler(Handler) instead. The order matters, so adding the body handler should happen after any PLATFORM or SECURITY_POLICY handler(s).
        Parameters:
        bodyHandler -
        Returns:
        self
      • mountServicesFromExtensions

        public RouterBuilder mountServicesFromExtensions()
        Returns:
        self
      • setOptions

        public RouterBuilder setOptions​(io.vertx.ext.web.openapi.RouterBuilderOptions options)
        Parameters:
        options -
        Returns:
        self
      • getOptions

        public io.vertx.ext.web.openapi.RouterBuilderOptions getOptions()
        Returns:
        options of router builder. For more info RouterBuilderOptions
      • getOpenAPI

        public OpenAPIHolder getOpenAPI()
        Returns:
        holder used by self to process the OpenAPI. You can use it to resolve $refs
      • getSchemaRouter

        @Deprecated
        public SchemaRouter getSchemaRouter()
        Deprecated.
        This method exposes the internal of the OpenAPI handler, it will be removed in the future. Users should configure the json schema module from the options.
        Returns:
        schema router used by self to internally manage all Schema instances
      • getSchemaParser

        @Deprecated
        public SchemaParser getSchemaParser()
        Deprecated.
        This method exposes the internal of the OpenAPI handler, it will be removed in the future. Users should configure the json schema module from the options.
        Returns:
        schema parser used by self to parse all Schema
      • serviceExtraPayloadMapper

        public RouterBuilder serviceExtraPayloadMapper​(Function<RoutingContext,​io.vertx.core.json.JsonObject> serviceExtraPayloadMapper)
        Parameters:
        serviceExtraPayloadMapper -
        Returns:
        self
      • securityHandler

        public SecurityScheme securityHandler​(String securitySchemeName)
        Parameters:
        securitySchemeName -
        Returns:
        a security scheme.
      • createRouter

        public Router createRouter()
        Returns:
      • create

        @CheckReturnValue
        public static io.smallrye.mutiny.Uni<RouterBuilder> create​(Vertx vertx,
                                                                   String url)
        Like

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Parameters:
        vertx -
        url -
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • createAndAwait

        public static RouterBuilder createAndAwait​(Vertx vertx,
                                                   String url)
        Blocking variant of create(io.vertx.mutiny.core.Vertx,String).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Parameters:
        vertx -
        url -
        Returns:
        the RouterBuilder instance produced by the operation.
      • create

        @CheckReturnValue
        public static io.smallrye.mutiny.Uni<RouterBuilder> create​(Vertx vertx,
                                                                   String url,
                                                                   io.vertx.ext.web.openapi.OpenAPILoaderOptions options)
        Like

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        Parameters:
        vertx -
        url -
        options -
        Returns:
        the uni firing the result of the operation when completed, or a failure if the operation failed.
      • createAndAwait

        public static RouterBuilder createAndAwait​(Vertx vertx,
                                                   String url,
                                                   io.vertx.ext.web.openapi.OpenAPILoaderOptions options)
        Blocking variant of create(io.vertx.mutiny.core.Vertx,String,OpenAPILoaderOptions).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        Parameters:
        vertx -
        url -
        options -
        Returns:
        the RouterBuilder instance produced by the operation.
      • securityHandler

        public RouterBuilder securityHandler​(String securitySchemeName,
                                             AuthenticationHandler handler)
        Parameters:
        securitySchemeName - the components security scheme id
        handler - the authentication handler
        Returns:
        self
      • newInstance

        public static RouterBuilder newInstance​(io.vertx.ext.web.openapi.RouterBuilder arg)