Having some conflicts with a REST API I created. Trying to pass an array of strings; for example, "skus", but I get this error:
Invalid type for value: array. Expected type: string.
{vendor}/{module}/etc/webapi.xml
<?xml version="1.0"?>
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
<route url="/V1/to/api/rules/group/guest" method="POST">
<service class="{Vendor}\{Module}\Api\ProductCheckInterface" method="checkProductsAsGuest" />
<!--this will change later-->
<resources>
<resource ref="anonymous" />
</resources>
</route>
</routes>
{Vendor}/{Module}/Api/ProductCheckInterface
<?php
namespace {Vendor}\{Module}\Api;
interface ProductCheckInterface
{
/**
* Check a group of products with rules as a guest
*
* @param string[] $skus
* @return \{Vendor}\{Module}\Api\Data\ProductsActionInterface
*/
public function checkProductsAsGuest($skus);
}
{Vendor}/{Module}/Model/ProductCheck
<?php
namespace {Vendor}\{Module}\Model;
class ProductCheck implements \{Vendor}\{Module}\Api\ProductCheckInterface
{
/**
* {@inheritdoc}
*/
public function checkProductsAsGuest($skus)
{
// code
}
}
I've went around the web, but nothing helped.