Skip to content

Commit bbbd5a2

Browse files
Adds example of URI type reference
1 parent bed83c0 commit bbbd5a2

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

lib/types/type_reference.ex

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,42 @@ defmodule JS2E.Types.TypeReference do
55
JSON Schema:
66
77
"self": {
8-
"$ref": "#/definitions/link"
8+
"$ref": "#/definitions/foo"
99
}
1010
11-
Where "#/definitions/link" resolves to
11+
"other": {
12+
"$ref": "http://www.example.com/definitions.json#bar"
13+
}
14+
15+
Where "#/definitions/foo" resolves to
1216
1317
"definitions": {
14-
"link": {
15-
"type": "string"
16-
}
18+
"foo": {
19+
"type": "string"
20+
}
21+
}
22+
23+
and "http://www.example.com/definitions.json#bar" resolves to
24+
25+
"definitions": {
26+
"bar": {
27+
"id": "#bar",
28+
"type": "number"
29+
}
1730
}
1831
1932
Elixir intermediate representation:
2033
2134
%TypeReference{name: "self",
2235
path: ["#", "definitions", "link"]}
2336
37+
%TypeReference{name: "other",
38+
path: %URI{scheme: "http",
39+
host: "www.example.com",
40+
path: "/definitions.json",
41+
fragment: "bar",
42+
...}}
43+
2444
"""
2545

2646
alias JS2E.Types

0 commit comments

Comments
 (0)