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"/>
        <resource ref="anonymous" />

What does this error mean?


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!

| improve this answer | |

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.