feat(symfony): composer dependency JSON+LD/Hydra is now optional#7898
feat(symfony): composer dependency JSON+LD/Hydra is now optional#7898giosh94mhz wants to merge 1 commit intoapi-platform:mainfrom
Conversation
|
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:179I 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'],
],
// ...
]];
// ...
} |
| use Composer\InstalledVersions; | ||
|
|
||
| use ApiPlatform\Doctrine\Common\Filter\OrderFilterInterface; |
There was a problem hiding this comment.
Extra blank line
| use Composer\InstalledVersions; | |
| use ApiPlatform\Doctrine\Common\Filter\OrderFilterInterface; | |
| use Composer\InstalledVersions; | |
| use ApiPlatform\Doctrine\Common\Filter\OrderFilterInterface; |
2981552 to
5d7fb4d
Compare
|
JSON-LD is our default format I'm not sure we want to make it optional as it doesn't make sense to not install any formats: plain JSON support with API Platform isn't perfect + we base all our code on IRIs... |
|
Our API is fully based on REST+HAL (HATEOAS) and so the JSONLD-Hydra stack is fully optional. I see your point on having a default with IRI support, as a general mean, however there may be read-only API or HATEOAS API available out there. This patch should not apply to whomever install the full api-platform stack, but only to those who decide to install the single packages, and the composer warning is there to intercept default configuration. Maybe we can add a "composer recommend" message on the single package which sais something like "for API write support you either need json-ld or Hal package"? |
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.