vertx-web
vertx-web copied to clipboard
Openapi RouterBuilder as subrouter does not correctly parse path parameters
Version
5.0.0.CR3
Context
The openapi router with GET /data/{id} is added as a subrouter to /api/test
Invoking http://localhost:8082/api/test/data/1 throws a validation exception:
The value of path parameter id is invalid. Reason: Instance type string is invalid. Expected integer
Debugging RequestValidatorImpl.validate shows that in request.path key "id" has value "test"
however, if the parameter type constraint is removed, invoking RoutingContext.pathParams() in the route handler returns the expected value: id -> 1
Do you have a reproducer?
verticle:
HttpServer server = vertx.createHttpServer(); Router global = Router.router(vertx); OpenAPIContract.from(vertx, "openapi.json").onSuccess(contract -> { RouterBuilderImpl routerBuilder = (RouterBuilderImpl) RouterBuilder.create(vertx, contract); for (Operation op : contract.operations()) { String opid = op.getOperationId(); String address = "api.test." + opid; DeliveryOptions dOptions = new DeliveryOptions().setLocalOnly(true); routerBuilder.getRoute(opid) .addHandler(RouteToEBServiceHandler.build(vertx.eventBus(), address, address, dOptions)); } Router subrouter = routerBuilder.createRouter(); Route route = global.route("/api/test/*").subRouter(subrouter); server.requestHandler(global).listen(8082);}).onFailure((e) -> e.printStackTrace());
openapi:
"/data/{id}": { "get": { "responses": { "200": { "content": { "application/json": {} }, "description": "ok" } }, "operationId": "getData" }, "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } } ] }