-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathquery3.ql
More file actions
44 lines (37 loc) · 1.05 KB
/
query3.ql
File metadata and controls
44 lines (37 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import javascript
string httpVerb() { result = ["get", "put", "post", "delete"] }
/** A RAML specification. */
class RAMLSpec extends YAMLDocument, YAMLMapping {
RAMLSpec() { getLocation().getFile().getExtension() = "raml" }
}
/** A RAML resource specification. */
class RAMLResource extends YAMLMapping {
RAMLResource() {
getDocument() instanceof RAMLSpec and
exists(YAMLMapping m, string name |
this = m.lookup(name) and
name.matches("/%")
)
}
/** Get the path of this resource relative to the API root. */
string getPath() {
exists(RAMLSpec spec | this = spec.lookup(result))
or
exists(RAMLResource that, string p |
this = that.lookup(p) and
result = that.getPath() + p
)
}
/** Get the method for this resource with the given verb. */
RAMLMethod getMethod(string verb) {
verb = httpVerb() and
result = lookup(verb)
}
}
class RAMLMethod extends YAMLValue {
RAMLMethod() {
getDocument() instanceof RAMLSpec and
exists(YAMLMapping obj | this = obj.lookup(httpVerb()))
}
}
select 1