Class OpenAPI3RouterFactory
- java.lang.Object
-
- io.vertx.reactivex.ext.web.api.contract.openapi3.OpenAPI3RouterFactory
-
- All Implemented Interfaces:
RouterFactory
public class OpenAPI3RouterFactory extends Object implements RouterFactory
Interface for OpenAPI3RouterFactory.
To add an handler, useaddHandlerByOperationId(java.lang.String, io.vertx.core.Handler<io.vertx.reactivex.ext.web.RoutingContext>)
Usage example:OpenAPI3RouterFactory.create(vertx, "src/resources/spec.yaml", asyncResult -> { if (!asyncResult.succeeded()) { // IO failure or spec invalid
else { OpenAPI3RouterFactory routerFactory = asyncResult.result(); routerFactory.addHandlerByOperationId("operation_id", routingContext -> { // Do something }, routingContext -> { // Do something with failure handler }); Router router = routerFactory.getRouter(); } }); }
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 RX-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static TypeArg<OpenAPI3RouterFactory>
__TYPE_ARG
-
Constructor Summary
Constructors Constructor Description OpenAPI3RouterFactory(OpenAPI3RouterFactory delegate)
OpenAPI3RouterFactory(Object delegate)
-
Method Summary
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<OpenAPI3RouterFactory> __TYPE_ARG
-
-
Constructor Detail
-
OpenAPI3RouterFactory
public OpenAPI3RouterFactory(OpenAPI3RouterFactory delegate)
-
OpenAPI3RouterFactory
public OpenAPI3RouterFactory(Object delegate)
-
-
Method Detail
-
getDelegate
public OpenAPI3RouterFactory getDelegate()
- Specified by:
getDelegate
in interfaceRouterFactory
-
addSecurityHandler
@Deprecated public RouterFactory addSecurityHandler(String securitySchemaName, Handler<RoutingContext> handler)
Deprecated.Mount to paths that have to follow a security schema a security handler- Specified by:
addSecurityHandler
in interfaceRouterFactory
- Parameters:
securitySchemaName
-handler
-- Returns:
-
setOptions
@Deprecated public RouterFactory setOptions(RouterFactoryOptions options)
Deprecated.Set options of router factory. For more info- Specified by:
setOptions
in interfaceRouterFactory
- Parameters:
options
-- Returns:
-
getOptions
@Deprecated public RouterFactoryOptions getOptions()
Deprecated.Get options of router factory. For more info- Specified by:
getOptions
in interfaceRouterFactory
- Returns:
-
getRouter
@Deprecated public Router getRouter()
Deprecated.Construct a new router based on spec. It will fail if you are trying to mount a spec with security schemes without assigned handlers
Note: Router is constructed in this function, so it will be respected the path definition ordering.- Specified by:
getRouter
in interfaceRouterFactory
- Returns:
-
getValidationFailureHandler
@Deprecated public Handler<RoutingContext> getValidationFailureHandler()
Deprecated.- Specified by:
getValidationFailureHandler
in interfaceRouterFactory
- Returns:
-
setValidationFailureHandler
@Deprecated public RouterFactory setValidationFailureHandler(Handler<RoutingContext> validationFailureHandler)
Deprecated.Set default validation failure handler. You can enable/disable this feature from- Specified by:
setValidationFailureHandler
in interfaceRouterFactory
- Parameters:
validationFailureHandler
-- Returns:
- this object
-
setNotImplementedFailureHandler
@Deprecated public RouterFactory setNotImplementedFailureHandler(Handler<RoutingContext> notImplementedFailureHandler)
Deprecated.Set not implemented failure handler. It's called when you don't define an handler for a specific operation. You can enable/disable this feature from- Specified by:
setNotImplementedFailureHandler
in interfaceRouterFactory
- Parameters:
notImplementedFailureHandler
-- Returns:
- this object
-
setBodyHandler
@Deprecated public RouterFactory setBodyHandler(BodyHandler bodyHandler)
Deprecated.Supply your own BodyHandler if you would like to control body limit, uploads directory and deletion of uploaded files- Specified by:
setBodyHandler
in interfaceRouterFactory
- Parameters:
bodyHandler
-- Returns:
- self
-
addGlobalHandler
@Deprecated public RouterFactory addGlobalHandler(Handler<RoutingContext> globalHandler)
Deprecated.Add global handler to be applied prior toRouter
being generated.
Please note that you should not add a body handler inside that list. If you want to modify the body handler, please use- Specified by:
addGlobalHandler
in interfaceRouterFactory
- Parameters:
globalHandler
-- Returns:
- this object
-
setExtraOperationContextPayloadMapper
@Deprecated public RouterFactory setExtraOperationContextPayloadMapper(Function<RoutingContext,JsonObject> extraOperationContextPayloadMapper)
Deprecated.When set, this function is called while creating the payload ofOperationRequest
- Specified by:
setExtraOperationContextPayloadMapper
in interfaceRouterFactory
- Parameters:
extraOperationContextPayloadMapper
-- Returns:
-
addSecuritySchemaScopeValidator
@Deprecated public OpenAPI3RouterFactory addSecuritySchemaScopeValidator(String securitySchemaName, String scopeName, Handler<RoutingContext> handler)
Deprecated.Add a particular scope validator. The main security schema will not be called if a specific scope validator is configured- Parameters:
securitySchemaName
-scopeName
-handler
-- Returns:
- this factory
-
addHandlerByOperationId
@Deprecated public OpenAPI3RouterFactory addHandlerByOperationId(String operationId, Handler<RoutingContext> handler)
Deprecated.Add an handler by operation_id field in Operation object- Parameters:
operationId
-handler
-- Returns:
- this factory
-
addFailureHandlerByOperationId
@Deprecated public OpenAPI3RouterFactory addFailureHandlerByOperationId(String operationId, Handler<RoutingContext> failureHandler)
Deprecated.Add a failure handler by operation_id field in Operation object- Parameters:
operationId
-failureHandler
-- Returns:
- this factory
-
mountOperationToEventBus
@Deprecated public OpenAPI3RouterFactory mountOperationToEventBus(String operationId, String address)
Deprecated.Specify to route an incoming request for specified operation id to a Web Api Service mounted at the specified address on event bus. Please give a look at vertx-web-api-service documentation for more informations- Parameters:
operationId
-address
-- Returns:
- this factory
-
mountServiceFromTag
@Deprecated public OpenAPI3RouterFactory mountServiceFromTag(String tag, String address)
Deprecated.Specify to route an incoming request for all operations that contains the specified tag to a Web Api Service mounted at the specified address on event bus. The request is handled by the method that matches the operation id. Please give a look at vertx-web-api-service documentation for more informations- Parameters:
tag
-address
-- Returns:
- this factory
-
mountServicesFromExtensions
@Deprecated public OpenAPI3RouterFactory mountServicesFromExtensions()
Deprecated.Introspect the OpenAPI spec to mount handlers for all operations that specifies a x-vertx-event-bus annotation. Please give a look at vertx-web-api-service documentation for more informations- Returns:
- this factory
-
create
@Deprecated public static void create(Vertx vertx, String url, Handler<AsyncResult<OpenAPI3RouterFactory>> handler)
Deprecated.Create a new OpenAPI3RouterFactory- Parameters:
vertx
-url
- location of your spec. It can be an absolute path, a local path or remote url (with HTTP protocol)handler
- When specification is loaded, this handler will be called with AsyncResult
-
create
@Deprecated public static void create(Vertx vertx, String url)
Deprecated.Create a new OpenAPI3RouterFactory- Parameters:
vertx
-url
- location of your spec. It can be an absolute path, a local path or remote url (with HTTP protocol)
-
rxCreate
@Deprecated public static io.reactivex.Single<OpenAPI3RouterFactory> rxCreate(Vertx vertx, String url)
Deprecated.Create a new OpenAPI3RouterFactory- Parameters:
vertx
-url
- location of your spec. It can be an absolute path, a local path or remote url (with HTTP protocol)- Returns:
-
create
@Deprecated public static void create(Vertx vertx, String url, List<JsonObject> auth, Handler<AsyncResult<OpenAPI3RouterFactory>> handler)
Deprecated.Create a new OpenAPI3RouterFactory- Parameters:
vertx
-url
- location of your spec. It can be an absolute path, a local path or remote url (with HTTP protocol)auth
- list of authorization values needed to access the remote url. Each item should be json representation of anAuthorizationValue
handler
- When specification is loaded, this handler will be called with AsyncResult
-
create
@Deprecated public static void create(Vertx vertx, String url, List<JsonObject> auth)
Deprecated.Create a new OpenAPI3RouterFactory- Parameters:
vertx
-url
- location of your spec. It can be an absolute path, a local path or remote url (with HTTP protocol)auth
- list of authorization values needed to access the remote url. Each item should be json representation of anAuthorizationValue
-
rxCreate
@Deprecated public static io.reactivex.Single<OpenAPI3RouterFactory> rxCreate(Vertx vertx, String url, List<JsonObject> auth)
Deprecated.Create a new OpenAPI3RouterFactory- Parameters:
vertx
-url
- location of your spec. It can be an absolute path, a local path or remote url (with HTTP protocol)auth
- list of authorization values needed to access the remote url. Each item should be json representation of anAuthorizationValue
- Returns:
-
newInstance
public static OpenAPI3RouterFactory newInstance(OpenAPI3RouterFactory arg)
-
-