@@ -70,6 +70,7 @@ class PropertySchema
7070
7171 /** @var string $refPointer */
7272 private $ refPointer ;
73+ private $ uri ;
7374
7475 /** @var \cebe\yii2openapi\lib\openapi\ComponentSchema $refSchema */
7576 private $ refSchema ;
@@ -170,6 +171,7 @@ private function initReference():void
170171 {
171172 $ this ->isReference = true ;
172173 $ this ->refPointer = $ this ->property ->getJsonReference ()->getJsonPointer ()->getPointer ();
174+ $ this ->uri = $ this ->property ->getJsonReference ()->getDocumentUri ();
173175 $ refSchemaName = $ this ->getRefSchemaName ();
174176 if ($ this ->isRefPointerToSelf ()) {
175177 $ this ->refSchema = $ this ->schema ;
@@ -194,6 +196,7 @@ private function initItemsReference():void
194196 return ;
195197 }
196198 $ this ->refPointer = $ items ->getJsonReference ()->getJsonPointer ()->getPointer ();
199+ $ this ->uri = $ this ->property ->getJsonReference ()->getDocumentUri ();
197200 if ($ this ->isRefPointerToSelf ()) {
198201 $ this ->refSchema = $ this ->schema ;
199202 } elseif ($ this ->isRefPointerToSchema ()) {
@@ -301,8 +304,15 @@ public function getRefSchemaName():string
301304 '~^ ' .self ::REFERENCE_PATH .'(?<schemaName>.+)/properties/(?<propName>.+)$~ '
302305 : '~^ ' .self ::REFERENCE_PATH .'(?<schemaName>.+)$~ ' ;
303306 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+ }
305314 }
315+ var_dump ($ matches );
306316 return $ matches ['schemaName ' ];
307317 }
308318
0 commit comments