forked from loafle/openapi-generator-original
temporary folder setting
This commit is contained in:
parent
7f31da734d
commit
259b31ccd4
@ -64,9 +64,9 @@ class ApiClient {
|
||||
* @param string $apiKey name of apikey
|
||||
* @return string API key with the prefix
|
||||
*/
|
||||
public function getApiKeyWithPrefix($apiKey) {
|
||||
$prefix = $this->config->getApiKeyPrefix($apiKey);
|
||||
$apiKey = $this->config->getApiKey($apiKey);
|
||||
public function getApiKeyWithPrefix($apiKeyIdentifier) {
|
||||
$prefix = $this->config->getApiKeyPrefix($apiKeyIdentifier);
|
||||
$apiKey = $this->config->getApiKey($apiKeyIdentifier);
|
||||
|
||||
if (!isset($apiKey)) {
|
||||
return null;
|
||||
|
@ -135,7 +135,7 @@ class ObjectSerializer {
|
||||
$deserialized = $data;
|
||||
} elseif ($class === '\SplFileObject') {
|
||||
# determine temp folder path
|
||||
if (!isset(Configuration::$tempFolderPath) || '' === Configuration::$tempFolderPath) {
|
||||
if (!isset(Configuration::getDefaultConfig->$tempFolderPath) || '' === Configuration::$tempFolderPath) {
|
||||
$tmpFolderPath = sys_get_temp_dir();
|
||||
} else {
|
||||
$tmpFolderPath = Configuration::tempFolderPath;
|
||||
|
@ -67,8 +67,8 @@ class {{classname}} {
|
||||
*
|
||||
* {{{summary}}}
|
||||
*
|
||||
{{#allParams}} * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional){{/required}}
|
||||
{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
||||
{{#allParams}} * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional){{/required}}
|
||||
{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
||||
* @throws \{{invokerPackage}}\ApiException on non-2xx response
|
||||
*/
|
||||
public function {{nickname}}({{#allParams}}${{paramName}}{{^required}}=null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
|
||||
@ -76,6 +76,7 @@ class {{classname}} {
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
if (${{paramName}} === null) {
|
||||
throw new \InvalidArgumentException('Missing the required parameter ${{paramName}} when calling {{nickname}}');
|
||||
>>>>>>> temporary folder setting
|
||||
}
|
||||
{{/required}}{{/allParams}}
|
||||
|
||||
@ -152,8 +153,7 @@ class {{classname}} {
|
||||
return null;
|
||||
}
|
||||
|
||||
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'{{returnType}}');
|
||||
return $responseObject;
|
||||
return $this->apiClient->getSerializer()->deserialize($response,'{{returnType}}');
|
||||
{{/returnType}}
|
||||
}
|
||||
{{/operation}}
|
||||
|
@ -260,12 +260,15 @@ class Configuration {
|
||||
return self::$defaultConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Configuration $config
|
||||
*/
|
||||
public static function setDefaultConfiguration(Configuration $config) {
|
||||
self::$defaultConfiguration = $config;
|
||||
}
|
||||
|
||||
/*
|
||||
* return the report for debuggin
|
||||
* return the report for debugging
|
||||
*/
|
||||
public static function toDebugReport() {
|
||||
$report = "PHP SDK ({{invokerPackage}}) Debug Report:\n";
|
||||
|
@ -235,7 +235,7 @@
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Pet"
|
||||
"type": "file"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
|
@ -249,8 +249,7 @@ class PetApi {
|
||||
return null;
|
||||
}
|
||||
|
||||
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\Pet[]');
|
||||
return $responseObject;
|
||||
return $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\Pet[]');
|
||||
|
||||
}
|
||||
|
||||
@ -320,8 +319,7 @@ class PetApi {
|
||||
return null;
|
||||
}
|
||||
|
||||
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\Pet[]');
|
||||
return $responseObject;
|
||||
return $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\Pet[]');
|
||||
|
||||
}
|
||||
|
||||
@ -331,7 +329,7 @@ class PetApi {
|
||||
* Find pet by ID
|
||||
*
|
||||
* @param int $pet_id ID of pet that needs to be fetched (required)
|
||||
* @return \Swagger\Client\Model\Pet
|
||||
* @return \SplFileObject
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function getPetById($pet_id) {
|
||||
@ -389,11 +387,11 @@ class PetApi {
|
||||
try {
|
||||
list($response, $httpHeader) = $this->apiClient->callApi($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, '\Swagger\Client\Model\Pet');
|
||||
$headerParams, '\SplFileObject');
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 200:
|
||||
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\Pet', $httpHeader);
|
||||
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\SplFileObject', $httpHeader);
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
}
|
||||
@ -405,8 +403,7 @@ class PetApi {
|
||||
return null;
|
||||
}
|
||||
|
||||
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\Pet');
|
||||
return $responseObject;
|
||||
return $this->apiClient->getSerializer()->deserialize($response,'\SplFileObject');
|
||||
|
||||
}
|
||||
|
||||
|
@ -127,8 +127,7 @@ class StoreApi {
|
||||
return null;
|
||||
}
|
||||
|
||||
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'map[string,int]');
|
||||
return $responseObject;
|
||||
return $this->apiClient->getSerializer()->deserialize($response,'map[string,int]');
|
||||
|
||||
}
|
||||
|
||||
@ -196,8 +195,7 @@ class StoreApi {
|
||||
return null;
|
||||
}
|
||||
|
||||
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\Order');
|
||||
return $responseObject;
|
||||
return $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\Order');
|
||||
|
||||
}
|
||||
|
||||
@ -271,8 +269,7 @@ class StoreApi {
|
||||
return null;
|
||||
}
|
||||
|
||||
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\Order');
|
||||
return $responseObject;
|
||||
return $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\Order');
|
||||
|
||||
}
|
||||
|
||||
|
@ -302,8 +302,7 @@ class UserApi {
|
||||
return null;
|
||||
}
|
||||
|
||||
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'string');
|
||||
return $responseObject;
|
||||
return $this->apiClient->getSerializer()->deserialize($response,'string');
|
||||
|
||||
}
|
||||
|
||||
@ -430,8 +429,7 @@ class UserApi {
|
||||
return null;
|
||||
}
|
||||
|
||||
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\User');
|
||||
return $responseObject;
|
||||
return $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\User');
|
||||
|
||||
}
|
||||
|
||||
|
@ -64,9 +64,9 @@ class ApiClient {
|
||||
* @param string $apiKey name of apikey
|
||||
* @return string API key with the prefix
|
||||
*/
|
||||
public function getApiKeyWithPrefix($apiKey) {
|
||||
$prefix = $this->config->getApiKeyPrefix($apiKey);
|
||||
$apiKey = $this->config->getApiKey($apiKey);
|
||||
public function getApiKeyWithPrefix($apiKeyIdentifier) {
|
||||
$prefix = $this->config->getApiKeyPrefix($apiKeyIdentifier);
|
||||
$apiKey = $this->config->getApiKey($apiKeyIdentifier);
|
||||
|
||||
if (!isset($apiKey)) {
|
||||
return null;
|
||||
|
@ -51,6 +51,17 @@ class Configuration {
|
||||
/** @var string Debug file location (log to STDOUT by default) */
|
||||
protected $debugFile = 'php://output';
|
||||
|
||||
/** @var string Debug file location (log to STDOUT by default) */
|
||||
protected $tempFolderPath;
|
||||
|
||||
/**
|
||||
* @param string $tempFolderPath
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->tempFolderPath = sys_get_temp_dir();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
@ -249,6 +260,22 @@ class Configuration {
|
||||
return $this->debugFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $debugFile
|
||||
* @return Configuration
|
||||
*/
|
||||
public function setTempFolderPath($tempFolderPath) {
|
||||
$this->tempFolderPath = $tempFolderPath;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getTempFolderPath() {
|
||||
return $this->tempFolderPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Configuration
|
||||
*/
|
||||
@ -260,12 +287,15 @@ class Configuration {
|
||||
return self::$defaultConfiguration;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Configuration $config
|
||||
*/
|
||||
public static function setDefaultConfiguration(Configuration $config) {
|
||||
self::$defaultConfiguration = $config;
|
||||
}
|
||||
|
||||
/*
|
||||
* return the report for debuggin
|
||||
* return the report for debugging
|
||||
*/
|
||||
public static function toDebugReport() {
|
||||
$report = "PHP SDK (Swagger\Client) Debug Report:\n";
|
||||
|
@ -135,16 +135,14 @@ class ObjectSerializer {
|
||||
$deserialized = $data;
|
||||
} elseif ($class === '\SplFileObject') {
|
||||
# determine temp folder path
|
||||
if (!isset(Configuration::$tempFolderPath) || '' === Configuration::$tempFolderPath) {
|
||||
$tmpFolderPath = sys_get_temp_dir();
|
||||
} else {
|
||||
$tmpFolderPath = Configuration::tempFolderPath;
|
||||
}
|
||||
$tmpFolderPath = Configuration::getDefaultConfiguration()->getTempFolderPath();
|
||||
print_r($tmpFolderPath);
|
||||
|
||||
# determine file name
|
||||
if (preg_match('/Content-Disposition: inline; filename=(.*)/i', $httpHeader, $match)) {
|
||||
if (preg_match('/Content-Disposition: inline; filename=(.*)$/i', $httpHeader, $match)) {
|
||||
$filename = $tmpFolderPath.$match[1];
|
||||
} else {
|
||||
print_r($tmpFolderPath);
|
||||
$filename = tempnam($tmpFolderPath, '');
|
||||
}
|
||||
$deserialized = new \SplFileObject($filename, "w");
|
||||
|
@ -12,12 +12,15 @@ require_once(__DIR__ . '/SwaggerClient-php/autoload.php');
|
||||
// to enable logging
|
||||
//SwaggerClient\Configuration::$debug = true;
|
||||
//SwaggerClient\Configuration::$debug_file = '/var/tmp/php_debug.log';
|
||||
Swagger\Client\Configuration::getDefaultConfiguration()->setTempFolderPath('/var/tmp/php/');
|
||||
|
||||
$petId = 10005; // ID of pet that needs to be fetched
|
||||
try {
|
||||
// get pet by id
|
||||
//$pet_api = new SwaggerClient\PetAPI($api_client);
|
||||
$pet_api = new Swagger\Client\Api\PetAPI();
|
||||
$pet_api->getApiClient()->getConfig()->setTempFolderPath('/var/tmp/php/');
|
||||
print_r($pet_api->getApiClient()->getConfig()->getTempFolderPath());
|
||||
// test default header
|
||||
//$pet_api->getApiClient()->addDefaultHeader("TEST_API_KEY", "09182sdkanafndsl903");
|
||||
// return Pet (model)
|
||||
|
Loading…
x
Reference in New Issue
Block a user