Closed
Description
After refactoring which was done in 735024a, the issue #24116 is come back.
Original report: tap
Preconditions (*)
- Magento 2.3.1 & 2.3-develop
- Created and enabled custom module 'DreamVendor\DreamModule'.
Steps to reproduce (*)
- Create php interface which will be used for the endpoint. E.g.
namespace DreamVendor\DreamModule\Api;
use Magento\Framework\Api\Search\SearchResultInterface;
/**
* My Custom Endpoint API.
*/
interface MyCustomEndpointInterface
{
/**
* Get some awesome stuff!
*
* @param \DreamVendor\DreamModule\Api\Data\SearchRequestInterface $searchRequest
*
* @return \Magento\Framework\Api\Search\SearchResultInterface
*/
public function execute(\DreamVendor\DreamModule\Api\Data\SearchRequestInterface $searchRequest): SearchResultInterface;
}
- Create SearchRequestInterface. Make it extensible with extension attributes.
namespace DreamVendor\DreamModule\Api\Data;
use Magento\Framework\Api\ExtensibleDataInterface;
/**
* Search Request Data Object.
*/
interface SearchRequestInterface extends ExtensibleDataInterface
{
/**
* Get Extension Attributes.
*
* @return \DreamVendor\DreamModule\Api\Data\SearchRequestExtensionInterface|null
*/
public function getExtensionAttributes(): ?\DreamVendor\DreamModule\Api\Data\SearchRequestExtensionInterface;
/**
* Set Extension Attributes.
*
* @param \DreamVendor\DreamModule\Api\Data\SearchRequestExtensionInterface|null $extension
*/
public function setExtensionAttributes(?\DreamVendor\DreamModule\Api\Data\SearchRequestExtensionInterface $extension): void;
- Declare your endpoint via
webapi.xml
inetc
folder of your module.
<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-endpoint" method="GET">
<service class="DreamVendor\DreamModule\Api\MyCustomEndpointInterface" method="execute"/>
<resources>
<resource ref="anonymous" />
</resources>
</route>
</routes>
- Flush caches.
- Try to generate schema. Go to
your.website.com/swagger/
.
Expected result (*)
- The page has been opened.
- You can see your new endpoint.
Actual result (*)
- You can see message like
Failed to load API definition. Internal Server Error http://magento2.local/rest/all/schema?services=all
- Error message
Warning: array_merge() expects at least 1 parameter, 0 given in \/var\/www\/html\/app\/code\/Magento\/Webapi\/Model\/Rest\/Swagger\/Generator.php:762
Metadata
Metadata
Assignees
Labels
Use with concrete module component label E.g. "Component: Api" + "Catalog"USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just CatalogThe issue has been fixed in 2.3 release lineGate 2 Passed. Manual verification of the issue description passedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 1 Passed. Automatic verification of issue format passedGate 4. Acknowledged. Issue is added to backlog and ready for developmentThe issue has been reproduced on latest 2.3 release