Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test-framework-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ jobs:
- name: Setup PHP with composer v2
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.3'
tools: composer:v2
###############################################
##### END DYNAMIC: Dependent on build environment
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-framework-v2-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:
- name: Setup PHP with composer v2
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.3'
tools: composer:v2
###############################################
##### END DYNAMIC: Dependent on build environment
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-framework-v3-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ jobs:
- name: Setup PHP with composer v2
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.3'
tools: composer:v2
###############################################
##### END DYNAMIC: Dependent on build environment
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-generation-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ jobs:
- name: Setup PHP with composer v2
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.3'
tools: composer:v2
###############################################
##### END DYNAMIC: Dependent on build environment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("README.mustache", getPackagePath(), "README.md"));
supportingFiles.add(new SupportingFile("phpunit.xml.mustache", getPackagePath(), "phpunit.xml.dist"));
supportingFiles.add(new SupportingFile(".travis.yml", getPackagePath(), ".travis.yml"));
supportingFiles.add(new SupportingFile(".php_cs", getPackagePath(), ".php_cs"));
supportingFiles.add(new SupportingFile(".php-cs-fixer.php", getPackagePath(), ".php-cs-fixer.php"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", getPackagePath(), "git_push.sh"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"require-dev": {
"phpunit/phpunit": "~4.8",
"satooshi/php-coveralls": "~1.0",
"squizlabs/php_codesniffer": "~2.6",
"squizlabs/php_codesniffer": "^3.0",
"friendsofphp/php-cs-fixer": "~1.12",
"symfony/browser-kit": "*",
"hoa/regex": "~1.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setUsingCache(true)
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'ordered_imports' => true,
Expand Down
6 changes: 1 addition & 5 deletions modules/swagger-codegen/src/main/resources/php/.travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
language: php
sudo: false
php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
- 8.3
before_install: "composer install"
script: "vendor/bin/phpunit"
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})

## Requirements

PHP 5.5 and later
PHP 8.3 and later

## Installation & Usage
### Composer
Expand Down Expand Up @@ -59,7 +59,7 @@ composer install
./vendor/bin/phpunit
```

**Note:** Running tests requires PHP 7.2 or later, while the runtime library supports PHP 5.5 and later.
**Note:** Running tests requires PHP 8.3 or later.

## Getting Started

Expand Down
62 changes: 39 additions & 23 deletions modules/swagger-codegen/src/main/resources/php/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ namespace {{apiPackage}};

use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Exception\ResponseException;
use GuzzleHttp\Exception\TransferException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
Expand Down Expand Up @@ -60,9 +61,9 @@ use {{invokerPackage}}\ObjectSerializer;
* @param HeaderSelector $selector
*/
public function __construct(
ClientInterface $client = null,
Configuration $config = null,
HeaderSelector $selector = null
?ClientInterface $client = null,
?Configuration $config = null,
?HeaderSelector $selector = null
) {
$this->client = $client ?: new Client();
$this->config = $config ?: new Configuration();
Expand Down Expand Up @@ -93,8 +94,9 @@ use {{invokerPackage}}\ObjectSerializer;
* @param {{dataType}} ${{paramName}}{{#description}} {{description}}{{/description}}{{^description}} {{paramName}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
{{/allParams}}
*
* @throws \{{invokerPackage}}\ApiException on non-2xx response
* @throws \{{invokerPackage}}\ApiException on non-2xx response or a failure without a response
* @throws \InvalidArgumentException
* @throws \JsonException
* @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
*/
public function {{operationId}}({{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}'{{{.}}}'{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
Expand All @@ -118,8 +120,9 @@ use {{invokerPackage}}\ObjectSerializer;
* @param {{dataType}} ${{paramName}}{{#description}} {{description}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
{{/allParams}}
*
* @throws \{{invokerPackage}}\ApiException on non-2xx response
* @throws \{{invokerPackage}}\ApiException on non-2xx response or a failure without a response
* @throws \InvalidArgumentException
* @throws \JsonException
* @return array of {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings)
*/
public function {{operationId}}WithHttpInfo({{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}'{{{.}}}'{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
Expand All @@ -131,13 +134,17 @@ use {{invokerPackage}}\ObjectSerializer;
$options = $this->createHttpClientOption();
try {
$response = $this->client->send($request, $options);
} catch (RequestException $e) {
} catch (ResponseException $e) {
$response = $e->getResponse();
throw new ApiException(
"[{$e->getCode()}] {$e->getMessage()}",
$e->getCode(),
$e->getResponse() ? $e->getResponse()->getHeaders() : null,
$e->getResponse() ? $e->getResponse()->getBody()->getContents() : null
$response->getHeaders(),
$response->getBody()->getContents()
);
} catch (TransferException $e) {
// e.g. connection errors: there is no response
throw new ApiException("[{$e->getCode()}] {$e->getMessage()}", $e->getCode());
}

$statusCode = $response->getStatusCode();
Expand Down Expand Up @@ -209,6 +216,7 @@ use {{invokerPackage}}\ObjectSerializer;
{{/allParams}}
*
* @throws \InvalidArgumentException
* @throws \JsonException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function {{operationId}}Async({{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}'{{{.}}}'{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
Expand All @@ -235,6 +243,7 @@ use {{invokerPackage}}\ObjectSerializer;
{{/allParams}}
*
* @throws \InvalidArgumentException
* @throws \JsonException
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function {{operationId}}AsyncWithHttpInfo({{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}'{{{.}}}'{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
Expand Down Expand Up @@ -268,17 +277,23 @@ use {{invokerPackage}}\ObjectSerializer;
{{/returnType}}
},
function ($exception) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
if ($exception instanceof ResponseException) {
$response = $exception->getResponse();
$statusCode = $response->getStatusCode();
throw new ApiException(
sprintf(
'[%d] Error connecting to the API (%s)',
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$exception->getRequest()->getUri()
),
$statusCode,
$response->getHeaders(),
$response->getBody()
$response->getHeaders(),
$response->getBody()
);
}
throw new ApiException(
sprintf('[%d] Error connecting to the API (%s)', $exception->getCode(), $exception->getMessage()),
$exception->getCode()
);
}
);
Expand All @@ -292,6 +307,7 @@ use {{invokerPackage}}\ObjectSerializer;
{{/allParams}}
*
* @throws \InvalidArgumentException
* @throws \JsonException
* @return \GuzzleHttp\Psr7\Request
*/
protected function {{operationId}}Request({{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}'{{{.}}}'{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
Expand Down Expand Up @@ -396,7 +412,7 @@ use {{invokerPackage}}\ObjectSerializer;
if (${{paramName}} !== null) {
{{#isFile}}
$multipart = true;
$formParams['{{baseName}}'] = \GuzzleHttp\Psr7\try_fopen(ObjectSerializer::toFormValue(${{paramName}}), 'rb');
$formParams['{{baseName}}'] = \GuzzleHttp\Psr7\Utils::tryFopen(ObjectSerializer::toFormValue(${{paramName}}), 'rb');
{{/isFile}}
{{^isFile}}
$formParams['{{baseName}}'] = ObjectSerializer::toFormValue(${{paramName}});
Expand Down Expand Up @@ -430,11 +446,11 @@ use {{invokerPackage}}\ObjectSerializer;
if($headers['Content-Type'] === 'application/json') {
// \stdClass has no __toString(), so we should encode it manually
if ($httpBody instanceof \stdClass) {
$httpBody = \GuzzleHttp\json_encode($httpBody);
$httpBody = json_encode($httpBody, JSON_THROW_ON_ERROR);
}
// array has no __toString(), so we should encode it manually
if(is_array($httpBody)) {
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
$httpBody = json_encode(ObjectSerializer::sanitizeForSerialization($httpBody), JSON_THROW_ON_ERROR);
}
}
} elseif (count($formParams) > 0) {
Expand All @@ -450,7 +466,7 @@ use {{invokerPackage}}\ObjectSerializer;
$httpBody = new MultipartStream($multipartContents);

} elseif ($headers['Content-Type'] === 'application/json') {
$httpBody = \GuzzleHttp\json_encode($formParams);
$httpBody = json_encode($formParams, JSON_THROW_ON_ERROR);

} else {
// for HTTP post (form)
Expand Down
10 changes: 5 additions & 5 deletions modules/swagger-codegen/src/main/resources/php/composer.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
}
],
"require": {
"php": ">=5.5",
"php": ">=8.3",
Comment thread
daniel-kmiecik marked this conversation as resolved.
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"guzzlehttp/guzzle": "^6.2"
"guzzlehttp/guzzle": "^8.3"
Comment thread
daniel-kmiecik marked this conversation as resolved.
},
"require-dev": {
"phpunit/phpunit": "^8.5.52",
"squizlabs/php_codesniffer": "~2.6",
"friendsofphp/php-cs-fixer": "~2.12"
"phpunit/phpunit": "^9.6",
"squizlabs/php_codesniffer": "^3.0",
"friendsofphp/php-cs-fixer": "^3.0"
},
"autoload": {
"psr-4": { "{{escapedInvokerPackage}}\\" : "{{srcBasePath}}/" }
Expand Down
4 changes: 2 additions & 2 deletions modules/swagger-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>${project.build.directory}/swagger-ui-master/dist</directory>
<directory>${project.build.directory}/swagger-ui-main/dist</directory>
<excludes>
<exclude>index.html</exclude>
</excludes>
Expand Down Expand Up @@ -144,7 +144,7 @@
<goal>wget</goal>
</goals>
<configuration>
<url>https://github.com/swagger-api/swagger-ui/archive/master.tar.gz</url>
<url>https://github.com/swagger-api/swagger-ui/archive/main.tar.gz</url>
<unpack>true</unpack>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.0-SNAPSHOT
2.4.53-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setUsingCache(true)
->setRiskyAllowed(true)
->setRules([
'@PSR2' => true,
'ordered_imports' => true,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
language: php
sudo: false
php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
- 8.3
before_install: "composer install"
script: "vendor/bin/phpunit"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This PHP package is automatically generated by the [Swagger Codegen](https://git

## Requirements

PHP 5.5 and later
PHP 8.3 and later

## Installation & Usage
### Composer
Expand Down Expand Up @@ -48,6 +48,8 @@ composer install
./vendor/bin/phpunit
```

**Note:** Running tests requires PHP 8.3 or later.

## Getting Started

Please follow the [installation procedure](#installation--usage) and then run the following:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
}
],
"require": {
"php": ">=5.5",
"php": ">=8.3",
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"guzzlehttp/guzzle": "^6.2"
"guzzlehttp/guzzle": "^8.3"
},
"require-dev": {
"phpunit/phpunit": "^4.8",
"squizlabs/php_codesniffer": "~2.6",
"friendsofphp/php-cs-fixer": "~1.12"
"phpunit/phpunit": "^9.6",
"squizlabs/php_codesniffer": "^3.0",
"friendsofphp/php-cs-fixer": "^3.0"
},
"autoload": {
"psr-4": { "Swagger\\Client\\" : "lib/" }
Expand Down
Loading
Loading