Anders
Anders

Reputation: 75

Prefixing paths in Vert.x Web Api service/contract

It seems that the vertx-web-api-service/vertx-web-api-contract does not respect the OpenAPI 3 top-level node called "servers" - under which is a list of - url: that can be used by the client to know where the API is located (and prefixed).

I want to be able to prefix the paths: with /v1 but how is that possible? My initial though was to put it in the top-level servers: node but it does not work.

Upvotes: 0

Views: 116

Answers (1)

Francesco Guardiani
Francesco Guardiani

Reputation: 688

It's not possible for the RouterFactory object to automatically determine the base path to use, because the servers is an array and you might define more than once (https://github.com/vert-x3/vertx-web/issues/1655).

If you need to specify a subpath, mount the generated router as subrouter in another router specifying the subpath:

Router generated = routerFactory.getRouter();
Router global = Router.router(vertx);
global.mountSubRouter("/v1", generated);

Upvotes: 4

Related Questions