-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Closed
Labels
Component: ApiUse with concrete module component label E.g. "Component: Api" + "Catalog"Use with concrete module component label E.g. "Component: Api" + "Catalog"Component: WebapiUse with concrete module component label E.g. "Component: Webapi" + "Catalog"Use with concrete module component label E.g. "Component: Webapi" + "Catalog"Fixed in 2.3.xThe issue has been fixed in 2.3 release lineThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passedProgress: PR CreatedIndicates that Pull Request has been created to fix issueIndicates that Pull Request has been created to fix issueReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseThe issue has been reproduced on latest 2.3 release
Description
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 Notice: Undefined index: parameters in Magento/Webapi/Model/Rest/Swagger/Generator.php on line 741
Metadata
Metadata
Assignees
Labels
Component: ApiUse with concrete module component label E.g. "Component: Api" + "Catalog"Use with concrete module component label E.g. "Component: Api" + "Catalog"Component: WebapiUse with concrete module component label E.g. "Component: Webapi" + "Catalog"Use with concrete module component label E.g. "Component: Webapi" + "Catalog"Fixed in 2.3.xThe issue has been fixed in 2.3 release lineThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedGate 1 Passed. Automatic verification of issue format passedProgress: PR CreatedIndicates that Pull Request has been created to fix issueIndicates that Pull Request has been created to fix issueReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseThe issue has been reproduced on latest 2.3 release