Conversation
Add a new #[Consumes] attribute that allows service methods to declare which content types they accept in the request body, overriding the default allowed types (form-urlencoded, multipart, JSON). - Create Annotations/Consumes.php attribute class - Refactor WebServicesManager::process() to defer content type check until after service resolution for #[Consumes] awareness - Skip parameter filtering for non-parseable content types (e.g. application/octet-stream) allowed by #[Consumes] - Integrate #[Consumes] and #[Produces] into OpenAPI spec generation - Add buildRawRequestBody() for binary upload endpoints in OpenAPI - Add 12 tests in ConsumesAnnotationTest covering all behaviors - Add example in examples/03-annotations/03-consumes/ Closes #151
added 2 commits
August 2, 2026 23:47
Add .gitattributes with eol=lf and renormalize all files. This silences CRLF warnings and standardizes the repo.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #152 +/- ##
============================================
- Coverage 93.84% 93.37% -0.48%
- Complexity 1363 1396 +33
============================================
Files 39 39
Lines 3314 3410 +96
============================================
+ Hits 3110 3184 +74
- Misses 204 226 +22
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Add a new
#[Consumes]attribute that allows service methods to declare which content types they accept in the request body, overriding the default allowed types.Motivation
WebServicesManager::POST_CONTENT_TYPESis hardcoded to only allow form-urlencoded, multipart, and JSON. This blocks developers from using properWebServiceclasses for endpoints that accept raw binary uploads, XML, CSV, or other content types. Fixes #151.Changes
Annotations/Consumes.phpattribute class (mirrors#[Produces]structure)WebServicesManager::process()to defer content type validation until after service resolution, enabling#[Consumes]awarenessgetConsumesTypes()andisParseableContentType()helper methods#[Consumes]#[Consumes]and#[Produces]into OpenAPI spec generation (toPathItemObj())buildRawRequestBody()for binary upload endpoints in OpenAPI outputConsumesAnnotationTestexamples/03-annotations/03-consumes/How to Test / Verify
Unit tests cover all behaviors:
composer test -- --filter ConsumesAnnotationTestFull suite passes (640 tests, 1883 assertions):
composer testBreaking Changes and Migration Steps
None. Fully backward compatible:
#[Consumes], behavior is identical to before (default 3 types apply)isContentTypeSupported()signature adds an optional nullable parameter (no BC break for callers)Checklist
composer fix-cs)Related issues
Closes #151