@@ -16,42 +16,53 @@ def get_data_set():
16
16
"//anotherserver.com/files/example.json" ,
17
17
],
18
18
"relative_references" : [
19
+ "#/definitions/myElement" ,
19
20
"document.json#/myElement" ,
20
21
"../document.json#/myElement" ,
21
22
"../another-folder/document.json#/myElement" ,
22
23
],
23
24
"absolute_references" : [
24
- "#/definitions/myElement" ,
25
25
"http://path/to/your/resource" ,
26
26
"http://path/to/your/resource.json#myElement" ,
27
27
"//anotherserver.com/files/example.json" ,
28
28
],
29
- "remotepath_by_reference" : {
30
- "#/definitions/myElement" : None ,
29
+ "full_document_references" : [
30
+ "http://path/to/your/resource" ,
31
+ "//anotherserver.com/files/example.json" ,
32
+ ],
33
+ "not_full_document_references" : [
34
+ "#/definitions/myElement" ,
35
+ "document.json#/myElement" ,
36
+ "../document.json#/myElement" ,
37
+ "../another-folder/document.json#/myElement" ,
38
+ "http://path/to/your/resource.json#myElement" ,
39
+ ],
40
+ "path_by_reference" : {
41
+ "#/definitions/myElement" : "" ,
31
42
"document.json#/myElement" : "document.json" ,
32
43
"../document.json#/myElement" : "../document.json" ,
33
44
"../another-folder/document.json#/myElement" : "../another-folder/document.json" ,
34
45
"http://path/to/your/resource" : "http://path/to/your/resource" ,
35
46
"http://path/to/your/resource.json#myElement" : "http://path/to/your/resource.json" ,
36
47
"//anotherserver.com/files/example.json" : "//anotherserver.com/files/example.json" ,
37
48
},
38
- "path_by_reference " : {
49
+ "pointer_by_reference " : {
39
50
"#/definitions/myElement" : "/definitions/myElement" ,
40
51
"document.json#/myElement" : "/myElement" ,
41
52
"../document.json#/myElement" : "/myElement" ,
42
53
"../another-folder/document.json#/myElement" : "/myElement" ,
43
- "http://path/to/your/resource" : "/ " ,
54
+ "http://path/to/your/resource" : "" ,
44
55
"http://path/to/your/resource.json#myElement" : "/myElement" ,
45
- "//anotherserver.com/files/example.json" : "/ " ,
56
+ "//anotherserver.com/files/example.json" : "" ,
46
57
},
47
- "pathparent_by_reference " : {
58
+ "pointerparent_by_reference " : {
48
59
"#/definitions/myElement" : "/definitions" ,
49
- "document.json#/myElement" : "/ " ,
50
- "../document.json#/myElement" : "/ " ,
51
- "../another-folder/document.json#/myElement" : "/ " ,
52
- "http://path/to/your/resource" : "/" ,
53
- "http://path/to/your/resource.json#myElement" : "/ " ,
54
- "//anotherserver.com/files/example.json" : "/" ,
60
+ "document.json#/myElement" : "" ,
61
+ "../document.json#/myElement" : "" ,
62
+ "../another-folder/document.json#/myElement" : "" ,
63
+ "http://path/to/your/resource" : None ,
64
+ "http://path/to/your/resource.json#myElement" : "" ,
65
+ "//anotherserver.com/files/example.json" : None ,
55
66
},
56
67
}
57
68
@@ -138,37 +149,57 @@ def test_is_relative():
138
149
assert ref .is_relative () == True
139
150
140
151
141
- def test_path ():
152
+ def test_pointer ():
142
153
from openapi_python_client .resolver .reference import Reference
143
154
144
155
data_set = get_data_set ()
145
156
146
- for ref_str in data_set ["path_by_reference " ].keys ():
157
+ for ref_str in data_set ["pointer_by_reference " ].keys ():
147
158
ref = Reference (ref_str )
148
- path = data_set ["path_by_reference " ][ref_str ]
149
- assert ref .path == path
159
+ pointer = data_set ["pointer_by_reference " ][ref_str ]
160
+ assert ref .pointer . value == pointer
150
161
151
162
152
- def test_path_parent ():
163
+ def test_pointer_parent ():
153
164
from openapi_python_client .resolver .reference import Reference
154
165
155
166
data_set = get_data_set ()
156
167
157
- for ref_str in data_set ["pathparent_by_reference " ].keys ():
168
+ for ref_str in data_set ["pointerparent_by_reference " ].keys ():
158
169
ref = Reference (ref_str )
159
- path_parent = data_set ["pathparent_by_reference" ][ref_str ]
160
- assert ref .path_parent == path_parent
170
+ pointer_parent = data_set ["pointerparent_by_reference" ][ref_str ]
171
+
172
+ if pointer_parent is not None :
173
+ assert ref .pointer .parent .value == pointer_parent
174
+ else :
175
+ assert ref .pointer .parent == None
161
176
162
177
163
- def test_remote_path ():
178
+ def test_path ():
164
179
from openapi_python_client .resolver .reference import Reference
165
180
166
181
data_set = get_data_set ()
167
182
168
- for ref_str in data_set ["remotepath_by_reference" ].keys ():
183
+ for ref_str in data_set ["path_by_reference" ].keys ():
184
+ ref = Reference (ref_str )
185
+ path = data_set ["path_by_reference" ][ref_str ]
186
+ assert ref .path == path
187
+
188
+
189
+ def test_is_full_document ():
190
+ from openapi_python_client .resolver .reference import Reference
191
+
192
+ data_set = get_data_set ()
193
+
194
+ for ref_str in data_set ["full_document_references" ]:
195
+ ref = Reference (ref_str )
196
+ assert ref .is_full_document () == True
197
+ assert ref .pointer .parent == None
198
+
199
+ for ref_str in data_set ["not_full_document_references" ]:
169
200
ref = Reference (ref_str )
170
- remote_path = data_set [ "remotepath_by_reference" ][ ref_str ]
171
- assert ref .remote_path == remote_path
201
+ assert ref . is_full_document () == False
202
+ assert ref .pointer . parent != None
172
203
173
204
174
205
def test_value ():
0 commit comments