Skip to content

Commit

Permalink
Merge branch 'api-platform:main' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
botjaeger committed Sep 4, 2023
2 parents 8056124 + 4cf6b27 commit 64157e5
Show file tree
Hide file tree
Showing 196 changed files with 5,244 additions and 610 deletions.
147 changes: 147 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -841,3 +841,150 @@ jobs:
run: tests/Fixtures/app/console cache:clear --ansi
- name: Run Behat tests
run: vendor/bin/behat --out=std --format=progress --profile=default --no-interaction

phpunit_legacy:
name: PHPUnit Legacy event listeners (PHP ${{ matrix.php }})
env:
EVENT_LISTENERS_BACKWARD_COMPATIBILITY_LAYER: 1
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
php:
- '8.2'
include:
- php: '8.2'
coverage: true
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite
coverage: pcov
ini-values: memory_limit=-1
- name: Get composer cache directory
id: composercache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Enable code coverage
if: matrix.coverage
run: echo "COVERAGE=1" >> $GITHUB_ENV
- name: Update project dependencies
run: composer update --no-interaction --no-progress --ansi
- name: Install PHPUnit
run: vendor/bin/simple-phpunit --version
- name: Clear test app cache
run: tests/Fixtures/app/console cache:clear --ansi
- name: Run PHPUnit tests
run: |
mkdir -p build/logs/phpunit
if [ "$COVERAGE" = '1' ]; then
vendor/bin/simple-phpunit --log-junit build/logs/phpunit/junit.xml --coverage-clover build/logs/phpunit/clover.xml
else
vendor/bin/simple-phpunit --log-junit build/logs/phpunit/junit.xml
fi
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: phpunit-logs-php${{ matrix.php }}
path: build/logs/phpunit
continue-on-error: true
- name: Upload coverage results to Codecov
if: matrix.coverage
uses: codecov/codecov-action@v3
with:
directory: build/logs/phpunit
name: phpunit-php${{ matrix.php }}
flags: phpunit
fail_ci_if_error: true
continue-on-error: true
- name: Upload coverage results to Coveralls
if: matrix.coverage
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
composer global require --prefer-dist --no-interaction --no-progress --ansi php-coveralls/php-coveralls
export PATH="$PATH:$HOME/.composer/vendor/bin"
php-coveralls --coverage_clover=build/logs/phpunit/clover.xml
continue-on-error: true

behat_legacy:
name: Behat Legacy event listeners (PHP ${{ matrix.php }})
env:
EVENT_LISTENERS_BACKWARD_COMPATIBILITY_LAYER: 1
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
php:
- '8.2'
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite
coverage: pcov
ini-values: memory_limit=-1
- name: Get composer cache directory
id: composercache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Update project dependencies
run: composer update --no-interaction --no-progress --ansi
- name: Install PHPUnit
run: vendor/bin/simple-phpunit --version
- name: Clear test app cache
run: tests/Fixtures/app/console cache:clear --ansi
- name: Run Behat tests (PHP 8)
run: |
mkdir -p build/logs/behat
vendor/bin/behat --out=std --format=progress --format=junit --out=build/logs/behat/junit --profile=legacy --no-interaction
- name: Upload test artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: behat-logs-php${{ matrix.php }}
path: build/logs/behat
continue-on-error: true
- name: Export OpenAPI documents
run: |
mkdir -p build/out/openapi
tests/Fixtures/app/console api:openapi:export -o build/out/openapi/openapi_v3.json
tests/Fixtures/app/console api:openapi:export --yaml -o build/out/openapi/openapi_v3.yaml
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: '14'
- name: Validate OpenAPI documents
run: |
npx git+https://github.com/soyuka/swagger-cli#master validate build/out/openapi/openapi_v3.json
npx git+https://github.com/soyuka/swagger-cli#master validate build/out/openapi/openapi_v3.yaml
- name: Upload OpenAPI artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: openapi-docs-php${{ matrix.php }}
path: build/out/openapi
continue-on-error: true

23 changes: 23 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,28 @@
# Changelog

## v3.2.0-alpha.1

### Bug fixes

* [33b1658a0](https://github.com/api-platform/core/commit/33b1658a0e100e0ca9e7bf46aa2307ead9b1744e) fix(serializer): disable_type_enforcement with null values (#5593)
* [49981505a](https://github.com/api-platform/core/commit/49981505a8af281d00e35f1424432fae65686eb8) fix(metadata): convert composite uri variables w/ proper type
* [502234cf5](https://github.com/api-platform/core/commit/502234cf55d6a58c79b68c5193bade9ba605107e) fix: allowed composite identifiers with differents types
* [51e4295b2](https://github.com/api-platform/core/commit/51e4295b26e606c5da10d434b6e98dadb8a243b2) fix: missing parent construct calls with named arguments (#5387)
* [9116f1554](https://github.com/api-platform/core/commit/9116f1554581bf5362146cdc4d5fdbebc71e3528) fix(symfony): provider can throw validation exception (#5586)
* [b58ec1207](https://github.com/api-platform/core/commit/b58ec1207da8ba5b669937508a17451af61b0688) fix(metadata): correct interface aliases (#5766)
* [c353e5aa4](https://github.com/api-platform/core/commit/c353e5aa474d7a2e6c701bfa1c369b560e928c17) fix(graphql): do not add id field if operation already has a dedicated input type (#5095)
* [ccef472ca](https://github.com/api-platform/core/commit/ccef472cade42b189fa8cb7793e27fad1349e289) fix(openapi): use 3.1 version (#5489)


### Features

* [4ef0ef856](https://github.com/api-platform/core/commit/4ef0ef856ced658ac942fd6a2c6f7c5c563078d1) feat: error as resources, jsonld errors are now problem-compliant (#5433)
* [6babb3d6b](https://github.com/api-platform/core/commit/6babb3d6b707290fdf314c0e96acd525d6f96670) feat: replace doctrine/inflector by symfony/string (#5637)
* [7a1d351b0](https://github.com/api-platform/core/commit/7a1d351b0a37fc7107c548708f4b9e38a9dedc76) feat(tests): add a method to generate the IRI from a resource (#5582)
* [851aa3778](https://github.com/api-platform/core/commit/851aa3778ef8a6f959a44b759fc343e9f8cfc8bf) feat(graphql)!: add extra args for custom queries or mutations (#5359)
* [92a81f024](https://github.com/api-platform/core/commit/92a81f024541054b9322e7457b75c721261e14e0) feat(graphql): allow to disable the introspection query (#5711)
* [d793ffb92](https://github.com/api-platform/core/commit/d793ffb9228a21655ee35f0b90a959f93281a4cf) feat: union/intersect types (#5470)

## v3.1.15

### Bug fixes
Expand Down
40 changes: 38 additions & 2 deletions behat.yml.dist
Expand Up @@ -16,7 +16,7 @@ default:
- 'Behat\MinkExtension\Context\MinkContext'
- 'behatch:context:rest'
filters:
tags: '~@postgres&&~@mongodb&&~@elasticsearch'
tags: '~@postgres&&~@mongodb&&~@elasticsearch&&~@controller'
extensions:
'FriendsOfBehat\SymfonyExtension':
bootstrap: 'tests/Fixtures/app/bootstrap.php'
Expand Down Expand Up @@ -52,7 +52,7 @@ postgres:
- 'Behat\MinkExtension\Context\MinkContext'
- 'behatch:context:rest'
filters:
tags: '~@sqlite&&~@mongodb&&~@elasticsearch'
tags: '~@sqlite&&~@mongodb&&~@elasticsearch&&~@controller'

mongodb:
suites:
Expand Down Expand Up @@ -142,3 +142,39 @@ elasticsearch-coverage:
- 'ApiPlatform\Tests\Behat\CoverageContext'
- 'Behat\MinkExtension\Context\MinkContext'
- 'behatch:context:rest'

legacy:
suites:
default:
contexts:
- 'ApiPlatform\Tests\Behat\CommandContext'
- 'ApiPlatform\Tests\Behat\DoctrineContext'
- 'ApiPlatform\Tests\Behat\GraphqlContext'
- 'ApiPlatform\Tests\Behat\JsonContext'
- 'ApiPlatform\Tests\Behat\HydraContext'
- 'ApiPlatform\Tests\Behat\OpenApiContext'
- 'ApiPlatform\Tests\Behat\HttpCacheContext'
- 'ApiPlatform\Tests\Behat\JsonApiContext'
- 'ApiPlatform\Tests\Behat\JsonHalContext'
- 'ApiPlatform\Tests\Behat\MercureContext'
- 'ApiPlatform\Tests\Behat\XmlContext'
- 'Behat\MinkExtension\Context\MinkContext'
- 'behatch:context:rest'
filters:
tags: '~@postgres&&~@mongodb&&~@elasticsearch'
extensions:
'FriendsOfBehat\SymfonyExtension':
bootstrap: 'tests/Fixtures/app/bootstrap.php'
kernel:
environment: 'test'
debug: true
class: AppKernel
path: 'tests/Fixtures/app/AppKernel.php'
'Behat\MinkExtension':
base_url: 'http://example.com/'
files_path: 'features/files'
sessions:
default:
symfony: ~
'Behatch\Extension': ~

3 changes: 3 additions & 0 deletions features/graphql/mutation.feature
Expand Up @@ -794,6 +794,7 @@ Feature: GraphQL mutation support
And the JSON node "errors[0].extensions.violations[0].path" should be equal to "name"
And the JSON node "errors[0].extensions.violations[0].message" should be equal to "This value should not be blank."

@createSchema
Scenario: Execute a custom mutation
Given there are 1 dummyCustomMutation objects
When I send the following GraphQL request:
Expand All @@ -812,7 +813,9 @@ Feature: GraphQL mutation support
And the header "Content-Type" should be equal to "application/json"
And the JSON node "data.sumDummyCustomMutation.dummyCustomMutation.result" should be equal to "8"

@createSchema
Scenario: Execute a not persisted custom mutation (resolver returns null)
Given there are 1 dummyCustomMutation objects
When I send the following GraphQL request:
"""
mutation {
Expand Down
9 changes: 5 additions & 4 deletions features/hydra/error.feature
Expand Up @@ -42,12 +42,13 @@ Feature: Error handling
"""
Then the response status code should be 400
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
And the JSON node "@context" should be equal to "/contexts/Error"
And the JSON node "@type" should be equal to "hydra:Error"
And the JSON node "hydra:title" should be equal to "An error occurred"
And the JSON node "hydra:description" should be equal to 'Nested documents for attribute "relatedDummy" are not allowed. Use IRIs instead.'
And the JSON node "trace" should exist
And the header "Link" should contain '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error"'

Scenario: Get an error during deserialization of collection
When I add "Content-Type" header equal to "application/ld+json"
Expand All @@ -62,7 +63,7 @@ Feature: Error handling
"""
Then the response status code should be 400
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
And the JSON node "@context" should be equal to "/contexts/Error"
And the JSON node "@type" should be equal to "hydra:Error"
And the JSON node "hydra:title" should be equal to "An error occurred"
Expand All @@ -79,7 +80,7 @@ Feature: Error handling
"""
Then the response status code should be 400
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
And the JSON node "@context" should be equal to "/contexts/Error"
And the JSON node "@type" should be equal to "hydra:Error"
And the JSON node "hydra:title" should be equal to "An error occurred"
Expand All @@ -97,7 +98,7 @@ Feature: Error handling
"""
Then the response status code should be 400
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
And the JSON node "@context" should be equal to "/contexts/Error"
And the JSON node "@type" should be equal to "hydra:Error"
And the JSON node "hydra:title" should be equal to "An error occurred"
Expand Down
1 change: 1 addition & 0 deletions features/jsonld/non_resource.feature
Expand Up @@ -40,6 +40,7 @@ Feature: JSON-LD non-resource handling
"""
And the JSON node "notAResource.@id" should exist

@createSchema
Scenario: Get a resource containing a raw object with selected properties
Given there are 1 dummy objects with relatedDummy and its thirdLevel
When I send a "GET" request to "/contain_non_resources/1?properties[]=id&properties[nested][notAResource][]=foo&properties[notAResource][]=bar"
Expand Down
3 changes: 2 additions & 1 deletion features/main/attribute_resource.feature
Expand Up @@ -98,7 +98,8 @@ Feature: Resource attributes
When I send a "GET" request to "/photos/1/resize/300/100"
Then the response status code should be 400
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
And the header "Link" should contain '<http://www.w3.org/ns/hydra/error>; rel="http://www.w3.org/ns/json-ld#error"'
And the JSON node "hydra:description" should be equal to 'Unable to generate an IRI for the item of type "ApiPlatform\Tests\Fixtures\TestBundle\Entity\IncompleteUriVariableConfigured"'

Scenario: Uri variables with Post operation
Expand Down
6 changes: 3 additions & 3 deletions features/main/exception_to_status.feature
Expand Up @@ -9,7 +9,7 @@ Feature: Using exception_to_status config
And I send a "GET" request to "/dummy_exception_to_statuses/123"
Then the response status code should be 404
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"

@!mongodb
Scenario: Configure status code via the resource exceptionToStatus to map custom NotFound error to 400
Expand All @@ -22,12 +22,12 @@ Feature: Using exception_to_status config
"""
Then the response status code should be 400
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"

@!mongodb
Scenario: Configure status code via the config file to map FilterValidationException to 400
When I add "Content-Type" header equal to "application/ld+json"
And I send a "GET" request to "/dummy_exception_to_statuses"
Then the response status code should be 400
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
5 changes: 4 additions & 1 deletion features/main/not_exposed.feature
Expand Up @@ -2,6 +2,9 @@
@v3
Feature: Expose only a collection of objects

Background:
Given I add "Accept" header equal to "application/ld+json"

# A NotExposed operation with "routeName: api_genid" is automatically added to this resource.
Scenario: Get a collection of objects without identifiers from a single resource with a single collection
When I send a "GET" request to "/chairs"
Expand Down Expand Up @@ -168,7 +171,7 @@ Feature: Expose only a collection of objects
When I send a "GET" request to "<uri>"
Then the response status code should be 404
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
And the JSON node "hydra:description" should be equal to "<hydra:description>"
Examples:
| uri | hydra:description |
Expand Down
8 changes: 4 additions & 4 deletions features/main/relation.feature
Expand Up @@ -351,7 +351,7 @@ Feature: Relations support
"""
Then the response status code should be 400
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"

Scenario: Post a relation with a not existing IRI
When I add "Content-Type" header equal to "application/ld+json"
Expand All @@ -363,7 +363,7 @@ Feature: Relations support
"""
Then the response status code should be 400
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"

Scenario: Update an embedded relation
When I add "Content-Type" header equal to "application/ld+json"
Expand Down Expand Up @@ -470,7 +470,7 @@ Feature: Relations support
"""
Then the response status code should be 400
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
And the JSON node "hydra:description" should contain 'Invalid IRI "certainly not an IRI".'

Scenario: Passing an invalid type to a relation
Expand All @@ -483,7 +483,7 @@ Feature: Relations support
"""
Then the response status code should be 400
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the header "Content-Type" should be equal to "application/problem+json; charset=utf-8"
And the JSON should be valid according to this schema:
"""
{
Expand Down

0 comments on commit 64157e5

Please sign in to comment.