@@ -70,6 +70,7 @@ class PropertySchema
70
70
71
71
/** @var string $refPointer */
72
72
private $ refPointer ;
73
+ private $ uri ;
73
74
74
75
/** @var \cebe\yii2openapi\lib\openapi\ComponentSchema $refSchema */
75
76
private $ refSchema ;
@@ -170,6 +171,7 @@ private function initReference():void
170
171
{
171
172
$ this ->isReference = true ;
172
173
$ this ->refPointer = $ this ->property ->getJsonReference ()->getJsonPointer ()->getPointer ();
174
+ $ this ->uri = $ this ->property ->getJsonReference ()->getDocumentUri ();
173
175
$ refSchemaName = $ this ->getRefSchemaName ();
174
176
if ($ this ->isRefPointerToSelf ()) {
175
177
$ this ->refSchema = $ this ->schema ;
@@ -194,6 +196,7 @@ private function initItemsReference():void
194
196
return ;
195
197
}
196
198
$ this ->refPointer = $ items ->getJsonReference ()->getJsonPointer ()->getPointer ();
199
+ $ this ->uri = $ this ->property ->getJsonReference ()->getDocumentUri ();
197
200
if ($ this ->isRefPointerToSelf ()) {
198
201
$ this ->refSchema = $ this ->schema ;
199
202
} elseif ($ this ->isRefPointerToSchema ()) {
@@ -301,8 +304,15 @@ public function getRefSchemaName():string
301
304
'~^ ' .self ::REFERENCE_PATH .'(?<schemaName>.+)/properties/(?<propName>.+)$~ '
302
305
: '~^ ' .self ::REFERENCE_PATH .'(?<schemaName>.+)$~ ' ;
303
306
if (!\preg_match ($ pattern , $ this ->refPointer , $ matches )) {
304
- throw new InvalidDefinitionException ('Invalid schema reference ' );
307
+ $ pattern = '/((\.\/)*)(?<schemaName>.+)(\.)(yml|yaml)(.*)/ ' ;
308
+ // $pattern = '~^(?<schemaName>.+)(\.+)(yaml+)(.*)$~';
309
+ if (strpos ($ this ->uri , '# ' ) !== false && !\preg_match ($ pattern , $ this ->uri , $ matches )) {
310
+ // throw new InvalidDefinitionException('Invalid schema reference');
311
+ } else {
312
+ throw new InvalidDefinitionException ('Invalid schema reference ' );
313
+ }
305
314
}
315
+ var_dump ($ matches );
306
316
return $ matches ['schemaName ' ];
307
317
}
308
318
0 commit comments