Closed Anubarak closed 4 years ago
hi @Anubarak
In deed there was no dependency set in composer.json for bootstrap. I have added it now. Thanks! For testing purpose I did following:
vendor
folder and composer.lock
filevendor/bower-asset/bootstrap
vendor/bower-asset/jquery
vendor/yiisoft/yii2-bootstrap
vendor/nostop8/rest-api-doc
composer.json
make sure that required version of module is set to *
("nostop8/rest-api-doc": "*"
)composer install
in your projectThis is the result I got after with modules versions below:
It works without javascript errors after this for me. In case after this it still provides an error for you, the problem might be somewhere else. E.g. some other module conflicts with my, overrides the jquery or bootstrap js files.
Thank you very much for your fast reply.
I was able to find the JS issue. I use sub-modules for the versioning of my API and your plugin only picked the controller name, for example v1/foo
then you included that as an ID of the HTML element but slashes in IDs are forbidden so $('#v1/foo')
throws an error.
I fixed it via
public function actionIndex()
{
$rules = [];
foreach (\Yii::$app->urlManager->rules as $urlRule) {
if ($urlRule instanceof \yii\rest\UrlRule) {
$entity = [];
$urlName = key($urlRule->controller);
$controllerName = current($urlRule->controller);
$entity['title'] = ucfirst($controllerName);
// convert slashes, just a hotfix for my situation, usually you would rely on correct regex replacement
$entity['id'] = str_replace('/', '-', ucfirst($controllerName));
$urlRuleReflection = new \ReflectionClass($urlRule);
$rulesObject = $urlRuleReflection->getProperty('rules');
$rulesObject->setAccessible(true);
$generatedRules = $rulesObject->getValue($urlRule);
$entity['rules'] = $this->_processRules($generatedRules[$urlName]);
$rules[] = $entity;
}
}
return $this->render('index', [
'rules' => $rules,
]);
}
Thanks again, it can be closed
Can you please tell me what versions of Bootstrap and jQuery you require? The Bootstrapplugin is not required in your composerand I don't know what version you used, I tried 4.x and 3.x and Bootstrap 3.x seems to work, but I always receive a JS error when clicking on an item
It looks like this currently