Skip to content

Commit 3f2ddc6

Browse files
committed
#51 🤷
1 parent 6bd7bf9 commit 3f2ddc6

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

tests/src/PHPUnit/Schema/ExportTest.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,74 @@ public function testRefClass()
174174
);
175175
}
176176

177+
/**
178+
* @throws \Swaggest\JsonSchema\Exception
179+
* @throws \Swaggest\JsonSchema\InvalidValue
180+
* @see https://github.com/swaggest/php-json-schema/issues/51
181+
*/
182+
public function testJustADereferencer()
183+
{
184+
$schema = \Swaggest\JsonSchema\Schema::import(json_decode(<<<'JSON'
185+
{
186+
"type": "object",
187+
"properties": {
188+
"id": {
189+
"type": "integer"
190+
},
191+
"orders": {
192+
"type": "array",
193+
"items": {
194+
"$ref": "#/definitions/order"
195+
}
196+
}
197+
},
198+
"definitions": {
199+
"order": {
200+
"type": "object",
201+
"properties": {
202+
"orderid": {
203+
"type": "integer"
204+
}
205+
}
206+
}
207+
}
208+
}
209+
JSON
210+
));
211+
212+
$dereferencedJson = json_encode($schema, JSON_PRETTY_PRINT);
213+
$this->assertSame(<<<'JSON'
214+
{
215+
"definitions": {
216+
"order": {
217+
"properties": {
218+
"orderid": {
219+
"type": "integer"
220+
}
221+
},
222+
"type": "object"
223+
}
224+
},
225+
"properties": {
226+
"id": {
227+
"type": "integer"
228+
},
229+
"orders": {
230+
"items": {
231+
"properties": {
232+
"orderid": {
233+
"type": "integer"
234+
}
235+
},
236+
"type": "object"
237+
},
238+
"type": "array"
239+
}
240+
},
241+
"type": "object"
242+
}
243+
JSON
244+
, $dereferencedJson
245+
);
246+
}
177247
}

0 commit comments

Comments
 (0)