This project detects the REST endpoints and clients (API calls) using static source code analysis for JAVA Spring Boot projects. For multiple microservices, it also finds the rest communication between the microservices.
To get started clone the Github repository.
$ git clone https://github.com/cloudhubs/rad-source.git
-
RadSourceService: Takes a list of paths of a single JAVA source file or, a directory as input. If input is a directory then it scans all java source files recursively and for each of them runs
RestCallService
andRestEndpointService
. -
RestCallService: Takes a single JAVA source file as input and detects all the rest calls along with their parent method, HTTP type, and return type.
-
RestEndpointService: Takes a single JAVA source file as input and detects all the rest endpoints along with their parent method, HTTP type, and return type.
-
RestFlowService: Takes a list of
RestCall
andRestEndpoint
as input and matches them to detect rest communication between microservices.
$ git clone https://github.com/cloudhubs/rad-source.git
$ cd rad-source
$ mvn clean install -DskipTests
$ java -jar application/target/rad-source-application-0.0.5.jar
You can either use a single java source file path or a directory path in pathToSource
.
$ curl --request POST \
--url http://localhost:8080/ \
--header 'content-type: application/json' \
--cookie JSESSIONID=3AFF4A7EDCBFA4249E1269FDA19A77C9 \
--data '{
"pathToMsRoots": [
"C:\\seer-lab\\cil-tms\\tms-cms",
"C:\\seer-lab\\cil-tms\\tms-ems"
]
}'
{
"request": {
"pathToMsRoots": [
"C:\\seer-lab\\cil-tms\\tms-cms",
"C:\\seer-lab\\cil-tms\\tms-ems"
]
},
"restEntityContexts": [
{
"pathToMsRoot": "C:\\seer-lab\\cil-tms\\tms-cms",
"restCalls": [
{
"msRoot": "C:\\seer-lab\\cil-tms\\tms-cms",
"source": "C:\\seer-lab\\cil-tms\\tms-cms\\src\\main\\java\\edu\\baylor\\ecs\\cms\\service\\EmsService.java",
"httpMethod": "POST",
"parentMethod": "edu.baylor.ecs.cms.service.EmsService.createExam",
"returnType": "edu.baylor.ecs.cms.dto.ExamDto",
"collection": false
},
...
],
"restEndpoints": [
{
"msRoot": "C:\\seer-lab\\cil-tms\\tms-cms",
"source": "C:\\seer-lab\\cil-tms\\tms-cms\\src\\main\\java\\edu\\baylor\\ecs\\cms\\controller\\CategoryInfoController.java",
"httpMethod": "GET",
"parentMethod": "edu.baylor.ecs.cms.controller.CategoryInfoController.getCategoryInfo",
"arguments": "[]",
"returnType": "java.lang.Object",
"collection": true
},
...
]
},
...
],
"restFlows": [
{
"client": {
"msRoot": "C:\\seer-lab\\cil-tms\\tms-cms",
"source": "C:\\seer-lab\\cil-tms\\tms-cms\\src\\main\\java\\edu\\baylor\\ecs\\cms\\service\\EmsService.java",
"httpMethod": "GET",
"parentMethod": "edu.baylor.ecs.cms.service.EmsService.getQuestionsForExam",
"returnType": "edu.baylor.ecs.cms.model.Question",
"collection": true
},
"endpoint": {
"msRoot": "C:\\seer-lab\\cil-tms\\tms-ems",
"source": "C:\\seer-lab\\cil-tms\\tms-ems\\src\\main\\java\\edu\\baylor\\ecs\\ems\\controller\\ExamController.java",
"httpMethod": "GET",
"parentMethod": "edu.baylor.ecs.ems.controller.ExamController.listAllQuestionsForExam",
"arguments": "[@PathVariable Integer id]",
"returnType": "edu.baylor.ecs.ems.model.Question",
"collection": true
}
},
...
]
}
$ git clone https://github.com/cloudhubs/rad-source.git
$ cd rad-source
$ mvn clean install -DskipTests
<dependency>
<groupId>edu.baylor.ecs.cloudhubs</groupId>
<artifactId>rad-source</artifactId>
<version>0.0.5</version>
</dependency>
@Autowired
private final RadSourceService radSourceService;
public RadSourceResponseContext getRadSourceResponseContext(RadSourceRequestContext request) throws IOException {
return radSourceService.generateRadSourceResponseContext(request);
}
public class RadSourceRequestContext {
private List<String> pathToMsRoots;
}
public class RadSourceResponseContext {
private RadSourceRequestContext request;
private List<RestEntityContext> restEntityContexts;
private List<RestFlow> restFlows;
}
public class RestEntityContext {
String pathToMsRoot;
private List<RestCall> restCalls;
private List<RestEndpoint> restEndpoints;
}
public class RestCall {
private String msRoot;
private String source;
private String httpMethod;
private String parentMethod;
private String returnType;
private boolean isCollection;
}
public class RestEndpoint {
private String msRoot;
private String source;
private String httpMethod;
private String parentMethod;
private String arguments;
private String returnType;
private boolean isCollection;
}
public class RestFlow {
private RestCall client;
private RestEndpoint endpoint;
}