We're using Magento 2.1.7
We have a REST Enpoint:
<route method="PUT" url="/V1/our-module/:sku/blacklist/:blacklist_id">
<service class="OurVendor\OurModule\Api\BlacklistManagementInterface" method="save"/>
<resources>
<resource ref="Magento_Catalog::products"/>
</resources>
</route>
The method signature looks like this:
/**
* @param string $sku
* @param \OurVendor\OurModule\Api\Data\OptionBlacklistInterface[] $blacklist
*
* @return \OurVendor\OurModule\Api\Data\OptionBlacklistInterface[]
*
* @throws \Magento\Framework\Exception\CouldNotSaveException
* @throws \Magento\Framework\Exception\InputException
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function save($sku, array $blacklist);
The code is then implementation of the save function is executed. We calling the API via swagger/postman/....
Response contains:
"message": "Class \\OurVendor\\OurModule\\Api\\Data\\OptionBlacklistInterface[] does not exist",
The crucial code segments seems to bee:
We currently use a plugin to fix this issue
public function beforeGetMethodsMap(MethodsMap $subject, $interfaceName)
{
if (substr($interfaceName, -2) === '[]') {
$interfaceName = substr($interfaceName, 0, -2);
}
return [$interfaceName];
}
There is such logic already: https://github.com/magento/magento2/blame/2.1.7/lib/internal/Magento/Framework/Reflection/TypeProcessor.php#L558
Is there a mistake in regular expression or this code is not used in case of PUT?
@orlangur I can check if this code gets called, but I haven't seen it before.
I asume it's not called when using PUT
They Method gets indeed called!
It will return "OurVendorOurModuleApiDataOptionBlacklistInterface[]" in line 561!
Hmm, have no idea how it works for many core data interfaces then which use \ClassName[] notation a lot.
From 563 you can see that this method always returns such format
return "{$type}[]";
We need to try any core API consuming such parameter type in action to see the execution flow and why it works.
@philippsander thank you for your bug report.
We've created internal ticket MAGETWO-75356 to track progress on the issue.
I'm having the same problem when trying to use the MagentoFrameworkWebapiServiceOutputProcessor to process an invoice to fetch it's dataModel.
Calling:
$invoiceOutputData = $this->serviceOutputProcessor->process(
$invoice,
'Magento\Sales\Api\InvoiceRepositoryInterface',
'get'
);
Will produce an exception:
Class \Magento\Sales\Api\Data\InvoiceItemInterface[] does not exist
Hi @engcom-backlog-nazar. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if your want to validate it one more time, please, go though the following instruction:
Component: XXXXX label(s) to the ticket, indicating the components it may be related to.[ ] 2. Verify that the issue is reproducible on 2.3-develop branchDetails
- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!
[ ] 3. Verify that the issue is reproducible on 2.2-develop branch. Details
- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x
[ ] 4. If the issue is not relevant or is not reproducible any more, feel free to close it.
HI @philippsander thank you for you report, this issue has already fixed in 2.3-develop branch and available on 2.3.0 release.
Still reproducable in Magento 2.3.3 :(
/**
* @param string $someString
* @param ClassItems[] $items
*
* @return void
* @throws NoSuchEntityException
*/
public function execute(string $someString, array $items): void;
<route url="/V1/params/:someString/items" method="POST">
<service class="Neusta\Vendor\Api\AddItems" method="execute"/>
<resources>
<resource ref="anonymous" />
</resources>
</route>
If i declare as PUT i got an error like this: Class ClassItems[] not found...; if i declare as POST everything is fine.
Hi @engcom-Charlie. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.
[ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.3-develop branchDetails
- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!
[ ] 5. Add label Issue: Confirmed once verification is complete.
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hello @ulftietze
We are not able to reproduce this issue on the latest Magento 2.3-develop(merged code from 2.3.3).
Manual testing scenario:
/**
* @param string $someString
* @param ClassItems[] $items
*
* @return void
* @throws NoSuchEntityException
*/
public function execute(string $someString, array $items): void;
but i change method from "POST" to "PUT"
<route url="/V1/params/:someString/items" method="PUT">
<service class="Neusta\Vendor\Api\AddItems" method="execute"/>
<resources>
<resource ref="anonymous" />
</resources>
</route>
Actual result:
response = void

So this issue should be closed.