Skip to content

Commit 84d0875

Browse files
author
Stanislav Idolov
authored
MAGETWO-87607: [Backport 2.1-develop] Change the store code in Swagger based on a param #13486
2 parents 582a673 + 759b386 commit 84d0875

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Swagger\Block;
7+
8+
use Magento\Framework\View\Element\Template;
9+
10+
/**
11+
* Class Index
12+
*
13+
* @api
14+
*/
15+
class Index extends Template
16+
{
17+
/**
18+
* @return mixed|string
19+
*/
20+
private function getParamStore()
21+
{
22+
return $this->getRequest()->getParam('store') ?: 'all';
23+
}
24+
25+
/**
26+
* @return string
27+
*/
28+
public function getSchemaUrl()
29+
{
30+
return rtrim($this->getBaseUrl(), '/') . '/rest/' . $this->getParamStore() . '/schema?services=all';
31+
}
32+
}

app/code/Magento/Swagger/view/frontend/layout/swagger_index_index.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<referenceContainer name="page.wrapper" remove="true"/>
4242
<referenceBlock name="requirejs-config" remove="true"/>
4343
<referenceContainer name="root">
44-
<block name="swaggerUiContent" class="Magento\Framework\View\Element\Template" template="Magento_Swagger::swagger-ui/index.phtml"/>
44+
<block name="swaggerUiContent" class="Magento\Swagger\Block\Index" template="Magento_Swagger::swagger-ui/index.phtml"/>
4545
</referenceContainer>
4646
</body>
4747
</page>

app/code/Magento/Swagger/view/frontend/templates/swagger-ui/index.phtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@
99
*
1010
* The original name of this file, as part of the swagger-ui package, was dist/index.html.
1111
*
12-
* Modified by Magento, Modifications Copyright © Magento, Inc.
12+
* Modified by Magento, Modifications Copyright © Magento, Inc. All rights reserved.
1313
*/
1414

15-
/** @var \Magento\Framework\View\Element\Template $block */
15+
/** @var \Magento\Swagger\Block\Index $block */
1616

17-
$schemaUrl = rtrim($block->getBaseUrl(), '/') . '/rest/default/schema?services=all';
17+
$schemaUrl = $block->getSchemaUrl();
1818
?>
1919

2020
<div id='header'>
2121
<div class="swagger-ui-wrap">
2222
<a id="logo" href="http://swagger.io">swagger</a>
2323
<form id='api_selector'>
24-
<input id="input_baseUrl" type="hidden" value="<?php /* @escapeNotVerified */ echo $schemaUrl ?>"/>
24+
<input id="input_baseUrl" type="hidden" value="<?= /* @escapeNotVerified */ $schemaUrl ?>"/>
2525
<div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div>
2626
<div class='input'><a id="explore" href="#" data-sw-translate>apply</a></div>
2727
</form>

0 commit comments

Comments
 (0)