1+ // Spring Web Request Annotations
2+ //
3+ // --- Method HTTP Annotation ---
4+ MATCH (method :Method )- [ : ANNOTATED_BY ] -> (httpMethodLink :Annotation )- [ : OF_TYPE ] -> (httpMethodAnnotation :Type )
5+ WHERE httpMethodAnnotation .fqn STARTS WITH 'org.springframework.web.bind.annotation.'
6+ AND httpMethodAnnotation .name IN ['RequestMapping' , 'GetMapping' , 'PostMapping' , 'PutMapping' , 'DeleteMapping' , 'PatchMapping' ]
7+ // --- Method HTTP Annotation Path Value ---
8+ OPTIONAL MATCH (httpMethodLink )- [ : HAS ] -> (httpPathAnnotationProperty :Value )- [ : CONTAINS ] -> (httpPathAnnotationValue :Value )
9+ WHERE httpPathAnnotationProperty .name IN ['value' , 'path' ]
10+ // --- Method HTTP Annotation Path Value ---
11+ OPTIONAL MATCH (httpMethodLink )- [ : HAS ] -> (httpMethodAnnotationProperty :Value )- [ : CONTAINS ] -> (httpMethodAnnotationValue :Value )
12+ WHERE httpMethodAnnotationProperty .name = 'method'
13+ // --- Method HTTP Annotation Other Values ---
14+ OPTIONAL MATCH (httpMethodLink )- [ : HAS ] -> (httpAnnotationAdditionalProperty :Value )- [ : CONTAINS ] -> (httpAnnotationAdditionalValue :Value )
15+ WHERE NOT httpAnnotationAdditionalProperty .name IN ['value' , 'path' , 'method' ]
16+ // --- Method Parameter Annotation ---
17+ OPTIONAL MATCH (method )- [ : HAS ] -> (methodParam :Parameter )- [ : ANNOTATED_BY ] -> (methodParamLink :Annotation )- [ : OF_TYPE ] -> (methodParamAnnotation :Type )
18+ WHERE methodParamAnnotation .fqn STARTS WITH 'org.springframework.web.bind.annotation.'
19+ OPTIONAL MATCH (methodParamLink )- [ : HAS ] -> (methodParamAnnotationValue :Value )
20+ // --- Type Path Annotation ---
21+ OPTIONAL MATCH (method )<- [ : DECLARES ] - (resourceType :Type )
22+ OPTIONAL MATCH (resourceType )- [ : ANNOTATED_BY ] -> (pathTypeLink :Annotation )- [ : OF_TYPE ] -> (pathTypeAnnotation :Type )
23+ WHERE pathTypeAnnotation .fqn = 'org.springframework.web.bind.annotation.RequestMapping'
24+ OPTIONAL MATCH (pathTypeLink )- [ : HAS ] -> (pathTypeAnnotationProperty :Value )- [ : CONTAINS ] -> (pathTypeAnnotationValue :Value )
25+ WHERE pathTypeAnnotationProperty .name IN ['value' , 'path' ]
26+ // --- SubType Path Annotation ---
27+ OPTIONAL MATCH (resourceType :Type )<- [ : EXTENDS *1..5 ] - (subResourceType :Type )- [ : ANNOTATED_BY ] -> (subResourceTypeLink :Annotation )- [ : OF_TYPE ] -> (subResourceTypeAnnotation :Type )
28+ WHERE subResourceTypeAnnotation .fqn = 'org.springframework.web.bind.annotation.RequestMapping'
29+ OPTIONAL MATCH (subResourceTypeLink )- [ : HAS ] -> (subResourceTypeAnnotationProperty :Value )- [ : CONTAINS ] -> (subResourceTypeAnnotationValue :Value )
30+ WHERE subResourceTypeAnnotationProperty .name IN ['value' , 'path' ]
31+ // --- Artifact ---
32+ OPTIONAL MATCH (artifact :Artifact )- [ : CONTAINS ] -> (resourceType )
33+ // --- Return Results ---
34+ RETURN replace (
35+ coalesce (subResourceTypeAnnotationValue .value , pathTypeAnnotationValue .value , '' ) +
36+ '/' +
37+ coalesce (httpPathAnnotationValue .value , '' )
38+ , '//' , '/' ) AS path
39+ ,coalesce (
40+ httpMethodAnnotationValue .value ,
41+ toUpper (
42+ replace (replace (httpMethodAnnotation .name , 'Mapping' , '' ), 'Request' , 'All' )
43+ )
44+ ) AS httpMethod
45+ ,replace (last (split (artifact .fileName , '/' )), '.jar' , '' ) AS resourceArtifact
46+ ,coalesce (subResourceType .fqn , resourceType .fqn ) AS resourceType
47+ ,method .name AS resourceMethod
48+ ,collect (
49+ httpAnnotationAdditionalProperty .name + ': ' +
50+ httpAnnotationAdditionalValue .value
51+ ) AS additionalHttpProperties
52+ ,collect (methodParamAnnotation .name +
53+ replace ('.' + methodParamAnnotationValue .name , '.value' , '' ) +
54+ ': ' +
55+ methodParamAnnotationValue .value ) AS methodParameters
56+ ORDER BY path , httpMethod , resourceType , resourceType
0 commit comments