Skip to content

Commit 600b058

Browse files
committed
Update openapi core implementation
1 parent 6450c04 commit 600b058

33 files changed

+161
-191
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,11 @@ jobs:
1515
strategy:
1616
matrix:
1717
include:
18-
- php-version: "8.0"
18+
- php-version: "8.1"
1919
composer-deps: lowest
20-
- php-version: "8.0"
21-
composer-deps: latest
22-
with-cs-check: true
2320
- php-version: "8.1"
2421
composer-deps: latest
22+
with-cs-check: true
2523
- php-version: "8.2"
2624
composer-deps: latest
2725
- php-version: "8.3"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
build
44
!build/.gitkeep
55
.idea
6+
.phpunit.cache

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
}
1515
],
1616
"require": {
17-
"php": "~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0",
18-
"cebe/php-openapi": "^1.7.0",
19-
"symfony/console": "^5.1.9 || ^6.0"
17+
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
18+
"php-openapi/openapi": "^2.0",
19+
"symfony/console": "^6.0 || ^7.0"
2020
},
2121
"require-dev": {
2222
"doctrine/coding-standard": "^12.0.0",
2323
"infection/infection": "^0.26.0",
2424
"phpstan/phpstan": "^1.10.0",
2525
"phpstan/phpstan-phpunit": "^1.3.0",
26-
"phpunit/phpunit": "^9.5.0",
26+
"phpunit/phpunit": "^10.0 || ^11.0",
2727
"roave/security-advisories": "dev-master"
2828
},
2929
"autoload": {

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:8.0-cli-alpine
1+
FROM php:8.3-cli-alpine
22

33
RUN php --version
44

phpunit.xml.dist

Lines changed: 27 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,29 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
4-
bootstrap="./tests/bootstrap.php"
5-
colors="true"
6-
defaultTimeLimit="5"
7-
executionOrder="random"
8-
enforceTimeLimit="true"
9-
beStrictAboutCoversAnnotation="true"
10-
forceCoversAnnotation="true"
11-
cacheResultFile="build/.phpunit.result.cache"
12-
>
13-
14-
<php>
15-
<ini name="assert.exception" value="1" />
16-
</php>
17-
18-
<testsuites>
19-
<testsuite name="Unit Test Suite">
20-
<directory>./tests</directory>
21-
<exclude>./tests/Acceptance</exclude>
22-
</testsuite>
23-
<testsuite name="Acceptance Test Suite">
24-
<directory>./tests/Acceptance</directory>
25-
</testsuite>
26-
</testsuites>
27-
28-
<coverage>
29-
<include>
30-
<directory>./src</directory>
31-
</include>
32-
<report>
33-
<clover outputFile="build/coverage/clover.xml"/>
34-
<xml outputDirectory="build/coverage/coverage-xml/"/>
35-
</report>
36-
</coverage>
37-
38-
<logging>
39-
<junit outputFile="build/coverage/junit.xml"/>
40-
</logging>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="./tests/bootstrap.php" colors="true" defaultTimeLimit="5" executionOrder="random" enforceTimeLimit="true" cacheDirectory=".phpunit.cache" requireCoverageMetadata="true" beStrictAboutCoverageMetadata="true">
3+
<php>
4+
<ini name="assert.exception" value="1"/>
5+
</php>
6+
<testsuites>
7+
<testsuite name="Unit Test Suite">
8+
<directory>./tests</directory>
9+
<exclude>./tests/Acceptance</exclude>
10+
</testsuite>
11+
<testsuite name="Acceptance Test Suite">
12+
<directory>./tests/Acceptance</directory>
13+
</testsuite>
14+
</testsuites>
15+
<coverage>
16+
<report>
17+
<clover outputFile="build/coverage/clover.xml"/>
18+
<xml outputDirectory="build/coverage/coverage-xml/"/>
19+
</report>
20+
</coverage>
21+
<logging>
22+
<junit outputFile="build/coverage/junit.xml"/>
23+
</logging>
24+
<source>
25+
<include>
26+
<directory>./src</directory>
27+
</include>
28+
</source>
4129
</phpunit>

src/FileHandling/SpecificationFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Mthole\OpenApiMerge\FileHandling;
66

7-
use cebe\openapi\spec\OpenApi;
7+
use openapiphp\openapi\spec\OpenApi;
88

99
final class SpecificationFile
1010
{

src/Merge/ComponentsMerger.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace Mthole\OpenApiMerge\Merge;
66

7-
use cebe\openapi\spec\Components;
8-
use cebe\openapi\spec\OpenApi;
7+
use openapiphp\openapi\spec\Components;
8+
use openapiphp\openapi\spec\OpenApi;
99
use Mthole\OpenApiMerge\Util\Json;
1010

1111
use function array_merge;

src/Merge/MergerInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Mthole\OpenApiMerge\Merge;
66

7-
use cebe\openapi\spec\OpenApi;
7+
use openapiphp\openapi\spec\OpenApi;
88

99
interface MergerInterface
1010
{

src/Merge/PathMerger.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace Mthole\OpenApiMerge\Merge;
66

7-
use cebe\openapi\spec\OpenApi;
8-
use cebe\openapi\spec\Paths;
7+
use openapiphp\openapi\spec\OpenApi;
8+
use openapiphp\openapi\spec\Paths;
99
use Mthole\OpenApiMerge\Util\Json;
1010

1111
class PathMerger implements MergerInterface

src/Merge/ReferenceNormalizer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
namespace Mthole\OpenApiMerge\Merge;
66

7-
use cebe\openapi\spec\MediaType;
8-
use cebe\openapi\spec\OpenApi;
9-
use cebe\openapi\spec\Reference;
10-
use cebe\openapi\spec\Response;
7+
use openapiphp\openapi\spec\MediaType;
8+
use openapiphp\openapi\spec\OpenApi;
9+
use openapiphp\openapi\spec\Reference;
10+
use openapiphp\openapi\spec\Response;
1111
use Mthole\OpenApiMerge\FileHandling\File;
1212

1313
use function array_map;
@@ -30,7 +30,7 @@ public function normalizeInlineReferences(
3030
foreach ($operation->responses->getResponses() as $statusCode => $response) {
3131
if ($response instanceof Reference) {
3232
$operation->responses->addResponse(
33-
$statusCode,
33+
(string) $statusCode,
3434
$this->normalizeReference($response, $refFileCollection),
3535
);
3636
}

src/Merge/ReferenceResolverResult.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Mthole\OpenApiMerge\Merge;
66

7-
use cebe\openapi\spec\OpenApi;
7+
use openapiphp\openapi\spec\OpenApi;
88
use Mthole\OpenApiMerge\FileHandling\File;
99

1010
final class ReferenceResolverResult

src/Merge/SecurityPathMerger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Mthole\OpenApiMerge\Merge;
66

7-
use cebe\openapi\spec\OpenApi;
7+
use openapiphp\openapi\spec\OpenApi;
88
use Mthole\OpenApiMerge\Util\Json;
99

1010
use function count;

src/Reader/FileReader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Mthole\OpenApiMerge\Reader;
66

7-
use cebe\openapi\spec\OpenApi;
7+
use openapiphp\openapi\spec\OpenApi;
88
use Mthole\OpenApiMerge\FileHandling\File;
99
use Mthole\OpenApiMerge\FileHandling\SpecificationFile;
1010
use Mthole\OpenApiMerge\Reader\Exception\InvalidFileTypeException;

src/Reader/OpenApiReaderWrapper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace Mthole\OpenApiMerge\Reader;
66

7-
use cebe\openapi\Reader;
8-
use cebe\openapi\SpecObjectInterface;
7+
use openapiphp\openapi\Reader;
8+
use openapiphp\openapi\SpecObjectInterface;
99

1010
class OpenApiReaderWrapper
1111
{

src/Writer/DefinitionWriter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Mthole\OpenApiMerge\Writer;
66

7-
use cebe\openapi\Writer;
7+
use openapiphp\openapi\Writer;
88
use Mthole\OpenApiMerge\FileHandling\SpecificationFile;
99
use Mthole\OpenApiMerge\Writer\Exception\InvalidFileTypeException;
1010

tests/Acceptance/ApplicationAcceptanceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use function sprintf;
1313
use function version_compare;
1414

15-
/** @coversNothing */
15+
#[\PHPUnit\Framework\Attributes\CoversNothing]
1616
class ApplicationAcceptanceTest extends TestCase
1717
{
1818
public function testApplicationRuns(): void

tests/AssertionsEnabledTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
use function assert;
1111

12-
/** @coversNothing */
12+
#[\PHPUnit\Framework\Attributes\CoversNothing]
1313
class AssertionsEnabledTest extends TestCase
1414
{
1515
public function testAssertionsWillThrowAnException(): void

tests/Console/Command/MergeCommandTest.php

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Mthole\OpenApiMerge\Tests\Console\Command;
66

7-
use cebe\openapi\spec\OpenApi;
7+
use openapiphp\openapi\spec\OpenApi;
88
use Generator;
99
use Mthole\OpenApiMerge\Console\Command\MergeCommand;
1010
use Mthole\OpenApiMerge\FileHandling\File;
@@ -23,15 +23,13 @@
2323

2424
use const PHP_EOL;
2525

26-
/**
27-
* @uses \Mthole\OpenApiMerge\FileHandling\File
28-
* @uses \Mthole\OpenApiMerge\FileHandling\SpecificationFile
29-
*
30-
* @covers \Mthole\OpenApiMerge\Console\Command\MergeCommand
31-
*/
26+
27+
#[\PHPUnit\Framework\Attributes\CoversClass(\Mthole\OpenApiMerge\Console\Command\MergeCommand::class)]
28+
#[\PHPUnit\Framework\Attributes\UsesClass('\Mthole\OpenApiMerge\FileHandling\File')]
29+
#[\PHPUnit\Framework\Attributes\UsesClass('\Mthole\OpenApiMerge\FileHandling\SpecificationFile')]
3230
class MergeCommandTest extends TestCase
3331
{
34-
/** @dataProvider invalidArgumentsDataProvider */
32+
#[\PHPUnit\Framework\Attributes\DataProvider('invalidArgumentsDataProvider')]
3533
public function testRunWithInvalidArguments(ArrayInput $input): void
3634
{
3735
$sut = new MergeCommand(
@@ -47,7 +45,7 @@ public function testRunWithInvalidArguments(ArrayInput $input): void
4745
}
4846

4947
/** @return Generator<list<ArrayInput>> */
50-
public function invalidArgumentsDataProvider(): Generator
48+
public static function invalidArgumentsDataProvider(): Generator
5149
{
5250
yield [
5351
new ArrayInput([
@@ -101,7 +99,7 @@ public function testRun(): void
10199

102100
$mergeResultStub = new SpecificationFile(
103101
new File('dummy'),
104-
$this->createStub(OpenApi::class),
102+
new OpenApi([]),
105103
);
106104

107105
$mergeMock = $this->createMock(OpenApiMergeInterface::class);
@@ -181,7 +179,7 @@ public function mergeFiles(
181179
}
182180

183181
/** @return array<string, list<mixed>> */
184-
public function resolveReferenceArgumentDataProvider(): iterable
182+
public static function resolveReferenceArgumentDataProvider(): iterable
185183
{
186184
yield 'default-param' => [null, true];
187185
yield 'one as string' => ['1', true];
@@ -190,7 +188,7 @@ public function resolveReferenceArgumentDataProvider(): iterable
190188
yield 'false' => [false, false];
191189
}
192190

193-
/** @dataProvider resolveReferenceArgumentDataProvider */
191+
#[\PHPUnit\Framework\Attributes\DataProvider('resolveReferenceArgumentDataProvider')]
194192
public function testResolveReferencesArgument(
195193
string|bool|null $resolveReferenceValue,
196194
bool $expectedResolveReferenceValue,
@@ -236,9 +234,8 @@ public function write(SpecificationFile $specFile): string
236234
/**
237235
* @param array<string, list<string>> $arguments
238236
* @param list<File> $expectedFiles
239-
*
240-
* @dataProvider matchArgumentDataProvider
241237
*/
238+
#[\PHPUnit\Framework\Attributes\DataProvider('matchArgumentDataProvider')]
242239
public function testMatchArgument(array $arguments, array $expectedFiles): void
243240
{
244241
$basefile = 'basefile.yml';
@@ -269,7 +266,7 @@ public function find(string $baseDirectory, string $searchString): array
269266
}
270267

271268
/** @return iterable<string, array<string, mixed>> */
272-
public function matchArgumentDataProvider(): iterable
269+
public static function matchArgumentDataProvider(): iterable
273270
{
274271
yield 'given additional files with match should ignore match' => [
275272
'arguments' => [

tests/FileHandling/Exception/IOExceptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Mthole\OpenApiMerge\FileHandling\Exception\IOException;
88
use PHPUnit\Framework\TestCase;
99

10-
/** @covers \Mthole\OpenApiMerge\FileHandling\Exception\IOException */
10+
#[\PHPUnit\Framework\Attributes\CoversClass(\Mthole\OpenApiMerge\FileHandling\Exception\IOException::class)]
1111
class IOExceptionTest extends TestCase
1212
{
1313
public function testCreateException(): void

tests/FileHandling/FileTest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,20 @@
1212
use function preg_quote;
1313
use function str_replace;
1414

15-
/**
16-
* @uses \Mthole\OpenApiMerge\FileHandling\Exception\IOException
17-
*
18-
* @covers \Mthole\OpenApiMerge\FileHandling\File
19-
*/
15+
16+
#[\PHPUnit\Framework\Attributes\CoversClass(\Mthole\OpenApiMerge\FileHandling\File::class)]
17+
#[\PHPUnit\Framework\Attributes\UsesClass('\Mthole\OpenApiMerge\FileHandling\Exception\IOException')]
2018
class FileTest extends TestCase
2119
{
22-
/** @dataProvider fileExtensionProvider */
20+
#[\PHPUnit\Framework\Attributes\DataProvider('fileExtensionProvider')]
2321
public function testGetFileExtension(string $filename, string $expectedExtension): void
2422
{
2523
$sut = new File($filename);
2624
self::assertSame($expectedExtension, $sut->getFileExtension());
2725
}
2826

2927
/** @return list<list<string>> */
30-
public function fileExtensionProvider(): iterable
28+
public static function fileExtensionProvider(): iterable
3129
{
3230
yield ['base.yml', 'yml'];
3331
yield ['base.yaml', 'yaml'];

tests/FileHandling/RegexFinderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
use function array_keys;
1111

12-
/** @covers \Mthole\OpenApiMerge\FileHandling\RegexFinder */
12+
#[\PHPUnit\Framework\Attributes\CoversClass(\Mthole\OpenApiMerge\FileHandling\RegexFinder::class)]
1313
class RegexFinderTest extends TestCase
1414
{
15-
/** @dataProvider findStringDataProvider */
15+
#[\PHPUnit\Framework\Attributes\DataProvider('findStringDataProvider')]
1616
public function testFind(string $search, int $expectedFilesCount): void
1717
{
1818
$sut = new RegexFinder();
@@ -24,7 +24,7 @@ public function testFind(string $search, int $expectedFilesCount): void
2424
}
2525

2626
/** @return array<string, array<string|int>> */
27-
public function findStringDataProvider(): iterable
27+
public static function findStringDataProvider(): iterable
2828
{
2929
yield 'all a.txt' => ['.*a.txt', 2];
3030
yield 'all a.txt in B' => ['B/a.txt', 1];

0 commit comments

Comments
 (0)