Skip to content

[JAVA] [library: vertx] Fix improper initialization of main router in MainApiVerticle template #7230

@ccozzolino

Description

@ccozzolino
Description

The current template for MainApiVerticle incorrectly instantiates the protected main Router and does not re-use that router member with the instantiated SwaggerRouter. I propose that we modify the template as follows:

Initiantiate the router as part of the init flow to ensure that the vertx instance is not null:

    Router router;

    @Override
    public void init(Vertx vertx, Context context) {
    	super.init(vertx, context);
    	router = Router.router(vertx);
    }

Also, pass the router member as the first parameter of the SwaggerRouter creation:

Router swaggerRouter = SwaggerRouter.swaggerRouter(router, swagger, vertx.eventBus(), new OperationIdServiceIdResolver());
Swagger-codegen version

2.2.3 and above

Swagger declaration file content or url
Command line used for generation
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions