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