Skip to content

Commit

Permalink
Merge pull request #1143 from magento-okapis/MAGETWO-55200-public_wsd…
Browse files Browse the repository at this point in the history
…l-2.1

Magetwo 55200 public wsdl 2.1
  • Loading branch information
cpartica authored May 26, 2017
2 parents e1e4617 + 86f454e commit cedeca0
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 16 deletions.
13 changes: 2 additions & 11 deletions app/code/Magento/Webapi/Model/AbstractSchemaGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,13 @@ public function __construct(
}

/**
* Retrieve a list of services visible to current user.
* Retrieve a list of all services.
*
* @return string[]
*/
public function getListOfServices()
{
$listOfAllowedServices = [];
foreach ($this->serviceMetadata->getServicesConfig() as $serviceName => $service) {
foreach ($service[ServiceMetadata::KEY_SERVICE_METHODS] as $method) {
if ($this->authorization->isAllowed($method[ServiceMetadata::KEY_ACL_RESOURCES])) {
$listOfAllowedServices[] = $serviceName;
break;
}
}
}
return $listOfAllowedServices;
return array_keys($this->serviceMetadata->getServicesConfig());
}

/**
Expand Down
28 changes: 23 additions & 5 deletions app/code/Magento/Webapi/Model/Rest/Swagger/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@
use Magento\Webapi\Model\Rest\SwaggerFactory;
use Magento\Framework\Webapi\Authorization;
use Magento\Framework\Webapi\Exception as WebapiException;
use Magento\Framework\Exception\AuthenticationException;
use Magento\Framework\Exception\AuthorizationException;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Phrase;
use Magento\Framework\App\ProductMetadataInterface;
use \Magento\Framework\Api\SimpleDataObjectConverter;
use Magento\Webapi\Model\ServiceMetadata;

/**
* REST Swagger schema generator.
*
* Generate REST API description in a format of JSON document,
* compliant with {@link https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md Swagger specification}
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
*/
class Generator extends AbstractSchemaGenerator
{
Expand Down Expand Up @@ -902,4 +901,23 @@ private function generateMethodExceptionErrorResponses($exceptionClass, $respons

return $responses;
}

/**
* Retrieve a list of services visible to current user.
*
* @return string[]
*/
public function getListOfServices()
{
$listOfAllowedServices = [];
foreach ($this->serviceMetadata->getServicesConfig() as $serviceName => $service) {
foreach ($service[ServiceMetadata::KEY_SERVICE_METHODS] as $method) {
if ($this->authorization->isAllowed($method[ServiceMetadata::KEY_ACL_RESOURCES])) {
$listOfAllowedServices[] = $serviceName;
break;
}
}
}
return $listOfAllowedServices;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Webapi\Controller;

class SoapTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \Magento\Webapi\Controller\Soap
*/
protected $soapController;

/**
* @var \Magento\Framework\ObjectManagerInterface
*/
protected $objectManager;

protected function setUp()
{
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->soapController = $this->objectManager->get(\Magento\Webapi\Controller\Soap::class);
}

/*
* Get the public wsdl with anonymous credentials
*/
public function testDispatchWsdlRequest()
{
$request = $this->objectManager->get(\Magento\Framework\Webapi\Request::class);
$request->setParam(\Magento\Webapi\Model\Soap\Server::REQUEST_PARAM_LIST_WSDL, true);
$response = $this->soapController->dispatch($request);
$decodedWsdl = json_decode($response->getContent(), true);
$this->assertArrayHasKey("customerAccountManagementV1", $decodedWsdl);
$this->assertArrayHasKey("integrationAdminTokenServiceV1", $decodedWsdl);
}
}

0 comments on commit cedeca0

Please sign in to comment.