File tree 1 file changed +38
-0
lines changed
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -346,6 +346,44 @@ public function testTransitiveReference()
346
346
$ this ->assertEquals ('string ' , $ openapi ->paths ['/city ' ]->get ->responses [200 ]->content ['application/json ' ]->schema ->type );
347
347
}
348
348
349
+ /**
350
+ * References to references fail as "cyclic reference"
351
+ * @see https://github.com/cebe/php-openapi/issues/54
352
+ */
353
+ public function testTransitiveReferenceToFile ()
354
+ {
355
+ $ schema = <<<'YAML'
356
+ openapi: 3.0.2
357
+ info:
358
+ title: 'Dog API'
359
+ version: dev
360
+ paths:
361
+ '/dog':
362
+ get:
363
+ description: 'Get Dog'
364
+ responses:
365
+ '200':
366
+ description: 'success'
367
+ content:
368
+ application/json:
369
+ schema:
370
+ $ref: '#/components/schemas/Dog'
371
+ components:
372
+ schemas:
373
+ Dog:
374
+ $ref: 'definitions.yaml#/Dog'
375
+
376
+ YAML;
377
+
378
+ $ openapi = Reader::readFromYaml ($ schema );
379
+ $ openapi ->resolveReferences (new \cebe \openapi \ReferenceContext ($ openapi , 'file:// ' . __DIR__ . '/data/reference/definitions.yaml ' ));
380
+
381
+ $ this ->assertTrue (isset ($ openapi ->components ->schemas ['Dog ' ]));
382
+ $ this ->assertEquals ('object ' , $ openapi ->components ->schemas ['Dog ' ]->type );
383
+ $ this ->assertEquals ('object ' , $ openapi ->components ->schemas ['Dog ' ]->type );
384
+ $ this ->assertEquals ('object ' , $ openapi ->paths ['/dog ' ]->get ->responses [200 ]->content ['application/json ' ]->schema ->type );
385
+ }
386
+
349
387
public function testTransitiveReferenceCyclic ()
350
388
{
351
389
$ schema = <<<'YAML'
You can’t perform that action at this time.
0 commit comments