Class RouterBuilder
- All Implemented Interfaces:
MutinyDelegate
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:
- Body handler (Customizable with
- Custom global handlers configurable with
- Global security handlers defined in upper spec level
- Operation specific security handlers
- Generated validation handler
- User handlers or "Not implemented" handler
original
non Mutiny-ified interface using Vert.x codegen.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRouterBuilder
(io.vertx.ext.web.openapi.RouterBuilder delegate) RouterBuilder
(Object delegate) -
Method Summary
Modifier and TypeMethodDescriptionbodyHandler
(BodyHandler bodyHandler) Deprecated.static io.smallrye.mutiny.Uni<RouterBuilder>
Likestatic io.smallrye.mutiny.Uni<RouterBuilder>
Likestatic RouterBuilder
createAndAwait
(Vertx vertx, String url) Blocking variant ofcreate(io.vertx.mutiny.core.Vertx,String)
.static RouterBuilder
createAndAwait
(Vertx vertx, String url, io.vertx.ext.web.openapi.OpenAPILoaderOptions options) Blocking variant ofcreate(io.vertx.mutiny.core.Vertx,String,OpenAPILoaderOptions)
.static void
createAndForget
(Vertx vertx, String url) Variant ofcreate(io.vertx.mutiny.core.Vertx,String)
that ignores the result of the operation.static void
createAndForget
(Vertx vertx, String url, io.vertx.ext.web.openapi.OpenAPILoaderOptions options) Variant ofcreate(io.vertx.mutiny.core.Vertx,String,OpenAPILoaderOptions)
that ignores the result of the operation.boolean
io.vertx.ext.web.openapi.RouterBuilder
io.vertx.ext.web.openapi.RouterBuilderOptions
Deprecated.This method exposes the internal of the OpenAPI handler, it will be removed in the future.Deprecated.This method exposes the internal of the OpenAPI handler, it will be removed in the future.int
hashCode()
static RouterBuilder
newInstance
(io.vertx.ext.web.openapi.RouterBuilder arg) rootHandler
(Consumer<RoutingContext> rootHandler) securityHandler
(String securitySchemeName) securityHandler
(String securitySchemeName, AuthenticationHandler handler) serviceExtraPayloadMapper
(Function<RoutingContext, io.vertx.core.json.JsonObject> serviceExtraPayloadMapper) setOptions
(io.vertx.ext.web.openapi.RouterBuilderOptions options) toString()
-
Field Details
-
__TYPE_ARG
-
-
Constructor Details
-
RouterBuilder
public RouterBuilder(io.vertx.ext.web.openapi.RouterBuilder delegate) -
RouterBuilder
-
-
Method Details
-
getDelegate
public io.vertx.ext.web.openapi.RouterBuilder getDelegate()- Specified by:
getDelegate
in interfaceMutinyDelegate
- Returns:
- the delegate used by this Mutiny object of generated type
-
toString
-
equals
-
hashCode
public int hashCode() -
operation
- Parameters:
operationId
- the id of the operation- Returns:
- the requested operation
-
operations
- Returns:
- all operations defined in the contract
-
bodyHandler
Deprecated.Use#rootHandler(Handler)
instead. The order matters, so adding the body handler should happen after anyPLATFORM
orSECURITY_POLICY
handler(s).- Parameters:
bodyHandler
-- Returns:
- self
-
rootHandler
- Parameters:
rootHandler
-- Returns:
-
mountServicesFromExtensions
- Returns:
- self
-
setOptions
- Parameters:
options
-- Returns:
- self
-
getOptions
public io.vertx.ext.web.openapi.RouterBuilderOptions getOptions()- Returns:
- options of router builder. For more info
RouterBuilderOptions
-
getOpenAPI
- Returns:
- holder used by self to process the OpenAPI. You can use it to resolve
$ref
s
-
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.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
- Parameters:
securitySchemeName
-- Returns:
- a security scheme.
-
createRouter
- Returns:
-
create
@CheckReturnValue public static io.smallrye.mutiny.Uni<RouterBuilder> create(Vertx vertx, String url) LikeUnlike 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
Blocking variant ofcreate(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.
-
createAndForget
Variant ofcreate(io.vertx.mutiny.core.Vertx,String)
that ignores the result of the operation.This method subscribes on the result of
create(io.vertx.mutiny.core.Vertx,String)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromcreate(io.vertx.mutiny.core.Vertx,String)
but you don't need to compose it with other operations.- Parameters:
vertx
-url
-
-
create
@CheckReturnValue public static io.smallrye.mutiny.Uni<RouterBuilder> create(Vertx vertx, String url, io.vertx.ext.web.openapi.OpenAPILoaderOptions options) LikeUnlike 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 ofcreate(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.
-
createAndForget
public static void createAndForget(Vertx vertx, String url, io.vertx.ext.web.openapi.OpenAPILoaderOptions options) Variant ofcreate(io.vertx.mutiny.core.Vertx,String,OpenAPILoaderOptions)
that ignores the result of the operation.This method subscribes on the result of
create(io.vertx.mutiny.core.Vertx,String,OpenAPILoaderOptions)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromcreate(io.vertx.mutiny.core.Vertx,String,OpenAPILoaderOptions)
but you don't need to compose it with other operations.- Parameters:
vertx
-url
-options
-
-
securityHandler
- Parameters:
securitySchemeName
- the components security scheme idhandler
- the authentication handler- Returns:
- self
-
newInstance
-
#rootHandler(Handler)
instead.