-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathRAML.qll
More file actions
53 lines (46 loc) · 1.33 KB
/
RAML.qll
File metadata and controls
53 lines (46 loc) · 1.33 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
45
46
47
48
49
50
51
52
53
/** Model of RAML specifications. */
import javascript
import HTTP
/** 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 = this.lookup(verb)
}
}
/** A RAML method specification. */
class RamlMethod extends YamlValue {
RamlMethod() {
getDocument() instanceof RamlSpec and
exists(YamlMapping obj | this = obj.lookup(httpVerb()))
}
/** Get the response specification for the given status code. */
YamlValue getResponse(int code) {
exists(YamlMapping obj, string s |
obj = this.(YamlMapping).lookup("responses") and
result = obj.lookup(s) and
code = s.toInt()
)
}
}