So for anyone running into this and totally at loss which module provider has not read the docs, here are a few tips&tricks.
I was confronted with the very annoying Internal Server Error above (magento 2.4.4) and found in the developer tools the underlying error
The "array" class doesn't exist and the namespace must be specified. Verify and try again.
This means someone has provided API functionality that returns a mixed or undefined array which is not allowed. In my case it was Addwish_Awext and I found this by adding the following logging to the above mentioned vendor\magento\module-webapi\Model\Config\ClassReflector.php
public function __construct(TypeProcessor $typeProcessor)
{
$this->_typeProcessor = $typeProcessor;
// adding my custom logger here:
$writer = new \Zend_Log_Writer_Stream(BP . '/var/log/customApi.log');
$this->myLogger = new \Zend_Log();
$this->myLogger->addWriter($writer);
}
public function extractMethodData(MethodReflection $method)
{
$methodData = ['documentation' => $this->extractMethodDescription($method), 'interface' => []];
/** @var \Laminas\Code\Reflection\ParameterReflection $parameter */
foreach ($method->getParameters() as $parameter) {
$parameterData = [
'type' => $this->_typeProcessor->register($this->_typeProcessor->getParamType($parameter)),
'required' => !$parameter->isOptional(),
'documentation' => $this->_typeProcessor->getParamDescription($parameter),
];
$methodName = $method->getName();
$typeIs = $this->_typeProcessor->register($this->_typeProcessor->getParamType($parameter));
// try to find something that returns array
$pos = strpos($typeIs, 'array');
if ($pos !== false) {
$this->myLogger->info('methodName: '.$methodName);
$this->myLogger->info(print_r($typeIs, true));
}
if ($parameter->isOptional()) {
$parameterData['default'] = $parameter->getDefaultValue();
}
$methodData['interface']['in']['parameters'][$parameter->getName()] = $parameterData;
}
$returnType = $this->_typeProcessor->getGetterReturnType($method);
// try to find something that returns array
$pos = strpos($returnType['type'], 'array');
if ($pos !== false) {
$this->myLogger->info('(getter) methodName:'.$method->getName());
$this->myLogger->info(print_r($method, true));
}
if ($returnType['type'] != 'void' && $returnType['type'] != 'null') {
....
Opening the CustomApi.log I found:
(getter) methodName: getState
Laminas\Code\Reflection\MethodReflection Object
(
[name] => getState
[class] => Addwish\Awext\Api\Service\StateInterface
)
Disabling the module, clear cache and do a full frontend deploy and... swagger works again.