File tree 5 files changed +24
-1
lines changed
5 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -192,6 +192,9 @@ public function getIterator()
192
192
public function resolveReferences (ReferenceContext $ context )
193
193
{
194
194
foreach ($ this ->_paths as $ key => $ path ) {
195
+ if ($ path === null ) {
196
+ continue ;
197
+ }
195
198
$ path ->resolveReferences ($ context );
196
199
}
197
200
}
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ public function resolve(ReferenceContext $context)
102
102
103
103
$ file = ($ pos === false ) ? $ this ->_ref : substr ($ this ->_ref , 0 , $ pos );
104
104
$ file = $ context ->resolveRelativeUri ($ file );
105
- $ jsonPointer = substr ($ this ->_ref , $ pos + 1 );
105
+ $ jsonPointer = ( $ pos === false ) ? '' : substr ($ this ->_ref , $ pos + 1 );
106
106
107
107
// TODO could be a good idea to cache loaded files in current context to avoid loading the same files over and over again
108
108
$ fileContent = $ this ->fetchReferencedFile ($ file );
Original file line number Diff line number Diff line change @@ -153,6 +153,18 @@ public function testResolveFile()
153
153
$ this ->assertInstanceOf (Schema::class, $ petItems = $ openapi ->components ->schemas ['Dog ' ]);
154
154
$ this ->assertArrayHasKey ('id ' , $ openapi ->components ->schemas ['Pet ' ]->properties );
155
155
$ this ->assertArrayHasKey ('name ' , $ openapi ->components ->schemas ['Dog ' ]->properties );
156
+
157
+ // second level reference inside of definitions.yaml
158
+ $ this ->assertArrayHasKey ('food ' , $ openapi ->components ->schemas ['Dog ' ]->properties );
159
+ $ this ->assertInstanceOf (Reference::class, $ openapi ->components ->schemas ['Dog ' ]->properties ['food ' ]);
160
+
161
+ $ openapi ->resolveReferences (new \cebe \openapi \ReferenceContext ($ openapi , $ file ));
162
+
163
+ $ this ->assertArrayHasKey ('food ' , $ openapi ->components ->schemas ['Dog ' ]->properties );
164
+ $ this ->assertInstanceOf (Schema::class, $ openapi ->components ->schemas ['Dog ' ]->properties ['food ' ]);
165
+ $ this ->assertArrayHasKey ('id ' , $ openapi ->components ->schemas ['Dog ' ]->properties ['food ' ]->properties );
166
+ $ this ->assertArrayHasKey ('name ' , $ openapi ->components ->schemas ['Dog ' ]->properties ['food ' ]->properties );
167
+ $ this ->assertEquals (1 , $ openapi ->components ->schemas ['Dog ' ]->properties ['food ' ]->properties ['id ' ]->example );
156
168
}
157
169
158
170
public function testResolveFileHttp ()
Original file line number Diff line number Diff line change
1
+ properties :
2
+ id :
3
+ type : integer
4
+ example : 1
5
+ name :
6
+ type : string
Original file line number Diff line number Diff line change 9
9
properties :
10
10
name :
11
11
type : string
12
+ food :
13
+ $ref : ' Food.yaml'
You can’t perform that action at this time.
0 commit comments