add debug switch to print out downloaded file info

This commit is contained in:
wing328
2016-05-14 17:11:48 +08:00
parent 1939ce8e91
commit 0b7d0c34af
23 changed files with 468 additions and 364 deletions

View File

@@ -1,6 +1,6 @@
<?php
/**
* ObjectSerializer
* ObjectSerializer
*
* PHP version 5
*
@@ -37,7 +37,7 @@ namespace Swagger\Client;
* ObjectSerializer Class Doc Comment
*
* @category Class
* @package Swagger\Client
* @package Swagger\Client
* @author http://github.com/swagger-api/swagger-codegen
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
* @link https://github.com/swagger-api/swagger-codegen
@@ -79,7 +79,7 @@ class ObjectSerializer
/**
* Sanitize filename by removing path.
* e.g. ../../sun.gif becomes sun.gif
* e.g. ../../sun.gif becomes sun.gif
*
* @param string $filename filename to be sanitized
*
@@ -268,9 +268,13 @@ class ObjectSerializer
}
$deserialized = new \SplFileObject($filename, "w");
$byte_written = $deserialized->fwrite($data);
error_log("[INFO] Written $byte_written byte to $filename. Please move the file to a proper folder or delete the temp file after processing.\n", 3, Configuration::getDefaultConfiguration()->getDebugFile());
return $deserialized;
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.\n", 3, Configuration::getDefaultConfiguration()->getDebugFile());
}
return $deserialized;
} else {
// If a discriminator is defined and points to a valid subclass, use it.
if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) {
@@ -282,11 +286,11 @@ class ObjectSerializer
$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, $discriminator));