Skip to content

Commit

Permalink
Laravel 10 support (#525)
Browse files Browse the repository at this point in the history
* WIP: Laravel 10 support

* WIP: Laravel 10 support

* fix #497

* Use php8.1 for doceker and phpunit 10

* Update usage of phpunit 10

* Apply fixes from StyleCI

* Add to gitignore .phpunit.cache

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
  • Loading branch information
DarkaOnLine and StyleCIBot authored Feb 15, 2023
1 parent 0b1c3f5 commit 8e61ce6
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ composer-extra-assets.lock
.env
/tests/storage/api-docs/*
/tests/storage/logs/*
.phpunit.cache
.bowerrc
bower.json
package.json
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Base install
#
FROM amd64/php:8.0-apache as base
FROM amd64/php:8.1-apache as base

LABEL vendor="L5 Swagger"

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
],
"require": {
"php": "^7.2 || ^8.0",
"laravel/framework": "^9.0 || >=8.40.0 || ^7.0",
"zircote/swagger-php": "^3.2 || ^4.0",
"laravel/framework": "^10.0 || ^9.0 || >=8.40.0 || ^7.0",
"zircote/swagger-php": "^3.2.0 || ^4.0.0",
"swagger-api/swagger-ui": "^3.0 || ^4.0",
"symfony/yaml": "^5.0 || ^6.0",
"ext-json": "*"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^10.0 || ^9.5",
"mockery/mockery": "1.*",
"orchestra/testbench": "7.* || ^6.15 || 5.*",
"orchestra/testbench": "^8.0 || 7.* || ^6.15 || 5.*",
"php-coveralls/php-coveralls": "^2.0"
},
"autoload": {
Expand Down
15 changes: 7 additions & 8 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="false"
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
stopOnFailure="false"
cacheDirectory=".phpunit.cache"
>
<coverage>
<include>
Expand Down
10 changes: 6 additions & 4 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,12 @@ protected function createOpenApiGenerator(): OpenApiGenerator
{
$generator = new OpenApiGenerator();

// OpenApi spec version.
$generator->setVersion(
$this->scanOptions['open_api_spec_version'] ?? self::OPEN_API_DEFAULT_SPEC_VERSION
);
// OpenApi spec version - only from zircote/swagger-php 4
if (method_exists($generator, 'setVersion')) {
$generator->setVersion(
$this->scanOptions['open_api_spec_version'] ?? self::OPEN_API_DEFAULT_SPEC_VERSION
);
}

// Processors.
$this->setProcessors($generator);
Expand Down
2 changes: 1 addition & 1 deletion tests/ConfigFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function canMergeConfigurationDeep(array $data, array $assert): void
$this->assertArraySimilar($config, $assert);
}

public function configDataProvider(): array
public static function configDataProvider(): array
{
return [
[
Expand Down
4 changes: 3 additions & 1 deletion tests/ConsoleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Tests;

use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Artisan;
use L5Swagger\Exceptions\L5SwaggerException;
Expand All @@ -18,6 +19,7 @@ class ConsoleTest extends TestCase
* @param string $artisanCommand
*
* @throws L5SwaggerException
* @throws FileNotFoundException
*/
public function canGenerate(string $artisanCommand): void
{
Expand All @@ -38,7 +40,7 @@ public function canGenerate(string $artisanCommand): void
/**
* @return iterable
*/
public function provideGenerateCommands(): iterable
public static function provideGenerateCommands(): iterable
{
yield 'default' => [
'artisanCommand' => 'l5-swagger:generate',
Expand Down
2 changes: 1 addition & 1 deletion tests/SecurityDefinitionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function canGenerateApiJsonFileWithSecurityDefinition(
/**
* @return iterable
*/
public function provideConfigAndSchemes(): iterable
public static function provideConfigAndSchemes(): iterable
{
$securitySchemes = [
'new_api_key_securitye' => [
Expand Down

0 comments on commit 8e61ce6

Please sign in to comment.