toJson(), true); $modelAnnotations = $annotations['components']['schemas']; foreach ($modelAnnotations as $modelName => $modelAnnotation) { $isExtend = preg_match('/.*(Extend)(.*)/', $modelName, $matches); if (!$isExtend) { continue; } $modelExtendedName = $matches[2]; $modelAnnotations[$modelExtendedName] = array_replace_recursive($modelAnnotations[$modelExtendedName], $modelAnnotation); unset($modelAnnotations[$modelName]); } $annotations['components']['schemas'] = $modelAnnotations; $host = $request->getSchemeAndHttpHost(); $annotations['servers'] = [ ['url' => $host.'/open_api'], ['url' => $host.'/index_dev.php/open_api'], ]; return $this->render('swagger-ui', [ 'spec' => json_encode($annotations), ]); } }