[documentcollector] Code generation: update services and models - #932
[documentcollector] Code generation: update services and models#932AdyenAutomationBot wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the PHP SDK generation for the Document Collector service, adding models like DefaultErrorResponseEntity, DocumentUploadResponse, and InvalidField, alongside the DocumentsApi service. The review feedback identifies three key issues in the generated code: the uploadCrossBorderInvoice method is missing its request body parameter, preventing document uploads; the ObjectSerializer uses an incorrect hardcoded namespace for polymorphic discriminator resolution; and calling settype on \SplFileObject will trigger a PHP warning.
| public function uploadCrossBorderInvoice(?array $requestOptions = null): \Adyen\Model\DocumentCollector\DocumentUploadResponse | ||
| { | ||
| $endpoint = $this->baseURL . "/crossBorderInvoices"; | ||
| $response = $this->requestHttp($endpoint, strtolower('POST'), null, $requestOptions); | ||
| return ObjectSerializer::deserialize($response, \Adyen\Model\DocumentCollector\DocumentUploadResponse::class); | ||
| } |
There was a problem hiding this comment.
The uploadCrossBorderInvoice method is missing the request body parameter. Currently, it passes null as the third argument to requestHttp, which means no document or payload is sent with the POST request. This makes it impossible to upload any invoice documents.
Please update the OpenAPI generator configuration or the spec to ensure the request body parameter (e.g., $documentUploadRequest or binary/multipart data) is correctly generated and passed to requestHttp.
| // If a discriminator is defined and points to a valid subclass, use it. | ||
| $discriminator = $class::DISCRIMINATOR; | ||
| if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) { | ||
| $subclass = '\Adyen\Model\\' . $data->{$discriminator}; |
There was a problem hiding this comment.
The discriminator subclass resolution is using the hardcoded namespace \Adyen\Model\ instead of the service-specific namespace \Adyen\Model\DocumentCollector\. This will cause subclass resolution to fail for polymorphic models because the classes are located under \Adyen\Model\DocumentCollector\.
$subclass = '\\Adyen\\Model\\DocumentCollector\\' . $data->{$discriminator};| if (in_array($class, ['\DateTime', '\SplFileObject', 'array', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) { | ||
| settype($data, $class); | ||
| return $data; | ||
| } |
There was a problem hiding this comment.
Calling settype($data, $class) when $class is \SplFileObject will trigger a PHP warning (settype(): Invalid type) because \SplFileObject is not a valid primitive type for settype(). Since \DateTime is already handled above, and \SplFileObject cannot be casted using settype, we should avoid calling settype for these class types.
if (in_array($class, ['\\DateTime', '\\SplFileObject', 'array', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) {
if ($class !== '\\DateTime' && $class !== '\\SplFileObject') {
settype($data, $class);
}
return $data;
}5ff6d47 to
b14c4ab
Compare
b14c4ab to
976244e
Compare
|



This PR contains the automated changes for the
documentcollectorservice.The commit history of this PR reflects the
adyen-openapicommits that have been applied.