Skip to content

fix(laravel): wire jsonapi.use_iri_as_id in ApiPlatformProvider#8224

Merged
soyuka merged 1 commit into
api-platform:4.3from
soyuka:fix/8199-jsonapi-laravel-use-iri-as-id
Jun 2, 2026
Merged

fix(laravel): wire jsonapi.use_iri_as_id in ApiPlatformProvider#8224
soyuka merged 1 commit into
api-platform:4.3from
soyuka:fix/8199-jsonapi-laravel-use-iri-as-id

Conversation

@soyuka
Copy link
Copy Markdown
Member

@soyuka soyuka commented Jun 2, 2026

Summary

The Laravel ApiPlatformProvider instantiated JsonApiItemNormalizer without the useIriAsId flag, without an IdentifiersExtractor, and without an OperationResourceClassResolver. As a result, api-platform.jsonapi.use_iri_as_id (documented for the Symfony integration) was silently ignored: data.id always held the IRI and data.links.self was never emitted.

Symfony's ApiPlatformExtension::registerJsonApiConfiguration already wires the flag as a constructor argument. This PR ports the same wiring to Laravel and adds the config default.

  • src/Laravel/ApiPlatformProvider.php: thread operationResourceResolver, identifiersExtractor, and useIriAsId into the JsonApiItemNormalizer singleton.
  • src/Laravel/config/api-platform.php: document the jsonapi.use_iri_as_id default (true).
  • src/Laravel/Tests/JsonApiUseIriAsIdTest.php: new functional test asserting data.id = scalar identifier and data.links.self = IRI when the flag is false.

Fixes #8199.

Test plan

  • vendor/bin/phpunit Tests/JsonApiTest.php Tests/JsonApiUseIriAsIdTest.php from src/Laravel/ (14 tests, 52 assertions — pass)
  • Default behaviour preserved (data.id = IRI when flag is true or unset)

The Laravel provider ignored the `jsonapi.use_iri_as_id` config key:
`JsonApiItemNormalizer` was instantiated without the flag, without
`IdentifiersExtractor`, and without `OperationResourceClassResolver`,
so `data.id` always held the IRI and `data.links.self` was never
emitted. Symfony's `ApiPlatformExtension` already wired this argument;
this ports the same wiring to Laravel and adds the config default.

Fixes api-platform#8199
@soyuka soyuka merged commit 4059c63 into api-platform:4.3 Jun 2, 2026
105 of 108 checks passed
@soyuka soyuka deleted the fix/8199-jsonapi-laravel-use-iri-as-id branch June 2, 2026 15:55
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.

1 participant