diff --git a/app/code/Magento/Webapi/Model/AbstractSchemaGenerator.php b/app/code/Magento/Webapi/Model/AbstractSchemaGenerator.php index 18920a66c173d..973b5121fd969 100644 --- a/app/code/Magento/Webapi/Model/AbstractSchemaGenerator.php +++ b/app/code/Magento/Webapi/Model/AbstractSchemaGenerator.php @@ -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()); } /** diff --git a/app/code/Magento/Webapi/Model/Rest/Swagger/Generator.php b/app/code/Magento/Webapi/Model/Rest/Swagger/Generator.php index c3658f17ef53e..5771da069ecbf 100644 --- a/app/code/Magento/Webapi/Model/Rest/Swagger/Generator.php +++ b/app/code/Magento/Webapi/Model/Rest/Swagger/Generator.php @@ -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 { @@ -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; + } } diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Controller/SoapTest.php b/dev/tests/integration/testsuite/Magento/Webapi/Controller/SoapTest.php new file mode 100644 index 0000000000000..01f47a22470f6 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Webapi/Controller/SoapTest.php @@ -0,0 +1,39 @@ +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); + } +}