Skip to content

feat(symfony): composer dependency JSON+LD/Hydra is now optional#7898

Open
giosh94mhz wants to merge 1 commit intoapi-platform:mainfrom
giosh94mhz:optional_hydra
Open

feat(symfony): composer dependency JSON+LD/Hydra is now optional#7898
giosh94mhz wants to merge 1 commit intoapi-platform:mainfrom
giosh94mhz:optional_hydra

Conversation

@giosh94mhz
Copy link
Copy Markdown
Contributor

Q A
Branch main
Tickets
License MIT
Doc PR no changes on default, not needed

I'm switching to the modular version of api-platform/* packages, mainly to get rid of all Laravel dependencies, and I found that JSON-LD/Hydra is somewhat hard-coded to the Symfony package.

I think this requirement can be lowered or totally removed, since simple JSON format is always available for use.

To avoid BC, I've updated the Configuration class with an heuristics to detect the standard case. There are multiple way to detect that (e.g. class_exists), please let me know it this doesn't not stand with your quality standards.

@giosh94mhz
Copy link
Copy Markdown
Contributor Author

I've checked the failing tests, and are all in the form of:

1) ApiPlatform\Symfony\Tests\Bundle\DependencyInjection\ApiPlatformExtensionTest::testCommonConfiguration
LogicException: JSON+LD support cannot be enabled as the JSON+LD component is not installed. Try running "composer require api-platform/jsonld".

/home/runner/work/core/core/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php:715
/home/runner/work/core/core/src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php:185
/home/runner/work/core/core/src/Symfony/Tests/Bundle/DependencyInjection/ApiPlatformExtensionTest.php:179

I guess this is "expected" since the CI tests for Symfony install only "api-platform/symfony" (without "api-platform/jsonld", nor "api-platform/hydrasonld"), but the tests are configured with:

class ApiPlatformExtensionTest
{
    final public const DEFAULT_CONFIG = ['api_platform' => [
        // ...
        'formats' => [
            'json' => ['mime_types' => ['json']],
            'jsonld' => ['mime_types' => ['application/ld+json']],
            'jsonhal' => ['mime_types' => ['application/hal+json']],
        ],
        // ...
        'error_formats' => [
            'jsonproblem' => ['application/problem+json'],
            'jsonld' => ['application/ld+json'],
        ],
        // ...
    ]];
    // ...
}

Comment on lines 16 to 18
use Composer\InstalledVersions;

use ApiPlatform\Doctrine\Common\Filter\OrderFilterInterface;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra blank line

Suggested change
use Composer\InstalledVersions;
use ApiPlatform\Doctrine\Common\Filter\OrderFilterInterface;
use Composer\InstalledVersions;
use ApiPlatform\Doctrine\Common\Filter\OrderFilterInterface;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants