Retrofit 2 and Spring RestController

I want to create a project with three modules:

  • Mobile application (modify?)
  • Spring Endpoint (@RestControler)
  • Interface (contains communication objects and definition of recreation methods )

Data classes are the easy part, as I can use the same parser at both ends or just not use the gson / jackson / * son annotations at all.

The problem is this:

How to define Retrofit and Spring interface so that manual synchronization of both files is not required?

Re-equipment:

public interface GitHubService {
  @GET("users/{user}/repos")
  Call<List<Repo>> listRepos(@Path("user") String user);
}

Spring:

public class GitHubService {
  @RequestMapping(value="users/{user}/repos", mehod=GET)
  List<Repo> listRepos(@PathVariable("user") String user);
}
+4
source share

Source: https://habr.com/ru/post/1687569/


All Articles