cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2 Rest API Swagger

Magento 2 Rest API Swagger

I have installed Ipgramatech wishlist API, it's working but https://baseurl/swagger is giving me this error message.

 

500 : {"message":"Class \"array\" does not exist. Please note that namespace must be specified.","trace":"#0 \/var\/www\/html\/vendor\/magento\/module-webapi\/Model\/Config\/ClassReflector.php(103): Magento\\Framework\\Reflection\\TypeProcessor->register('array')\n#1 \/var\/www\/html\/vendor\/magento\/module-webapi\/Model\/Config\/ClassReflector.php(72): Magento\\Webapi\\Model\\Config\\ClassReflector->extractMethodData(Object(Zend\\Code\\Reflection\\MethodReflection))\n#2 \/var\/www\/html\/vendor\/magento\/module-webapi\/Model\/ServiceMetadata.php(127): Magento\\Webapi\\Model\\Config\\ClassReflector->reflectClassMethods('Ipragmatech\\\\Ipr...', Array)\n#3 \/var\/www\/html\/vendor\/magento\/module-webapi\/Model\/ServiceMetadata.php(156): Magento\\Webapi\\Model\\ServiceMetadata->initServicesMetadata()\n#4 \/var\/www\/html\/vendor\/magento\/module-webapi\/Model\/Rest\/Swagger\/Generator.php(914): Magento\\Webapi\\Model\\ServiceMetadata->getServicesConfig()\n#5 \/var\/www\/html\/vendor\/magento\/module-webapi\/Controller\/Rest.php(301): Magento\\Webapi\\Model\\Rest\\Swagger\\Generator->getListOfServices()\n#6 \/var\/www\/html\/vendor\/magento\/module-webapi\/Controller\/Rest.php(237): Magento\\Webapi\\Controller\\Rest->processSchemaRequest()\n#7 \/var\/www\/html\/vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magento\\Webapi\\Controller\\Rest->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#8 \/var\/www\/html\/vendor\/magento\/framework\/Interception\/Interceptor.php(138): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callParent('dispatch', Array)\n#9 \/var\/www\/html\/vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\\Webapi\\Controller\\Rest\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#10 \/var\/www\/html\/generated\/code\/Magento\/Webapi\/Controller\/Rest\/Interceptor.php(39): Magento\\Webapi\\Controller\\Rest\\Interceptor->___callPlugins('dispatch', Array, Array)\n#11 \/var\/www\/html\/vendor\/magento\/framework\/App\/Http.php(135): Magento\\Webapi\\Controller\\Rest\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#12 \/var\/www\/html\/generated\/code\/Magento\/Framework\/App\/Http\/Interceptor.php(24): Magento\\Framework\\App\\Http->launch()\n#13 \/var\/www\/html\/vendor\/magento\/framework\/App\/Bootstrap.php(256): Magento\\Framework\\App\\Http\\Interceptor->launch()\n#14 \/var\/www\/html\/pub\/index.php(37): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http\\Interceptor))\n#15 {main}"} https://buynatives.com/rest/all/schema?services=all
2 REPLIES 2

Re: Magento 2 Rest API Swagger

Hello @asimbyazid 

 

If you are miss matching parameters data type in DocBlock annotation of either interface or model you can face this error "Class “array” does not exist"

OR

If you are passing wrong parameter's data type in postman or API call you will face this 'Class “array” does not exist issue.

For more ref: https://magento.stackexchange.com/questions/231741/magento-2-webapi-gives-error-class-array-does-not...

Manish Mittal
https://www.manishmittal.com/

Re: Magento 2 Rest API Swagger

The type array is not valid. Please use  a valid scalar types include: mixed (or anyType), bool (or boolean), str (or string), integer (or int), float, and double.

For reference: