Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.18.0
7.27.0
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"guzzlehttp/guzzle": "^7.3",
"guzzlehttp/psr7": "^1.7 || ^2.0"
"guzzlehttp/guzzle": "^7.3 || ^8.0",
"guzzlehttp/psr7": "^1.7 || ^2.0 || ^3.0",
"psr/http-client": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^8.0 || ^9.0",
Expand Down
2 changes: 1 addition & 1 deletion generate_api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ rm -r ./lib/*
rm -r ./docs/*

LOG_LEVEL="warn"
TAG="v7.18.0"
TAG="v7.27.0"

# generate sysadmin
docker run --rm \
Expand Down
156 changes: 118 additions & 38 deletions lib/Auth/APITokenApi.php

Large diffs are not rendered by default.

60 changes: 30 additions & 30 deletions lib/Auth/AccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,49 +45,49 @@ class AccessToken implements ModelInterface, ArrayAccess, \JsonSerializable
public const DISCRIMINATOR = null;

/**
* The original name of the model.
*
* @var string
*/
* The original name of the model.
*
* @var string
*/
protected static $openAPIModelName = 'AccessToken';

/**
* Array of property to type mappings. Used for (de)serialization
*
* @var string[]
*/
* Array of property to type mappings. Used for (de)serialization
*
* @var string[]
*/
protected static $openAPITypes = [
'access_token' => 'string',
'dtable_uuid' => 'string'
];

/**
* Array of property to format mappings. Used for (de)serialization
*
* @var string[]
* @phpstan-var array<string, string|null>
* @psalm-var array<string, string|null>
*/
* Array of property to format mappings. Used for (de)serialization
*
* @var string[]
* @phpstan-var array<string, string|null>
* @psalm-var array<string, string|null>
*/
protected static $openAPIFormats = [
'access_token' => null,
'dtable_uuid' => 'uuid'
];

/**
* Array of nullable properties. Used for (de)serialization
*
* @var boolean[]
*/
* Array of nullable properties. Used for (de)serialization
*
* @var boolean[]
*/
protected static array $openAPINullables = [
'access_token' => false,
'dtable_uuid' => false
];

/**
* If a nullable field gets set to null, insert it here
*
* @var boolean[]
*/
* If a nullable field gets set to null, insert it here
*
* @var boolean[]
*/
protected array $openAPINullablesSetToNull = [];

/**
Expand Down Expand Up @@ -255,14 +255,14 @@ public function __construct(?array $data = null)
}

/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
Expand Down
60 changes: 30 additions & 30 deletions lib/Auth/AccountToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,46 +45,46 @@ class AccountToken implements ModelInterface, ArrayAccess, \JsonSerializable
public const DISCRIMINATOR = null;

/**
* The original name of the model.
*
* @var string
*/
* The original name of the model.
*
* @var string
*/
protected static $openAPIModelName = 'AccountToken';

/**
* Array of property to type mappings. Used for (de)serialization
*
* @var string[]
*/
* Array of property to type mappings. Used for (de)serialization
*
* @var string[]
*/
protected static $openAPITypes = [
'token' => 'string'
];

/**
* Array of property to format mappings. Used for (de)serialization
*
* @var string[]
* @phpstan-var array<string, string|null>
* @psalm-var array<string, string|null>
*/
* Array of property to format mappings. Used for (de)serialization
*
* @var string[]
* @phpstan-var array<string, string|null>
* @psalm-var array<string, string|null>
*/
protected static $openAPIFormats = [
'token' => null
];

/**
* Array of nullable properties. Used for (de)serialization
*
* @var boolean[]
*/
* Array of nullable properties. Used for (de)serialization
*
* @var boolean[]
*/
protected static array $openAPINullables = [
'token' => false
];

/**
* If a nullable field gets set to null, insert it here
*
* @var boolean[]
*/
* If a nullable field gets set to null, insert it here
*
* @var boolean[]
*/
protected array $openAPINullablesSetToNull = [];

/**
Expand Down Expand Up @@ -248,14 +248,14 @@ public function __construct(?array $data = null)
}

/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
Expand Down
40 changes: 34 additions & 6 deletions lib/Auth/AccountTokenApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@

use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use Psr\Http\Client\NetworkExceptionInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use SeaTable\Client\ApiException;
Expand Down Expand Up @@ -167,13 +167,14 @@ public function getAccountTokenfromUsernameWithHttpInfo($username, $password, $x
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
$eResponse = $this->getExceptionResponse($e);
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? (string) $e->getResponse()->getBody() : null
$eResponse ? $eResponse->getHeaders() : null,
$eResponse ? (string) $eResponse->getBody() : null
);
} catch (ConnectException $e) {
} catch (NetworkExceptionInterface $e) {
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
(int) $e->getCode(),
Expand Down Expand Up @@ -292,7 +293,15 @@ function ($response) use ($returnType) {
];
},
function ($exception) {
$response = $exception->getResponse();
$response = $this->getExceptionResponse($exception);
if ($response === null) {
throw new ApiException(
"[{$exception->getCode()}] {$exception->getMessage()}",
(int) $exception->getCode(),
null,
null
);
}
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
Expand Down Expand Up @@ -390,7 +399,11 @@ public function getAccountTokenfromUsernameRequest($username, $password, $x_seaf

} elseif (stripos($headers['Content-Type'], 'application/json') !== false) {
# if Content-Type contains "application/json", json_encode the form parameters
$httpBody = \GuzzleHttp\Utils::jsonEncode($formParams);
try {
$httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);
} catch (\JsonException $e) {
throw new \InvalidArgumentException('json_encode error: ' . $e->getMessage(), 0, $e);
}
} else {
// for HTTP post (form)
$httpBody = ObjectSerializer::buildQuery($formParams);
Expand Down Expand Up @@ -446,6 +459,21 @@ protected function createHttpClientOption()
return $options;
}

/**
* Returns the response attached to a Guzzle exception, if there is one.
*
* Guzzle 7 exposes getResponse() on RequestException, while Guzzle 8 only
* exposes it on ResponseException and its subclasses.
*
* @param \Throwable $exception
*
* @return ResponseInterface|null
*/
private function getExceptionResponse(\Throwable $exception): ?ResponseInterface
{
return method_exists($exception, 'getResponse') ? $exception->getResponse() : null;
}

private function handleResponseWithDataType(
string $dataType,
RequestInterface $request,
Expand Down
60 changes: 30 additions & 30 deletions lib/Auth/ApiToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ class ApiToken implements ModelInterface, ArrayAccess, \JsonSerializable
public const DISCRIMINATOR = null;

/**
* The original name of the model.
*
* @var string
*/
* The original name of the model.
*
* @var string
*/
protected static $openAPIModelName = 'ApiToken';

/**
* Array of property to type mappings. Used for (de)serialization
*
* @var string[]
*/
* Array of property to type mappings. Used for (de)serialization
*
* @var string[]
*/
protected static $openAPITypes = [
'app_name' => 'string',
'api_token' => 'string',
Expand All @@ -66,12 +66,12 @@ class ApiToken implements ModelInterface, ArrayAccess, \JsonSerializable
];

/**
* Array of property to format mappings. Used for (de)serialization
*
* @var string[]
* @phpstan-var array<string, string|null>
* @psalm-var array<string, string|null>
*/
* Array of property to format mappings. Used for (de)serialization
*
* @var string[]
* @phpstan-var array<string, string|null>
* @psalm-var array<string, string|null>
*/
protected static $openAPIFormats = [
'app_name' => null,
'api_token' => null,
Expand All @@ -82,10 +82,10 @@ class ApiToken implements ModelInterface, ArrayAccess, \JsonSerializable
];

/**
* Array of nullable properties. Used for (de)serialization
*
* @var boolean[]
*/
* Array of nullable properties. Used for (de)serialization
*
* @var boolean[]
*/
protected static array $openAPINullables = [
'app_name' => false,
'api_token' => false,
Expand All @@ -96,10 +96,10 @@ class ApiToken implements ModelInterface, ArrayAccess, \JsonSerializable
];

/**
* If a nullable field gets set to null, insert it here
*
* @var boolean[]
*/
* If a nullable field gets set to null, insert it here
*
* @var boolean[]
*/
protected array $openAPINullablesSetToNull = [];

/**
Expand Down Expand Up @@ -300,14 +300,14 @@ public function __construct(?array $data = null)
}

/**
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
* Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName
* is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the
* $this->openAPINullablesSetToNull array
*
* @param string $variableName
* @param array $fields
* @param mixed $defaultValue
*/
private function setIfExists(string $variableName, array $fields, $defaultValue): void
{
if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) {
Expand Down
Loading