forked from loafle/openapi-generator-original
Merge branch 'master' into new-sync-master-to-2.3.0
This commit is contained in:
@@ -58,9 +58,9 @@ class ApiException extends Exception
|
||||
* @param string $message Error message
|
||||
* @param int $code HTTP status code
|
||||
* @param string[]|null $responseHeaders HTTP response header
|
||||
* @param mixed $responseBody HTTP body of the server response either as Json or string
|
||||
* @param mixed $responseBody HTTP decoded body of the server response either as \stdClass or string
|
||||
*/
|
||||
public function __construct($message = "", $code = 0, array $responseHeaders = null, $responseBody = null)
|
||||
public function __construct($message = "", $code = 0, $responseHeaders = [], $responseBody = null)
|
||||
{
|
||||
parent::__construct($message, $code);
|
||||
$this->responseHeaders = $responseHeaders;
|
||||
@@ -80,7 +80,7 @@ class ApiException extends Exception
|
||||
/**
|
||||
* Gets the HTTP body of the server response either as Json or string
|
||||
*
|
||||
* @return mixed HTTP body of the server response either as Json or string
|
||||
* @return mixed HTTP body of the server response either as \stdClass or string
|
||||
*/
|
||||
public function getResponseBody()
|
||||
{
|
||||
|
||||
@@ -49,10 +49,16 @@ class ObjectSerializer
|
||||
return $data;
|
||||
} elseif (is_object($data)) {
|
||||
$values = [];
|
||||
foreach (array_keys($data::swaggerTypes()) as $property) {
|
||||
foreach ($data::swaggerTypes() as $property => $swaggerType) {
|
||||
$getter = $data::getters()[$property];
|
||||
if ($data->$getter() !== null) {
|
||||
$values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($data->$getter());
|
||||
$value = $data->$getter();
|
||||
if (method_exists($swaggerType, 'getAllowableEnumValues')
|
||||
&& !in_array($value, $swaggerType::getAllowableEnumValues())) {
|
||||
$imploded = implode("', '", $swaggerType::getAllowableEnumValues());
|
||||
throw new \InvalidArgumentException("Invalid value for enum '$swaggerType', must be one of: '$imploded'");
|
||||
}
|
||||
if ($value !== null) {
|
||||
$values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value);
|
||||
}
|
||||
}
|
||||
return (object)$values;
|
||||
@@ -259,6 +265,12 @@ class ObjectSerializer
|
||||
}
|
||||
|
||||
return $deserialized;
|
||||
} elseif (method_exists($class, 'getAllowableEnumValues')) {
|
||||
if (!in_array($data, $class::getAllowableEnumValues())) {
|
||||
$imploded = implode("', '", $class::getAllowableEnumValues());
|
||||
throw new \InvalidArgumentException("Invalid value for enum '$class', must be one of: '$imploded'");
|
||||
}
|
||||
return $data;
|
||||
} else {
|
||||
// If a discriminator is defined and points to a valid subclass, use it.
|
||||
$discriminator = $class::DISCRIMINATOR;
|
||||
|
||||
@@ -211,9 +211,6 @@ use \{{invokerPackage}}\ObjectSerializer;
|
||||
);
|
||||
}
|
||||
{{/pathParams}}
|
||||
// default format to json
|
||||
$resourcePath = str_replace("{format}", "json", $resourcePath);
|
||||
|
||||
{{#formParams}}
|
||||
// form params
|
||||
if (${{paramName}} !== null) {
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace {{invokerPackage}};
|
||||
*/
|
||||
class Configuration
|
||||
{
|
||||
private static $defaultConfiguration = null;
|
||||
private static $defaultConfiguration;
|
||||
|
||||
/**
|
||||
* Associate array to store API key(s)
|
||||
@@ -99,7 +99,7 @@ class Configuration
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $userAgent = "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{#artifactVersion}}{{{.}}}{{/artifactVersion}}{{^artifactVersion}}1.0.0{{/artifactVersion}}/php{{/httpUserAgent}}";
|
||||
protected $userAgent = '{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/{{#artifactVersion}}{{{.}}}{{/artifactVersion}}{{^artifactVersion}}1.0.0{{/artifactVersion}}/php{{/httpUserAgent}}';
|
||||
|
||||
/**
|
||||
* Debug switch (default set to false)
|
||||
@@ -181,7 +181,7 @@ class Configuration
|
||||
* @param string $apiKeyIdentifier API key identifier (authentication scheme)
|
||||
* @param string $key API key or token
|
||||
*
|
||||
* @return Configuration
|
||||
* @return $this
|
||||
*/
|
||||
public function setApiKey($apiKeyIdentifier, $key)
|
||||
{
|
||||
@@ -207,7 +207,7 @@ class Configuration
|
||||
* @param string $apiKeyIdentifier API key identifier (authentication scheme)
|
||||
* @param string $prefix API key prefix, e.g. Bearer
|
||||
*
|
||||
* @return Configuration
|
||||
* @return $this
|
||||
*/
|
||||
public function setApiKeyPrefix($apiKeyIdentifier, $prefix)
|
||||
{
|
||||
@@ -232,7 +232,7 @@ class Configuration
|
||||
*
|
||||
* @param string $accessToken Token for OAuth
|
||||
*
|
||||
* @return Configuration
|
||||
* @return $this
|
||||
*/
|
||||
public function setAccessToken($accessToken)
|
||||
{
|
||||
@@ -255,7 +255,7 @@ class Configuration
|
||||
*
|
||||
* @param string $username Username for HTTP basic authentication
|
||||
*
|
||||
* @return Configuration
|
||||
* @return $this
|
||||
*/
|
||||
public function setUsername($username)
|
||||
{
|
||||
@@ -278,7 +278,7 @@ class Configuration
|
||||
*
|
||||
* @param string $password Password for HTTP basic authentication
|
||||
*
|
||||
* @return Configuration
|
||||
* @return $this
|
||||
*/
|
||||
public function setPassword($password)
|
||||
{
|
||||
@@ -302,7 +302,8 @@ class Configuration
|
||||
* @param string $headerName header name (e.g. Token)
|
||||
* @param string $headerValue header value (e.g. 1z8wp3)
|
||||
*
|
||||
* @return Configuration
|
||||
* @throws \InvalidArgumentException
|
||||
* @return $this
|
||||
*/
|
||||
public function addDefaultHeader($headerName, $headerValue)
|
||||
{
|
||||
@@ -329,11 +330,12 @@ class Configuration
|
||||
*
|
||||
* @param string $headerName the header to delete
|
||||
*
|
||||
* @return Configuration
|
||||
* @return $this
|
||||
*/
|
||||
public function deleteDefaultHeader($headerName)
|
||||
{
|
||||
unset($this->defaultHeaders[$headerName]);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,7 +343,7 @@ class Configuration
|
||||
*
|
||||
* @param string $host Host
|
||||
*
|
||||
* @return Configuration
|
||||
* @return $this
|
||||
*/
|
||||
public function setHost($host)
|
||||
{
|
||||
@@ -364,7 +366,8 @@ class Configuration
|
||||
*
|
||||
* @param string $userAgent the user agent of the api client
|
||||
*
|
||||
* @return Configuration
|
||||
* @throws \InvalidArgumentException
|
||||
* @return $this
|
||||
*/
|
||||
public function setUserAgent($userAgent)
|
||||
{
|
||||
@@ -391,7 +394,8 @@ class Configuration
|
||||
*
|
||||
* @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
|
||||
*
|
||||
* @return Configuration
|
||||
* @throws \InvalidArgumentException
|
||||
* @return $this
|
||||
*/
|
||||
public function setCurlTimeout($seconds)
|
||||
{
|
||||
@@ -418,7 +422,8 @@ class Configuration
|
||||
*
|
||||
* @param integer $seconds Number of seconds before connection times out [set to 0 for no timeout]
|
||||
*
|
||||
* @return Configuration
|
||||
* @throws \InvalidArgumentException
|
||||
* @return $this
|
||||
*/
|
||||
public function setCurlConnectTimeout($seconds)
|
||||
{
|
||||
@@ -446,7 +451,7 @@ class Configuration
|
||||
*
|
||||
* @param string $proxyHost HTTP Proxy URL
|
||||
*
|
||||
* @return ApiClient
|
||||
* @return $this
|
||||
*/
|
||||
public function setCurlProxyHost($proxyHost)
|
||||
{
|
||||
@@ -469,7 +474,7 @@ class Configuration
|
||||
*
|
||||
* @param integer $proxyPort HTTP Proxy Port
|
||||
*
|
||||
* @return ApiClient
|
||||
* @return $this
|
||||
*/
|
||||
public function setCurlProxyPort($proxyPort)
|
||||
{
|
||||
@@ -492,7 +497,7 @@ class Configuration
|
||||
*
|
||||
* @param integer $proxyType HTTP Proxy Type
|
||||
*
|
||||
* @return ApiClient
|
||||
* @return $this
|
||||
*/
|
||||
public function setCurlProxyType($proxyType)
|
||||
{
|
||||
@@ -515,7 +520,7 @@ class Configuration
|
||||
*
|
||||
* @param string $proxyUser HTTP Proxy User
|
||||
*
|
||||
* @return ApiClient
|
||||
* @return $this
|
||||
*/
|
||||
public function setCurlProxyUser($proxyUser)
|
||||
{
|
||||
@@ -538,7 +543,7 @@ class Configuration
|
||||
*
|
||||
* @param string $proxyPassword HTTP Proxy Password
|
||||
*
|
||||
* @return ApiClient
|
||||
* @return $this
|
||||
*/
|
||||
public function setCurlProxyPassword($proxyPassword)
|
||||
{
|
||||
@@ -561,7 +566,7 @@ class Configuration
|
||||
*
|
||||
* @param bool $debug Debug flag
|
||||
*
|
||||
* @return Configuration
|
||||
* @return $this
|
||||
*/
|
||||
public function setDebug($debug)
|
||||
{
|
||||
@@ -584,7 +589,7 @@ class Configuration
|
||||
*
|
||||
* @param string $debugFile Debug file
|
||||
*
|
||||
* @return Configuration
|
||||
* @return $this
|
||||
*/
|
||||
public function setDebugFile($debugFile)
|
||||
{
|
||||
@@ -607,7 +612,7 @@ class Configuration
|
||||
*
|
||||
* @param string $tempFolderPath Temp folder path
|
||||
*
|
||||
* @return Configuration
|
||||
* @return $this
|
||||
*/
|
||||
public function setTempFolderPath($tempFolderPath)
|
||||
{
|
||||
@@ -630,7 +635,7 @@ class Configuration
|
||||
*
|
||||
* @param boolean $sslVerification True if the certificate should be validated, false otherwise
|
||||
*
|
||||
* @return Configuration
|
||||
* @return $this
|
||||
*/
|
||||
public function setSSLVerification($sslVerification)
|
||||
{
|
||||
@@ -683,7 +688,7 @@ class Configuration
|
||||
{
|
||||
$report = 'PHP SDK ({{invokerPackage}}) Debug Report:' . PHP_EOL;
|
||||
$report .= ' OS: ' . php_uname() . PHP_EOL;
|
||||
$report .= ' PHP Version: ' . phpversion() . PHP_EOL;
|
||||
$report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL;
|
||||
$report .= ' OpenAPI Spec Version: {{version}}' . PHP_EOL;
|
||||
{{#artifactVersion}}
|
||||
$report .= ' SDK Package Version: {{artifactVersion}}' . PHP_EOL;
|
||||
|
||||
@@ -20,8 +20,10 @@
|
||||
*/
|
||||
|
||||
namespace {{modelPackage}};
|
||||
{{^isEnum}}
|
||||
|
||||
use \ArrayAccess;
|
||||
{{/isEnum}}
|
||||
|
||||
/**
|
||||
* {{classname}} Class Doc Comment
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
class {{classname}} {
|
||||
/**
|
||||
* Possible values of this enum
|
||||
*/
|
||||
{{#allowableValues}}{{#enumVars}}const {{{name}}} = {{{value}}};
|
||||
{{/enumVars}}{{/allowableValues}}
|
||||
|
||||
{{#vars}}{{#isEnum}}
|
||||
/**
|
||||
* Gets allowable values of the enum
|
||||
* @return string[]
|
||||
*/
|
||||
public function {{getter}}AllowableValues()
|
||||
public static function getAllowableEnumValues()
|
||||
{
|
||||
return [
|
||||
{{#allowableValues}}{{#enumVars}}self::{{datatypeWithEnum}}_{{{name}}},{{^-last}}
|
||||
{{#allowableValues}}{{#enumVars}}self::{{{name}}},{{^-last}}
|
||||
{{/-last}}{{/enumVars}}{{/allowableValues}}
|
||||
];
|
||||
}
|
||||
{{/isEnum}}{{/vars}}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user