-
Notifications
You must be signed in to change notification settings - Fork 0
/
SwaggerUIRenderer.php
executable file
·59 lines (50 loc) · 1.32 KB
/
SwaggerUIRenderer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace globalart\swagger;
use yii\base\Action;
/**
* Class SwaggerUIRenderer renders the UI (HTML/JS/CSS).
*
* @package globalart\swagger
*/
class SwaggerUIRenderer extends Action
{
/**
* @var string the rest urls configuration
*/
public $urls = [
'api' => 'json-schema'
];
/**
* @var boolean is filter show
*/
public $filter = false;
/**
* @var string base swagger template
*/
public $view = '@vendor/globalart/yii2-swagger/views/index';
/**
* @var null|string|false the name of the layout to be applied to this controller's views.
* This property mainly affects the behavior of [[render()]].
* Defaults to null, meaning the actual layout value should inherit that from [[module]]'s layout value.
* If false, no layout will be applied.
*/
public $layout = false;
/**
* @inheritdoc
*/
public function run()
{
$this->controller->layout = $this->layout;
$urls = [];
foreach($this->urls as $name => $url) {
$urls[] = [
'name' => $name,
'url' => $url,
];
}
return $this->controller->render($this->view, [
'urls' => json_encode($urls) ?? [],
'filter' => $this->filter,
]);
}
}