Skip to content

Commit cedeca0

Browse files
authored
Merge pull request #1143 from magento-okapis/MAGETWO-55200-public_wsdl-2.1
Magetwo 55200 public wsdl 2.1
2 parents e1e4617 + 86f454e commit cedeca0

File tree

3 files changed

+64
-16
lines changed

3 files changed

+64
-16
lines changed

app/code/Magento/Webapi/Model/AbstractSchemaGenerator.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,13 @@ public function __construct(
6565
}
6666

6767
/**
68-
* Retrieve a list of services visible to current user.
68+
* Retrieve a list of all services.
6969
*
7070
* @return string[]
7171
*/
7272
public function getListOfServices()
7373
{
74-
$listOfAllowedServices = [];
75-
foreach ($this->serviceMetadata->getServicesConfig() as $serviceName => $service) {
76-
foreach ($service[ServiceMetadata::KEY_SERVICE_METHODS] as $method) {
77-
if ($this->authorization->isAllowed($method[ServiceMetadata::KEY_ACL_RESOURCES])) {
78-
$listOfAllowedServices[] = $serviceName;
79-
break;
80-
}
81-
}
82-
}
83-
return $listOfAllowedServices;
74+
return array_keys($this->serviceMetadata->getServicesConfig());
8475
}
8576

8677
/**

app/code/Magento/Webapi/Model/Rest/Swagger/Generator.php

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,18 @@
1313
use Magento\Webapi\Model\Rest\SwaggerFactory;
1414
use Magento\Framework\Webapi\Authorization;
1515
use Magento\Framework\Webapi\Exception as WebapiException;
16-
use Magento\Framework\Exception\AuthenticationException;
17-
use Magento\Framework\Exception\AuthorizationException;
18-
use Magento\Framework\Exception\LocalizedException;
19-
use Magento\Framework\Exception\NoSuchEntityException;
20-
use Magento\Framework\Phrase;
2116
use Magento\Framework\App\ProductMetadataInterface;
2217
use \Magento\Framework\Api\SimpleDataObjectConverter;
18+
use Magento\Webapi\Model\ServiceMetadata;
2319

2420
/**
2521
* REST Swagger schema generator.
2622
*
2723
* Generate REST API description in a format of JSON document,
2824
* compliant with {@link https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md Swagger specification}
25+
*
26+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
27+
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
2928
*/
3029
class Generator extends AbstractSchemaGenerator
3130
{
@@ -902,4 +901,23 @@ private function generateMethodExceptionErrorResponses($exceptionClass, $respons
902901

903902
return $responses;
904903
}
904+
905+
/**
906+
* Retrieve a list of services visible to current user.
907+
*
908+
* @return string[]
909+
*/
910+
public function getListOfServices()
911+
{
912+
$listOfAllowedServices = [];
913+
foreach ($this->serviceMetadata->getServicesConfig() as $serviceName => $service) {
914+
foreach ($service[ServiceMetadata::KEY_SERVICE_METHODS] as $method) {
915+
if ($this->authorization->isAllowed($method[ServiceMetadata::KEY_ACL_RESOURCES])) {
916+
$listOfAllowedServices[] = $serviceName;
917+
break;
918+
}
919+
}
920+
}
921+
return $listOfAllowedServices;
922+
}
905923
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Webapi\Controller;
8+
9+
class SoapTest extends \PHPUnit_Framework_TestCase
10+
{
11+
/**
12+
* @var \Magento\Webapi\Controller\Soap
13+
*/
14+
protected $soapController;
15+
16+
/**
17+
* @var \Magento\Framework\ObjectManagerInterface
18+
*/
19+
protected $objectManager;
20+
21+
protected function setUp()
22+
{
23+
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
24+
$this->soapController = $this->objectManager->get(\Magento\Webapi\Controller\Soap::class);
25+
}
26+
27+
/*
28+
* Get the public wsdl with anonymous credentials
29+
*/
30+
public function testDispatchWsdlRequest()
31+
{
32+
$request = $this->objectManager->get(\Magento\Framework\Webapi\Request::class);
33+
$request->setParam(\Magento\Webapi\Model\Soap\Server::REQUEST_PARAM_LIST_WSDL, true);
34+
$response = $this->soapController->dispatch($request);
35+
$decodedWsdl = json_decode($response->getContent(), true);
36+
$this->assertArrayHasKey("customerAccountManagementV1", $decodedWsdl);
37+
$this->assertArrayHasKey("integrationAdminTokenServiceV1", $decodedWsdl);
38+
}
39+
}

0 commit comments

Comments
 (0)