Skip to content

feat(state): added "Accept-Post" and "Allow" headers - #8

Closed
LaurentHuzard wants to merge 4 commits into
mainfrom
feat/wip-ldp
Closed

feat(state): added "Accept-Post" and "Allow" headers#8
LaurentHuzard wants to merge 4 commits into
mainfrom
feat/wip-ldp

Conversation

@LaurentHuzard

Copy link
Copy Markdown
Owner

feat(state): added "Accept-Post" and "Allow" headers

To ensure compliance with the LDP specification (https://www.w3.org/TR/ldp/): Added the "Accept-Post" header containing the list of supported Post formats.
Added the "Allow" header with values based on the allowed operations on the queried resources.

@LaurentHuzard
LaurentHuzard requested a review from Copilot January 11, 2026 19:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR implements compliance with the LDP (Linked Data Platform) specification by adding two HTTP headers to API responses: Accept-Post (listing supported POST content types) and Allow (listing permitted HTTP methods for a resource).

Changes:

  • Added LinkedDataPlatformProcessor to set Accept-Post and Allow headers based on resource operations
  • Integrated the processor into the Laravel service provider
  • Added comprehensive test coverage for both functional and unit testing

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/State/Processor/LinkedDataPlatformProcessor.php New processor that analyzes resource operations and sets LDP-compliant headers
src/Laravel/ApiPlatformProvider.php Registers the new LinkedDataPlatformProcessor in the Laravel DI container
src/State/Tests/Processor/LinkedDataPlatformProcessorTest.php Unit tests verifying processor behavior for header generation
tests/Functional/LinkDataPlatformTest.php Functional tests ensuring headers are correctly set in real API requests
tests/Fixtures/TestBundle/ApiResource/DummyGetPostDeleteOperation.php Test fixture resource with GET, POST, and DELETE operations
src/State/Tests/Fixtures/ApiResource/Dummy.php Basic test fixture for unit testing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

$this->assertResponseHeaderSame('accept-post', 'application/ld+json, application/hal+json, application/vnd.api+json, application/xml, text/xml, application/json, text/html, application/graphql, multipart/form-data');
}

public function testAcceptPostHeaderDoesNotExistResourceWithoutPost(): void

Copilot AI Jan 11, 2026

Copy link

Choose a reason for hiding this comment

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

The test method name contains a grammatical error. Consider renaming to 'testAcceptPostHeaderDoesNotExistForResourceWithoutPost' to improve readability and clarity.

Suggested change
public function testAcceptPostHeaderDoesNotExistResourceWithoutPost(): void
public function testAcceptPostHeaderDoesNotExistForResourceWithoutPost(): void

Copilot uses AI. Check for mistakes.
Comment on lines +30 to +36
provider: [self::class, 'provide'], ),
new Post(
uriTemplate: '/dummy_get_post_delete_operations',
provider: [self::class, 'provide'], ),
new Delete(
uriTemplate: '/dummy_get_post_delete_operations/{id}',
provider: [self::class, 'provideItem'], ),

Copilot AI Jan 11, 2026

Copy link

Choose a reason for hiding this comment

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

Inconsistent formatting: closing parenthesis and comma are on the same line as the provider parameter, while other operations place the closing parenthesis on a new line. Consider moving the closing parenthesis to a new line for consistency with lines 36-37.

Suggested change
provider: [self::class, 'provide'], ),
new Post(
uriTemplate: '/dummy_get_post_delete_operations',
provider: [self::class, 'provide'], ),
new Delete(
uriTemplate: '/dummy_get_post_delete_operations/{id}',
provider: [self::class, 'provideItem'], ),
provider: [self::class, 'provide'],
),
new Post(
uriTemplate: '/dummy_get_post_delete_operations',
provider: [self::class, 'provide'],
),
new Delete(
uriTemplate: '/dummy_get_post_delete_operations/{id}',
provider: [self::class, 'provideItem'],
),

Copilot uses AI. Check for mistakes.
Comment on lines +30 to +33
provider: [self::class, 'provide'], ),
new Post(
uriTemplate: '/dummy_get_post_delete_operations',
provider: [self::class, 'provide'], ),

Copilot AI Jan 11, 2026

Copy link

Choose a reason for hiding this comment

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

Inconsistent formatting: closing parenthesis and comma are on the same line as the provider parameter. Consider moving the closing parenthesis to a new line for consistency with the Delete operation formatting on lines 36-37.

Suggested change
provider: [self::class, 'provide'], ),
new Post(
uriTemplate: '/dummy_get_post_delete_operations',
provider: [self::class, 'provide'], ),
provider: [self::class, 'provide'],
),
new Post(
uriTemplate: '/dummy_get_post_delete_operations',
provider: [self::class, 'provide'],
),

Copilot uses AI. Check for mistakes.
$this->decorated->method('process')->willReturn(new Response());
}

public function testHeadersAcceptPostIsReturnWhenPostAllowed(): void

Copilot AI Jan 11, 2026

Copy link

Choose a reason for hiding this comment

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

The test method name has a grammatical error. 'IsReturn' should be 'IsReturned'. Consider renaming to 'testHeadersAcceptPostIsReturnedWhenPostAllowed' for grammatical correctness.

Suggested change
public function testHeadersAcceptPostIsReturnWhenPostAllowed(): void
public function testHeadersAcceptPostIsReturnedWhenPostAllowed(): void

Copilot uses AI. Check for mistakes.
$this->assertStringContainsString('POST', $allowHeader);
$operation = new Get('/dummy/{dummyResourceId}{._format}', class: Dummy::class);

/** @var Response $response */

Copilot AI Jan 11, 2026

Copy link

Choose a reason for hiding this comment

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

The PHPDoc comment on line 120 incorrectly documents $processor as a Response when it should document the variable on line 127. This comment appears to be misplaced and should either be removed or moved to line 126.

Suggested change
/** @var Response $response */

Copilot uses AI. Check for mistakes.
@coveralls

coveralls commented Jan 11, 2026

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 20941246093

Details

  • 35 of 117 (29.91%) changed or added relevant lines in 5 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.002%) to 29.097%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/Laravel/ApiPlatformProvider.php 0 6 0.0%
src/State/Tests/Processor/LinkedDataPlatformProcessorTest.php 0 76 0.0%
Files with Coverage Reduction New Missed Lines %
src/Laravel/ApiPlatformProvider.php 1 0.0%
Totals Coverage Status
Change from base Build 20899830831: 0.002%
Covered Lines: 17027
Relevant Lines: 58518

💛 - Coveralls

# This is the 1st commit message:

feat(state): added "Accept-Post" and "Allow" headers

To ensure compliance with the LDP specification (https://www.w3.org/TR/ldp/):
Added the "Accept-Post" header containing the list of supported Post formats.
 Added the "Allow" header with values based on the allowed operations on the queried resources.

# Conflicts:
#	src/Symfony/Bundle/Resources/config/state/processor.xml
#	src/Symfony/Bundle/Resources/config/symfony/events.xml

# The commit message #2 will be skipped:

# WIP
@LaurentHuzard
LaurentHuzard deleted the feat/wip-ldp branch January 13, 2026 20:41
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.

3 participants