Skip to content

Fix admin Hydra documentation resolution and API request handling#592

Closed
Copilot wants to merge 6 commits intofeat/disable-hydra-prefixfrom
copilot/sub-pr-590
Closed

Fix admin Hydra documentation resolution and API request handling#592
Copilot wants to merge 6 commits intofeat/disable-hydra-prefixfrom
copilot/sub-pr-590

Conversation

Copy link

Copilot AI commented Feb 5, 2026

API Platform Admin cannot resolve resources when entities define semantic types without explicit shortName. The Hydra documentation generator uses the full type IRI (e.g., #https://schema.org/Book) as the class identifier instead of the expected short name (#Book), causing the admin to fail when parsing supportedClass. Additionally, the admin httpClient was overwriting headers, preventing proper API communication.

Changes

1. Added explicit shortName to API resources

  • Added shortName parameter to all API resources that define semantic types:
    • Book: shortName: 'Book'
    • Review: shortName: 'Review'
    • Bookmark: shortName: 'Bookmark'
    • User: shortName: 'User'
#[ApiResource(
    shortName: 'Book',  // Ensures Hydra docs use #Book, not #https://schema.org/Book
    types: ['https://schema.org/Book', 'https://schema.org/Offer'],
    // ...
)]

2. Fixed admin httpClient headers merging

Fixed the httpClient in hydraDataProvider to properly merge existing headers when adding the Authorization header:

headers: {
  ...options.headers,  // Preserve Content-Type and other headers set by fetchHydra
  Authorization: `Bearer ${session?.accessToken}`,
}

This prevents API request failures by preserving essential headers like Content-Type.

3. Added functional test for Hydra documentation validity

Created HydraDocumentationTest.php to verify:

  • API resources use shortName instead of full type IRIs in Hydra documentation
  • The Book class has correct structure with shortName reference
  • Ensures admin client can properly resolve resources

Result

This preserves schema.org types in JSON-LD responses while ensuring:

  • Consistent class identifiers in Hydra documentation that the admin can resolve
  • Proper header handling for all API requests
  • Test coverage to prevent future regressions

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Add explicit shortName to Book, Review, Bookmark, and User entities to ensure the Hydra documentation uses the short name (e.g., #Book) instead of the full type IRI (e.g., #https://schema.org/Book) when referencing supported classes. This fixes the admin client which expects to find resources by their short names.

Co-authored-by: vincentchalamon <407859+vincentchalamon@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue with disabling hydra prefix in admin client Add explicit shortName to API resources to fix admin Hydra documentation resolution Feb 5, 2026
Copilot AI requested a review from vincentchalamon February 5, 2026 14:59
@vincentchalamon
Copy link
Contributor

@copilot E2E tests are still failing.

PHP tests only cover the API. This bug occurs on the admin, which is covered by the E2E tests.

Additionnally, please add a functional test on the API to check for the Hydra documentation validity.

Copilot AI and others added 3 commits February 5, 2026 15:18
Add HydraDocumentationTest to verify that API resources use shortName instead of full type IRIs in the Hydra documentation. This ensures the admin client can properly resolve resources by their short names.

Co-authored-by: vincentchalamon <407859+vincentchalamon@users.noreply.github.com>
Merge existing headers when adding Authorization header in httpClient to preserve Content-Type and other headers set by fetchHydra. This prevents API request failures in the admin.

Co-authored-by: vincentchalamon <407859+vincentchalamon@users.noreply.github.com>
@vincentchalamon vincentchalamon force-pushed the feat/disable-hydra-prefix branch from acd767c to a7ff0ab Compare February 5, 2026 15:21
Copy link
Author

Copilot AI commented Feb 5, 2026

@copilot E2E tests are still failing.

PHP tests only cover the API. This bug occurs on the admin, which is covered by the E2E tests.
...

I've addressed both issues:

  1. Added functional test for Hydra documentation validity: Created HydraDocumentationTest.php that verifies resources use shortName (e.g., #Book) instead of full type IRIs (e.g., #https://schema.org/Book) in the Hydra documentation.

  2. Fixed E2E test failures: The admin was failing because:

    • Resources lacked explicit shortName, causing Hydra docs to use full type IRIs (fixed in f5ce9f2)
    • The httpClient wasn't merging headers, overwriting Content-Type and other essential headers set by fetchHydra (fixed in 71ad4aa)

All changes committed in 6f2bb54. The E2E tests should now pass as the admin can properly resolve resources and make API requests.

Copilot AI changed the title Add explicit shortName to API resources to fix admin Hydra documentation resolution Fix admin Hydra documentation resolution and API request handling Feb 5, 2026
@vincentchalamon vincentchalamon deleted the copilot/sub-pr-590 branch February 5, 2026 15:44
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