Skip to content

Conversation

@hectorprats
Copy link

This PR fixes an issue where OpenAPI attributes responses were not being processed correctly.

Changes

  • Fixed OpenAPI attributes (Get, Post, Put, Delete, Patch) processing in OpenApiPhpDescriber
  • Clear path property before merge to avoid duplicate path definitions
  • Verify path matches before applying attributes with explicit paths
  • Improved response handling in DefaultDescriber to check for existing responses before adding default
  • Fixed assertNotHasParameter test helper to use array_filter instead of array_column

Description

The OpenApiPhpDescriber wasn't handling Post/Get/Put/Delete/Patch attributes properly, so their responses weren't being merged into the spec. Also fixed DefaultDescriber adding default responses even when specific ones were already defined.

Now attributes like #[OA\\Post] work correctly and we don't get default responses overriding the actual ones. The fix also ensures that attributes with explicit paths only apply to those specific paths.

The OpenApiPhpDescriber wasn't handling Post/Get/Put/Delete/Patch attributes properly, so their responses weren't being merged into the spec. Also fixed DefaultDescriber adding default responses even when specific ones were already defined.

Now attributes like #[OA\Post] work correctly and we don't get default responses overriding the actual ones.
Avoid fatal errors if OpenAPI Attributes classes don't exist by checking
the class name directly instead of using instanceof with potentially
non-existent classes.
- Use $annotation::class instead of \get_class()
- Remove unnecessary backslash prefixes from substr, strrpos, strtolower
- Process OpenAPI Attributes (Get, Post, Put, Delete, Patch) correctly
- Clear path property before merge to avoid duplicate path definitions
- Verify path matches before applying attributes with explicit paths
- Fix DefaultDescriber to check for existing responses before adding default
- Fix assertNotHasParameter to use array_filter instead of array_column
@codecov
Copy link

codecov bot commented Nov 24, 2025

Codecov Report

❌ Patch coverage is 76.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.65%. Comparing base (b11e562) to head (2cb783c).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/Describer/OpenApiPhpDescriber.php 71.42% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              5.x    #2629      +/-   ##
==========================================
- Coverage   96.05%   95.65%   -0.40%     
==========================================
  Files          94       94              
  Lines        3016     3040      +24     
==========================================
+ Hits         2897     2908      +11     
- Misses        119      132      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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