File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -320,4 +320,39 @@ public function testRefAdditionalProperties()
320
320
$ schema = new Schema (['additionalProperties ' => new Reference (['$ref ' => '#/here ' ], Schema::class)]);
321
321
$ this ->assertInstanceOf (Reference::class, $ schema ->additionalProperties );
322
322
}
323
+
324
+ /**
325
+ * Ensure that a property named "$ref" is not interpreted as a reference.
326
+ * @link https://github.com/OAI/OpenAPI-Specification/issues/2173
327
+ */
328
+ public function testPropertyNameRef ()
329
+ {
330
+ $ json = <<<'JSON'
331
+ {
332
+ "components": {
333
+ "schemas": {
334
+ "person": {
335
+ "type": "object",
336
+ "properties": {
337
+ "name": {
338
+ "type": "string"
339
+ },
340
+ "$ref": {
341
+ "type": "string"
342
+ }
343
+ }
344
+ }
345
+ }
346
+ }
347
+ }
348
+ JSON;
349
+ $ openApi = Reader::readFromJson ($ json );
350
+ $ this ->assertInstanceOf (Schema::class, $ person = $ openApi ->components ->schemas ['person ' ]);
351
+
352
+ $ this ->assertEquals (['name ' , '$ref ' ], array_keys ($ person ->properties ));
353
+ $ this ->assertInstanceOf (Schema::class, $ person ->properties ['name ' ]);
354
+ $ this ->assertInstanceOf (Schema::class, $ person ->properties ['$ref ' ]);
355
+ $ this ->assertEquals ('string ' , $ person ->properties ['name ' ]->type );
356
+ $ this ->assertEquals ('string ' , $ person ->properties ['$ref ' ]->type );
357
+ }
323
358
}
You can’t perform that action at this time.
0 commit comments