@@ -219,11 +219,21 @@ private static function resolveRef(string $ref, string $resolved, $container, ar
219219 $ unresolved = $ slash === false ? $ resolved . $ subpath : $ resolved . $ subpath . '/ ' ;
220220
221221 if (is_object ($ container )) {
222- if (property_exists ($ container , $ property ) === false ) {
222+ // support use x-* in ref
223+ $ xKey = strpos ($ property , 'x- ' ) === 0 ? substr ($ property , 2 ) : null ;
224+ if ($ xKey ) {
225+ if (!is_array ($ container ->x ) || !array_key_exists ($ xKey , $ container ->x )) {
226+ $ xKey = null ;
227+ }
228+ }
229+ if (property_exists ($ container , $ property ) === false && !$ xKey ) {
223230 throw new OpenApiException ('$ref " ' . $ ref . '" not found ' );
224231 }
232+
233+ $ nextContainer = $ xKey ? $ container ->x [$ xKey ] : $ container ->{$ property };
234+
225235 if ($ slash === false ) {
226- return $ container ->{ $ property } ;
236+ return $ nextContainer ;
227237 }
228238 $ mapping = [];
229239 foreach ($ container ::$ _nested as $ nestedClass => $ nested ) {
@@ -232,7 +242,7 @@ private static function resolveRef(string $ref, string $resolved, $container, ar
232242 }
233243 }
234244
235- return self ::resolveRef ($ ref , $ unresolved , $ container ->{ $ property } , $ mapping );
245+ return self ::resolveRef ($ ref , $ unresolved , $ nextContainer , $ mapping );
236246 } elseif (is_array ($ container )) {
237247 if (array_key_exists ($ property , $ container )) {
238248 return self ::resolveRef ($ ref , $ unresolved , $ container [$ property ], []);
0 commit comments