Im using Magento 2.1.3 and PHP 7.0.8.

I would like to test some Magentos 2 import api.

When I'm trying to connect to swagger by http://localhost/swagger error 500 is received:
enter image description here

I'm also trying to connect to http://localhost/rest/default/schema?services=all
and return:
enter image description here

I am worried about that it doesn't works.
However I am able to connect via rest to eg. http://localhost/index.php/rest/V1/integration/admin/token and get user token.

I also tried to install https://www.npmjs.com/package/magento2-swagger

root@2d426841549e:/var/www/html# npm install magento2-swagger --save
npm WARN saveError ENOENT: no such file or directory, open '/var/www/html/package.json'
`-- magento2-swagger@0.0.8  

npm WARN enoent ENOENT: no such file or directory, open '/var/www/html/package.json'
npm WARN html No description
npm WARN html No repository field.
npm WARN html No README data
npm WARN html No license field.  
  • I think you have issue in you custom module. Dec 3, 2018 at 9:53

3 Answers 3


Swagger try to generate documentation from class annotation.

You use array as API type.

It is not support by Magento swagger implementation.

You can try to use anyType as a workaround or create your custom type.

Reference :


Allowed base type :

 * Normalized type constants
const NORMALIZED_STRING_TYPE = 'string';
const NORMALIZED_INT_TYPE = 'int';
const NORMALIZED_FLOAT_TYPE = 'float';
const NORMALIZED_DOUBLE_TYPE = 'double';
const NORMALIZED_BOOLEAN_TYPE = 'boolean';
const NORMALIZED_ANY_TYPE = 'anyType';

You can also add array type but you need to do some custom development.

If your website is different than default, you will need to change the form URL hidden value to match your website.

  • Is there any easy way to find api's location using array type? I can not find it manually :c Feb 20, 2017 at 9:05
  • Try to search array[] in API folders ? Did you create custom API ? Do you install custom modules ? Search there. Feb 20, 2017 at 9:15
  • Add log inside the error function near \Magento\Webapi\Model\Config\ClassReflector::extractMethodData and \Magento\Webapi\Model\Config\ClassReflector::reflectClassMethods to log which class is responsible of the error. Feb 20, 2017 at 9:16
  • oh crap. There are a lot of array type in Core Magento Api... Feb 20, 2017 at 9:29
  • I do not think so! I do not have to change Magento core to make swagger works. Make sure to debug the class, to see exactly what is the class responsible of the error. Feb 20, 2017 at 10:47

looks like some of your api declare parameter/return type as array[] that not supported by Magento.

Please fix error and swagger will start to work



  • Delete vendor, delete composer.lock.
  • do composer install, setup:upgrade, setup:di:compile, indexer:reindex

And it start works

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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