“Undefined index: interface” error from Magento 2 swagger webapi
Question
I'm getting the following error when loading the swagger routes:
Undefined index: interface in /mnt/c/develop/php/mage2/vendor/magento/module-webapi/Model/AbstractSchemaGenerator.php on line 156 {"exception":"[object] (Exception(code: 0)
I'm trying to add my own swagger endpoint. My webapi.xml
looks like:
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
<route url="/V1/my/custom/route" method="GET">
<service class="Vendor\Module\Api\MyInterface" method="myMethod"/>
<resources>
<resource ref="anonymous" />
</resources>
</route>
What does this error mean?
La solution
The interface you defined, Vendor\Module\Api\MyInterface
, doesn't have a method named myMethod
.
Add one, clear your cache, and you should be good!
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange