3

I trying this url http://192.168.1.67/isac/swagger but I got this error below

 500 : {"message":"Internal Error. Details are available in Magento log file. 
    Report ID: webapi-5bfe5e3ac4100"} http://192.168.1.67/isac/rest/default/schema?services=all

When I checked exception log file I got this below information.

[2018-11-28 09:24:07] main.CRITICAL: LogicException: Class "array" does not exist. Please note that namespace must be specified. in /var/www/html/isac/vendor/magento/framework/Reflection/TypeProcessor.php:156
Stack trace:
#0 /var/www/html/isac/vendor/magento/module-webapi/Model/Config/ClassReflector.php(103): Magento\Framework\Reflection\TypeProcessor->register('array')
#1 /var/www/html/isac/vendor/magento/module-webapi/Model/Config/ClassReflector.php(72): Magento\Webapi\Model\Config\ClassReflector->extractMethodData(Object(Zend\Code\Reflection\MethodReflection))
#2 /var/www/html/isac/vendor/magento/module-webapi/Model/ServiceMetadata.php(119): Magento\Webapi\Model\Config\ClassReflector->reflectClassMethods('Altius\\Customap...', Array)
#3 /var/www/html/isac/vendor/magento/module-webapi/Model/ServiceMetadata.php(148): Magento\Webapi\Model\ServiceMetadata->initServicesMetadata()
#4 /var/www/html/isac/vendor/magento/module-webapi/Model/Rest/Swagger/Generator.php(913): Magento\Webapi\Model\ServiceMetadata->getServicesConfig()
#5 /var/www/html/isac/vendor/magento/module-webapi/Controller/Rest.php(278): Magento\Webapi\Model\Rest\Swagger\Generator->getListOfServices()
#6 /var/www/html/isac/vendor/magento/module-webapi/Controller/Rest.php(214): Magento\Webapi\Controller\Rest->processSchemaRequest()
#7 /var/www/html/isac/vendor/magento/framework/Interception/Interceptor.php(146): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))
#8 /var/www/html/isac/var/generation/Magento/Webapi/Controller/Rest/Interceptor.php(39): Magento\Webapi\Controller\Rest\Interceptor->___callPlugins('dispatch', Array, Array)
#9 /var/www/html/isac/vendor/magento/framework/App/Http.php(135): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#10 /var/www/html/isac/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#11 /var/www/html/isac/index.php(40): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#12 {main}

Next Exception: Report ID: webapi-5bfe5eb799b72; Message: Class "array" does not exist. Please note that namespace must be specified. in /var/www/html/isac/vendor/magento/framework/Webapi/ErrorProcessor.php:195
Stack trace:
#0 /var/www/html/isac/vendor/magento/framework/Webapi/ErrorProcessor.php(139): Magento\Framework\Webapi\ErrorProcessor->_critical(Object(LogicException))
#1 /var/www/html/isac/vendor/magento/module-webapi/Controller/Rest.php(219): Magento\Framework\Webapi\ErrorProcessor->maskException(Object(LogicException))
#2 /var/www/html/isac/vendor/magento/framework/Interception/Interceptor.php(146): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))
#3 /var/www/html/isac/var/generation/Magento/Webapi/Controller/Rest/Interceptor.php(39): Magento\Webapi\Controller\Rest\Interceptor->___callPlugins('dispatch', Array, Array)
#4 /var/www/html/isac/vendor/magento/framework/App/Http.php(135): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#5 /var/www/html/isac/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#6 /var/www/html/isac/index.php(40): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#7 {main} [] []

It's very confusing and like toughest puzzle game. How to resolve this and get api from swagger?

3 Answers 3

3

This error due to undefined return type. you cannot defined array as return type. If I am not wrong then you want to return it as associative array so check below code.

You need to define it like below

/**
 * Get Slides
 *
 * @return \Vendor\Module\Api\Data\KeyValueInterface[]  
 */
public function getSlides();

Please Check, in your case there will be array as return type in place of \Vendor\Module\Api\Data\KeyValueInterface.

KeyValueInterface.php

<?php
namespace Vendor\Module\Api\Data;

/**
 * KeyValueInterface.
 * @api
 */
interface KeyValueInterface
{
    const LABEL_KEY = "key";
    const LABEL_VALUE = "value";

    /**
     * Get key
     * 
     * @return string
     */
    public function getKey();

    /**
     * Set key
     * 
     * @return string
     */
    public function setKey($key);

    /**
     * Get value
     * 
     * @return string
     */
    public function getValue();

    /**
     * Set value
     * 
     * @param string $value
     * @return $this
     */
    public function setValue($value);
}

Let me know if you need further help.

1
2

You have a custom api module Altius_Customap which is creating the issue and you have to remove or disable it and check it.

0

Set a breakpoint in your debugger at the try/catch that throws a \LogicException in \Magento\Framework\Reflection\TypeProcessor::register. There you can see the offending class name and method. In my case it was coming from the module Afterpay_Payment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.