Skip to content

Migrating JAX-RS annotations results in broken annotation when path given on type level #402

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fabapp2 opened this issue Sep 18, 2022 · 0 comments · Fixed by #404
Closed
Labels
JEE/JAX-RS type: bug Something isn't working
Milestone

Comments

@fabapp2
Copy link
Contributor

fabapp2 commented Sep 18, 2022

Describe the bug
When running MigrateJaxRsRecipe against an endpoint that only defined a @Path on type and not method level the generated @RequestMapping annotation is broken.

package com.example.jeerest.rest;
                
import com.example.jeerest.Movie;
import com.example.jeerest.MoviesBean;
import org.springframework.beans.factory.annotation.Autowired;
                
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import java.util.List;
                
@Path("movies")
@Produces({"application/json"})
public class MoviesRest {
    @GET
    public List<Movie> getMovies(@QueryParam("first") Integer first, @QueryParam("max") Integer max,
                                 @QueryParam("field") String field, @QueryParam("searchTerm") String searchTerm) {
        return service.getMovies(first, max, field, searchTerm);
    }
}

results in

package com.example.jeerest.rest;
                
import com.example.jeerest.Movie;
import com.example.jeerest.MoviesBean;
import org.springframework.beans.factory.annotation.Autowired;

import javax.ws.rs.DELETE;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import java.util.List;

@Path("movies")
@Produces({"application/json"})
public class MoviesRest {
    @RequestMapping(, method = RequestMethod.GET)
    public List<Movie> getMovies(@QueryParam("first") Integer first, @QueryParam("max") Integer max,
                                 @QueryParam("field") String field, @QueryParam("searchTerm") String searchTerm) {
        return service.getMovies(first, max, field, searchTerm);
    }
}

with broken annotation
@RequestMapping(, method = RequestMethod.GET)

To Reproduce
Apply MigrateJaxRsRecipe to a controller as described above.

Expected behavior
In the example above the resulting annotations should look like this:
@RequestMapping(method = RequestMethod.GET)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JEE/JAX-RS type: bug Something isn't working
Projects
None yet
1 participant