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?
Best Answer
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
Please Check, in your case there will be array as return type in place of \Vendor\Module\Api\Data\KeyValueInterface.
KeyValueInterface.php
Let me know if you need further help.