diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4ad9d8f..44e75ae 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,10 +19,10 @@ jobs: composer-deps: lowest - php-version: "7.4" composer-deps: latest - - php-version: "8.0" - composer-deps: lowest - php-version: "8.0" composer-deps: latest + - php-version: "8.1" + composer-deps: latest steps: - name: "Checkout" uses: "actions/checkout@v2" @@ -48,10 +48,10 @@ jobs: restore-keys: "php-${{ matrix.php-version }}-composer-${{ matrix.composer-deps }}" - name: "Install dependencies" - run: "composer install --no-interaction --no-progress --no-suggest --ignore-platform-reqs" + run: "composer install --no-interaction --no-progress --ignore-platform-reqs" - name: "Update dependencies (lowest)" - run: "composer update --no-interaction --no-progress --no-suggest --prefer-lowest --prefer-stable" + run: "composer update --no-interaction --no-progress --prefer-lowest --prefer-stable" if: ${{ matrix.composer-deps == 'lowest' }} - name: "Update dependencies (latest)" diff --git a/composer.json b/composer.json index ddc0278..959a7d1 100644 --- a/composer.json +++ b/composer.json @@ -14,9 +14,9 @@ } ], "require": { - "php": "^7.4 || ~8.0.0", - "cebe/php-openapi": "^1.5.2", - "symfony/console": "^v5.1.9" + "php": "^7.4 || ~8.0.0 || ~8.1.0", + "cebe/php-openapi": "^1.7.0", + "symfony/console": "^5.1.9 || ^6.0" }, "require-dev": { "doctrine/coding-standard": "^9.0.0", @@ -59,7 +59,12 @@ "infection": "infection --threads=4 --coverage=build/coverage" }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true, + "infection/extension-installer": true, + "ocramius/package-versions": true + } }, "bin": [ "bin/openapi-merge" diff --git a/docker/Dockerfile b/docker/Dockerfile index 4c07c0d..0cf13e7 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.4-cli-alpine +FROM php:8.0-cli-alpine RUN php --version diff --git a/tests/Acceptance/ApplicationAcceptanceTest.php b/tests/Acceptance/ApplicationAcceptanceTest.php index bcaea82..507f867 100644 --- a/tests/Acceptance/ApplicationAcceptanceTest.php +++ b/tests/Acceptance/ApplicationAcceptanceTest.php @@ -9,6 +9,9 @@ use function implode; use function shell_exec; use function sprintf; +use function version_compare; + +use const PHP_VERSION; /** * @coversNothing @@ -28,97 +31,12 @@ public function testApplicationRuns(): void ]) )); - self::assertSame( - <<<'EXPECTED_YAML' - openapi: 3.0.2 - info: - title: 'Example OpenAPI Definition' - description: 'This is the example Description' - contact: - name: 'Base Author' - url: base.example.org - email: base-file@example.org - license: - name: MIT - url: 'https://tldrlegal.com/license/mit-license' - version: '1.0' - servers: - - - url: 'https://api.base.example.org' - description: 'Main Base URL' - paths: - /ping: - get: - tags: - - 'Base Route' - summary: 'Your GET endpoint' - description: 'Description of Ping' - operationId: get-ping - parameters: - - - name: responseWith - in: query - description: 'response with this message' - schema: - maxLength: 20 - minLength: 0 - type: string - responses: - '200': - description: OK - content: - application/json: - schema: - required: - - response - type: object - properties: - response: - type: string - '400': - description: 'Bad Request' - content: - application/problem+json: - schema: - title: ProblemResponse - required: - - type - - title - type: object - properties: - type: - type: string - description: 'type of the problem' - example: ValidationError - title: - type: string - example: 'Your request parameters didn''t validate.' - description: 'Default Problem Response' - post: - summary: 'Your POST endpoint' - description: 'Description of post Ping' - operationId: post-ping - responses: - '200': - description: OK - content: - application/json: - schema: - required: - - response - type: object - properties: - response: - type: string - components: - schemas: [] - security: [] - tags: - - - name: Base + self::assertNotNull($output); - EXPECTED_YAML, - $output - ); + if (version_compare(PHP_VERSION, '8.1.0', '>=')) { + self::assertStringEqualsFile(__DIR__ . '/Fixtures/expected_php81.yml', $output); + } else { + self::assertStringEqualsFile(__DIR__ . '/Fixtures/expected_php80.yml', $output); + } } } diff --git a/tests/Acceptance/Fixtures/expected_php80.yml b/tests/Acceptance/Fixtures/expected_php80.yml new file mode 100644 index 0000000..cfca99e --- /dev/null +++ b/tests/Acceptance/Fixtures/expected_php80.yml @@ -0,0 +1,86 @@ +openapi: 3.0.2 +info: + title: 'Example OpenAPI Definition' + description: 'This is the example Description' + contact: + name: 'Base Author' + url: base.example.org + email: base-file@example.org + license: + name: MIT + url: 'https://tldrlegal.com/license/mit-license' + version: '1.0' +servers: + - + url: 'https://api.base.example.org' + description: 'Main Base URL' +paths: + /ping: + get: + tags: + - 'Base Route' + summary: 'Your GET endpoint' + description: 'Description of Ping' + operationId: get-ping + parameters: + - + name: responseWith + in: query + description: 'response with this message' + schema: + maxLength: 20 + minLength: 0 + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + required: + - response + type: object + properties: + response: + type: string + '400': + description: 'Bad Request' + content: + application/problem+json: + schema: + title: ProblemResponse + required: + - type + - title + type: object + properties: + type: + type: string + description: 'type of the problem' + example: ValidationError + title: + type: string + example: 'Your request parameters didn''t validate.' + description: 'Default Problem Response' + post: + summary: 'Your POST endpoint' + description: 'Description of post Ping' + operationId: post-ping + responses: + '200': + description: OK + content: + application/json: + schema: + required: + - response + type: object + properties: + response: + type: string +components: + schemas: { } +security: [] +tags: + - + name: Base diff --git a/tests/Acceptance/Fixtures/expected_php81.yml b/tests/Acceptance/Fixtures/expected_php81.yml new file mode 100644 index 0000000..3896b30 --- /dev/null +++ b/tests/Acceptance/Fixtures/expected_php81.yml @@ -0,0 +1,86 @@ +openapi: 3.0.2 +info: + title: 'Example OpenAPI Definition' + description: 'This is the example Description' + contact: + name: 'Base Author' + url: base.example.org + email: base-file@example.org + license: + name: MIT + url: 'https://tldrlegal.com/license/mit-license' + version: '1.0' +servers: + - + url: 'https://api.base.example.org' + description: 'Main Base URL' +paths: + /ping: + get: + tags: + - 'Base Route' + summary: 'Your GET endpoint' + description: 'Description of Ping' + operationId: get-ping + parameters: + - + name: responseWith + in: query + description: 'response with this message' + schema: + maxLength: 20 + minLength: 0 + type: string + responses: + '200': + description: OK + content: + application/json: + schema: + required: + - response + type: object + properties: + response: + type: string + '400': + description: 'Bad Request' + content: + application/problem+json: + schema: + title: ProblemResponse + required: + - type + - title + type: object + properties: + type: + type: string + description: 'type of the problem' + example: ValidationError + title: + type: string + example: "Your request parameters didn't validate." + description: 'Default Problem Response' + post: + summary: 'Your POST endpoint' + description: 'Description of post Ping' + operationId: post-ping + responses: + '200': + description: OK + content: + application/json: + schema: + required: + - response + type: object + properties: + response: + type: string +components: + schemas: { } +security: [] +tags: + - + name: Base