Skip to content

Generate http client from interface #5729

@zZHorizonZz

Description

@zZHorizonZz

Describe the feature

I was wondering if it would be useful to have Vert.x codegen support for generating HTTP client implementations from interfaces. For example, you could define something like this:

@VertxGen
@HttpClient
public interface PetStoreApi {
    @Path(path = "/pets", method = HttpMethod.GET)
    Future<List<Pet>> listAllPets(@QueryParam("page") int page, @QueryParam("limit") int limit);
    
    @Path(path = "/pets/{id}", method = HttpMethod.GET)
    Future<JsonObject> getPetData(@PathParam("id") String id);
}

The generated implementation would:

  • Take an HttpClient as a constructor argument
  • Support primitive types, JsonObject, and data objects as request parameters
  • Support JsonObject and data objects as response types
  • Automatically handle path parameters, query parameters, and request/response serialization

This would provide a declarative way to define HTTP client interfaces similar to JAX-RS or Spring's @FeignClient, reducing boilerplate code for REST API consumption in Vert.x applications.

Contribution

I'm willing to contribute this

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions