1

I had upgraded the magento version to 2.3.5 after that swagger is not working in my setup

Image Reference : enter image description here

To debug the i click invalid button it shows

{"schemaValidationMessages":[{"level":"error","message":"Can't read from file http://My Domain/rest/all/schema?services=all"}]}

The below errors i got in the debug.log

[2020-06-30 08:50:34] main.ERROR: Unable to resolve the source file for 'frontend/Vendor/child-theme/en_US/Magento_Swagger/swagger-ui/js/swagger-ui-bundle.js.map' [] []
[2020-06-30 08:50:34] main.CRITICAL: Unable to resolve the source file for 'frontend/Vendor/child-theme/en_US/Magento_Swagger/swagger-ui/js/swagger-ui-bundle.js.map' [] []
[2020-06-30 08:50:34] main.ERROR: Unable to resolve the source file for 'frontend/Vendor/child-theme/en_US/Magento_Swagger/swagger-ui/css/swagger-ui.css.map' [] []
[2020-06-30 08:50:34] main.CRITICAL: Unable to resolve the source file for 'frontend/Vendor/child-theme/en_US/Magento_Swagger/swagger-ui/css/swagger-ui.css.map' [] []
[2020-06-30 08:50:34] main.ERROR: Unable to resolve the source file for 'frontend/Vendor/child-theme/en_US/Magento_Swagger/swagger-ui/js/swagger-ui-standalone-preset.js.map' [] []
[2020-06-30 08:50:34] main.CRITICAL: Unable to resolve the source file for 'frontend/Vendor/child-theme/en_US/Magento_Swagger/swagger-ui/js/swagger-ui-standalone-preset.js.map' [] []

I ran the below commands and tested

  1. bin/magento deploy:mode:set developer - (Set the store to developer mode)
  2. Removed the pub/static frontend and adminhtml
  3. php bin/magento setup:upgrade
  4. php bin/magento setup:static-content:deploy -f
  5. php bin/magento setup:di:compile
  6. chmod -R 777 root_file/*
5
  • 4
    give try to disable all the dot mailer modules. there is \Datetime error breaking SOAP 2.3.5 so swagger tool also. Run command php bin/magento module:disable --clear-static-content Dotdigitalgroup_Email Dotdigitalgroup_Chat Dotdigitalgroup_Enterprise
    – sandip
    Commented Jun 30, 2020 at 10:35
  • @sandip Yes the solution worked well but by disabling this there is any cons or side-effect is there?
    – Sabareesh
    Commented Jun 30, 2020 at 10:44
  • its vendor bundled extension comes with by default, if your system not using this then you can remove it from a composer or disable it - see this - devdocs.magento.com/extensions/vendor
    – sandip
    Commented Jun 30, 2020 at 10:52
  • No, the solution did not work for me.
    – Abid Malik
    Commented Jul 15, 2020 at 3:35
  • 1
    Thanks @sandip It's working for me as well
    – RAKESH ROY
    Commented Dec 12, 2020 at 16:45

3 Answers 3

7

There is a \Datetime error breaking SOAP 2.3.5 so it is affecting swagger tool. Run command below to resolve that issue.

php bin/magento module:disable --clear-static-content Dotdigitalgroup_Email Dotdigitalgroup_Chat Dotdigitalgroup_Enterprise

It may be possible other installed extensions may break swagger so have to debug on browser console level to check further.

NOTE: Only disable these modules if you do not need in your system or else if required then upgrade dotdigital modules because it may be the case that upgraded versions already have fix for that.

Reference Commit

2
  • 2
    its worked for me @Sabareesh you should accept this answer
    – matinict
    Commented Dec 22, 2020 at 3:49
  • 1
    You can also disable Dotdigitalgroup_Sms Commented Jun 9, 2021 at 11:41
0

This errors could be happened by phpdoc on function declarations.

Wrong

/**
* @param $id
**/
public function myFuncitonHere(){}

Right

/**
* @param int $id
**/
public function myFuncitonHere(){}

Swagger uses phpdocs as complement to assemble the service contract to webservices REST/SOAP, and the class (as in/out on function delaration) needs to be declared with full path in return / params phpdocs.

Wrong

/**
* @param MyInterface $myInterface
**/
public function myFuncitonHere(){}

Right

/**
* @param \MyVendor\MyModule\Api\Data\MyInterface $myInterface
**/
public function myFuncitonHere(){}
0

This error is throw because one of your apis declare. Try to remove your recently added api and try again, if you can get swagger now, it mean your api is wrong about syntax or structure.

Consider this post: https://meetanshi.com/blog/solved-failed-to-load-api-definition-in-magento-2-swagger/

To debug what is wrong you cant visit the url that is expose: https://magento.test/rest/all/schema?services=all

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.