1+ // Jakarta Enterprise Edition JAX-RS REST Annotations
2+ //
3+ // --- Method Http Annotation ---
4+ MATCH (method :Method )- [ : ANNOTATED_BY ] -> (httpMethodLink :Annotation )- [ : OF_TYPE ] -> (httpMethodAnnotation :Type )
5+ WHERE ((httpMethodAnnotation .fqn STARTS WITH 'jakarta.ws.rs.'
6+ OR httpMethodAnnotation .fqn STARTS WITH 'javax.ws.rs.' )
7+ AND httpMethodAnnotation .name IN ['GET' , 'POST' , 'PUT' , 'DELETE' , 'PATCH' , 'HEAD' , 'OPTIONS' ])
8+ // --- Method Path Annotation ---
9+ OPTIONAL MATCH (method )- [ : ANNOTATED_BY ] -> (pathMethodLink :Annotation )- [ : OF_TYPE ] -> (pathMethodAnnotation :Type )
10+ WHERE pathMethodAnnotation .fqn in ['jakarta.ws.rs.Path' , 'javax.ws.rs.Path' ]
11+ OPTIONAL MATCH (pathMethodLink )- [ : HAS ] -> (pathMethodValue :Value { name : 'value' } )
12+ // --- Method Parameter Annotation ---
13+ OPTIONAL MATCH (method )- [ : HAS ] -> (methodParam :Parameter )- [ : ANNOTATED_BY ] -> (methodParamLink :Annotation )- [ : OF_TYPE ] -> (methodParamAnnotation :Type )
14+ WHERE ((methodParamAnnotation .fqn STARTS WITH 'jakarta.ws.rs.'
15+ OR methodParamAnnotation .fqn STARTS WITH 'javax.ws.rs.' )
16+ AND methodParamAnnotation .name ENDS WITH 'Param'
17+ AND methodParamAnnotation .name <> 'PathParam' )
18+ OPTIONAL MATCH (methodParamLink )- [ : HAS ] -> (methodParamValue :Value { name : 'value' } )
19+ // --- Type Path Annotation ---
20+ OPTIONAL MATCH (method )<- [ : DECLARES ] - (pathType :Type )
21+ OPTIONAL MATCH (pathType )- [ : ANNOTATED_BY ] -> (pathTypeLink :Annotation )- [ : OF_TYPE ] -> (pathTypeAnnotation :Type )
22+ WHERE pathTypeAnnotation .fqn in ['jakarta.ws.rs.Path' , 'javax.ws.rs.Path' ]
23+ OPTIONAL MATCH (pathTypeLink )- [ : HAS ] -> (pathTypeValue :Value { name : 'value' } )
24+ // --- SubType Path Annotation ---
25+ OPTIONAL MATCH (pathType :Type )<- [ : EXTENDS *1..3 ] - (subPathType :Type )- [ : ANNOTATED_BY ] -> (subPathTypeLink :Annotation )- [ : OF_TYPE ] -> (subPathTypeAnnotation :Type )
26+ WHERE subPathTypeAnnotation .fqn in ['jakarta.ws.rs.Path' , 'javax.ws.rs.Path' ]
27+ OPTIONAL MATCH (subPathTypeLink )- [ : HAS ] -> (subPathTypeValue :Value { name : 'value' } )
28+ // --- Application Path Annotation ---
29+ OPTIONAL MATCH (artifact :Artifact )- [ : CONTAINS ] -> (pathType )
30+ OPTIONAL MATCH (artifact )- [ : CONTAINS ] -> (applicationPathType :Type )- [ : ANNOTATED_BY ] -> (applicationPathLink :Annotation )- [ : OF_TYPE ] -> (applicationPathAnnotation :Type )
31+ WHERE applicationPathAnnotation .fqn in ['jakarta.ws.rs.ApplicationPath' , 'javax.ws.rs.ApplicationPath' ]
32+ OPTIONAL MATCH (applicationPathLink )- [ : HAS ] -> (applicationPathValue :Value { name : 'value' } )
33+ // --- Return Results ---
34+ RETURN replace (coalesce (
35+ coalesce (applicationPathValue .value , '' ) + '/' +
36+ coalesce (subPathTypeValue .value , pathTypeValue .value , '' ) + '/' +
37+ coalesce (pathMethodValue .value , '' )
38+ ), '//' , '/' ) AS url
39+ ,httpMethodAnnotation .name AS httpMethod
40+ ,replace (last (split (artifact .fileName , '/' )), '.jar' , '' ) AS ressourceArtifact
41+ ,coalesce (subPathType .fqn , pathType .fqn ) AS ressourceType
42+ ,method .name AS ressourceMethod
43+ ,collect (methodParamAnnotation .name + ': ' + methodParamValue .value ) AS methodParameters
44+ ORDER BY url , httpMethod , ressourceType , ressourceMethod
0 commit comments