|
1 | | -<?php |
2 | | -/** |
3 | | - * SwaggerModule |
4 | | - * |
5 | | - * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | | - * you may not use this file except in compliance with the License. |
7 | | - * You may obtain a copy of the License at |
8 | | - * |
9 | | - * http://www.apache.org/licenses/LICENSE-2.0 |
10 | | - * |
11 | | - * Unless required by applicable law or agreed to in writing, software |
12 | | - * distributed under the License is distributed on an "AS IS" BASIS, |
13 | | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | | - * See the License for the specific language governing permissions and |
15 | | - * limitations under the License. |
16 | | - * |
17 | | - * @copyright Copyright (c) 2012 OuterEdge UK Ltd (http://www.outeredgeuk.com) |
18 | | - * @license http://www.apache.org/licenses/LICENSE-2.0 |
19 | | - */ |
20 | | - |
21 | | -namespace SwaggerModule\Controller; |
22 | | - |
23 | | -use OpenApi\Annotations\OpenApi; |
24 | | -use Laminas\Mvc\Controller\AbstractActionController; |
25 | | -use Laminas\View\Model\JsonModel; |
26 | | - |
27 | | -/** |
28 | | - * DocumentationController. It is used to display a documentation in HTML |
29 | | - */ |
30 | | -class DocumentationController extends AbstractActionController |
31 | | -{ |
32 | | - protected $openApi; |
33 | | - |
34 | | - public function setOpenApi(OpenApi $openApi) { |
35 | | - $this->swagger = $openApi; |
36 | | - } |
37 | | - |
38 | | - /** |
39 | | - * Display the documentation |
40 | | - * |
41 | | - * @return JsonModel |
42 | | - */ |
43 | | - public function displayAction() |
44 | | - { |
45 | | - $jsonModel = new JsonModel((array)$this->swagger->jsonSerialize()); |
46 | | - return $jsonModel; |
47 | | - } |
48 | | - |
49 | | - /** |
50 | | - * Get the details of a resource |
51 | | - * |
52 | | - * @return JsonModel |
53 | | - */ |
54 | | - public function detailsAction() |
55 | | - { |
56 | | - /** @var $options \SwaggerModule\Options\ModuleOptions */ |
57 | | - $options = $this->serviceLocator->get('SwaggerModule\Options\ModuleOptions'); |
58 | | - $resourceOptions = $options->getResourceOptions() ? : array(); |
59 | | - $resource = $this->swagger->getResource('/' . $this->params('resource', null), $resourceOptions); |
60 | | - |
61 | | - if ($resource === false) { |
62 | | - return new JsonModel(); |
63 | | - } |
64 | | - |
65 | | - $jsonModel = new JsonModel(); |
66 | | - |
67 | | - return $jsonModel->setVariables($resource); |
68 | | - } |
69 | | -} |
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * SwaggerModule |
| 5 | + * |
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + * you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + * |
| 18 | + * @copyright Copyright (c) 2012 OuterEdge UK Ltd (http://www.outeredgeuk.com) |
| 19 | + * @license http://www.apache.org/licenses/LICENSE-2.0 |
| 20 | + */ |
| 21 | + |
| 22 | +declare(strict_types=1); |
| 23 | + |
| 24 | +namespace SwaggerModule\Controller; |
| 25 | + |
| 26 | +use OpenApi\Annotations\OpenApi; |
| 27 | +use Laminas\Mvc\Controller\AbstractActionController; |
| 28 | +use Laminas\View\Model\JsonModel; |
| 29 | +use SwaggerModule\Options\ModuleOptions; |
| 30 | + |
| 31 | +/** |
| 32 | + * DocumentationController. It is used to display a documentation in HTML |
| 33 | + */ |
| 34 | +class DocumentationController extends AbstractActionController |
| 35 | +{ |
| 36 | + /** @var OpenApi */ |
| 37 | + protected $openApi; |
| 38 | + |
| 39 | + /** @var ModuleOptions */ |
| 40 | + protected $moduleOptions; |
| 41 | + |
| 42 | + public function setOpenApi(OpenApi $openApi) |
| 43 | + { |
| 44 | + $this->openApi = $openApi; |
| 45 | + } |
| 46 | + |
| 47 | + public function setModuleOptions(ModuleOptions $moduleOptions) |
| 48 | + { |
| 49 | + $this->moduleOptions = $moduleOptions; |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * Display the documentation |
| 54 | + * |
| 55 | + * @return JsonModel |
| 56 | + */ |
| 57 | + public function displayAction() |
| 58 | + { |
| 59 | + $jsonModel = new JsonModel((array)$this->openApi->jsonSerialize()); |
| 60 | + return $jsonModel; |
| 61 | + } |
| 62 | +} |
0 commit comments