documentation home

FAQ  Miredot warns about REST interfaces partially overlapping


Problem

When you have a REST interface with a path parameter and another with a literal at the same position in the URL, Miredot warns that the two resources partially overlap.

Solution

Add a regular expression to the parameter so that it is narrowed down and no longer matches with the literal.

For example, if you have the following interfaces:

    @GET
    @Path("/cars/{id}")
    public Car getCar(@PathParam("id") int id);

    @GET
    @Path("/cars/electric")
    public List<Car> getElectricCars();

You can fix the partial overlap by adding a regular expression to the id parameter:

    @GET
    @Path("/cars/{id:\\d+}")
    public Car getCar(@PathParam("id") int id);

    @GET
    @Path("/cars/electric")
    public List<Car> getElectricCars();

This limits the ids to positive integers only, so they no longer overlap with the string "electric".