-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serializer issue. #60
Comments
Hi there, To go in production with this vendor, our team was forced to fork the repo and patch it by ourself. |
I can confirm I'm also seeing this and would greatly appreciate if the PR in question could be merged. Thanks. |
Hi @acooper4960, do someone at DocuSign plans to release a fix shortly? It would be greatly appreciated. ICYMI, a fork of DocuSign repository by @trickeyone seems to do the trick. |
For those stuck with the bug, you may also consider extending use DocuSign\eSign\ApiClient;
class ApiClientFixer extends ApiClient
{
public function __construct(\DocuSign\eSign\Configuration $config = null)
{
parent::__construct($config);
$this->serializer = new ObjectSerializerFixer();
}
} use DocuSign\eSign\Configuration;
use DocuSign\eSign\ObjectSerializer;
class ObjectSerializerFixer extends ObjectSerializer
{
/**
* @param mixed $data
* @param string $class
* @param null $httpHeaders
*
* @return array|mixed|object|\SplFileObject|null
*
* @throws \Exception
*/
public static function deserialize($data, $class, $httpHeaders = null)
{
if (null === $data) {
return null;
} elseif (substr($class, 0, 4) === 'map[') { // for associative array e.g. map[string,int]
$inner = substr($class, 4, -1);
$deserialized = [];
if (strrpos($inner, ",") !== false) {
$subClass_array = explode(',', $inner, 2);
$subClass = $subClass_array[1];
foreach ($data as $key => $value) {
$deserialized[$key] = self::deserialize($value, $subClass, null);
}
}
return $deserialized;
} elseif (strcasecmp(substr($class, -2), '[]') === 0) {
$subClass = substr($class, 0, -2);
$values = [];
foreach ($data as $key => $value) {
$values[] = self::deserialize($value, $subClass, null);
}
return $values;
} elseif ($class === 'object') {
settype($data, 'array');
return $data;
} elseif ($class === '\DateTime') {
// Some API's return an invalid, empty string as a
// date-time property. DateTime::__construct() will return
// the current time for empty input which is probably not
// what is meant. The invalid empty string is probably to
// be interpreted as a missing field/value. Let's handle
// this graceful.
if (!empty($data)) {
return new \DateTime($data);
} else {
return null;
}
} elseif (in_array($class, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) {
settype($data, $class);
return $data;
} elseif ($class === '\SplFileObject') {
// determine file name
if (array_key_exists('Content-Disposition', $httpHeaders) &&
preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) {
$filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . sanitizeFilename($match[1]);
} else {
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');
}
$deserialized = new \SplFileObject($filename, "w");
$byte_written = $deserialized->fwrite($data);
if (Configuration::getDefaultConfiguration()->getDebug()) {
error_log("[DEBUG] Written $byte_written byte to $filename. Please move the file to a proper folder or delete the temp file after processing.".PHP_EOL, 3, Configuration::getDefaultConfiguration()->getDebugFile());
}
return $deserialized;
} else {
$class = self::fixClassNamespacing($class);
// 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 = '\DocuSign\eSign\Model\\' . $data->{$discriminator};
if (is_subclass_of($subclass, $class)) {
$class = $subclass;
}
}
$instance = new $class();
foreach ($instance::swaggerTypes() as $property => $type) {
$propertySetter = $instance::setters()[$property];
if (!isset($propertySetter) || !isset($data->{$instance::attributeMap()[$property]})) {
continue;
}
$propertyValue = $data->{$instance::attributeMap()[$property]};
if (isset($propertyValue)) {
$instance->$propertySetter(self::deserialize($propertyValue, $type, null));
}
}
return $instance;
}
}
/**
* Fix issue with loading non-namespaced types
* @see https://github.com/trickeyone/docusign-php-client/commit/cc3483c44c301ad7c0d42e41094e70dfde5f68ef
*/
private static function fixClassNamespacing(string $class): string
{
if (in_array($class, ['Number', 'Date'])) {
return '\DocuSign\eSign\Model\\' . $class;
}
return $class;
}
} |
Thank you for the problem report. And please accept my apologies for the very slow DocuSign staff replies on this issue. We have reorganized so we can provide faster response. This issue now has internal bug report # DCM-3210 We are working on it. |
Is this fixed? |
@larrykluger Almost a year later -- is there really any attention here? |
Hi, our engineering group reports that this has been fixed in v5.1. Can you verify? |
@larrykluger Can you point to a commit that addresses this? There is no activity on related issues/PRs, and no mention of this in release notes. |
Hi @benburleson , To install it: |
No reply for since Mar 26. Closing. Please comment to re-open if there's still an issue. Thank you, Larry |
When i try to call
$templateApi = new \DocuSign\eSign\Api\TemplatesApi($apiClient);
$template = $templateApi->get($accountId, '[id-template]');
I've got this error
Fatal error: Class 'Number' not found in _vendors/docusign/esign-client/src/ObjectSerializer.php on line 274
Looks like the serializer is waiting for number and not Number. (ObjectSerializer.php line 254)
Edit : Pull request #46 and #41 try to fix that issue already.
Duplicate issue with #48
The text was updated successfully, but these errors were encountered: