-
-
Notifications
You must be signed in to change notification settings - Fork 838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: override code based defaults with explicit ones #2377
fix: override code based defaults with explicit ones #2377
Conversation
This change allows that defaults that are set in attributes can override the ones that are read from the code. This fixes nelmio#2330
de11fd1
to
4451269
Compare
4451269
to
6419201
Compare
6419201
to
0a81850
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2377 +/- ##
==========================================
+ Coverage 89.46% 89.48% +0.01%
==========================================
Files 77 78 +1
Lines 2848 2890 +42
==========================================
+ Hits 2548 2586 +38
- Misses 300 304 +4 ☔ View full report in Codecov by Sentry. |
7a499cb
to
006e643
Compare
This allows to fetch default values via reflection should they so far not have been set via other means. As that happens before the SymfonyConstraint handling, the required fields should be set as expected but should also take into account the default values set via Attributes or Annotations.
Two tests didn't handle the provided defaults properly, so I had to fix them to now also validate that the defaults are set appropriately
006e643
to
43eca97
Compare
65cbd50
to
4e3fae1
Compare
As the library is set to be usable with PHP7.4 and the ReflectionProperty::has/getDefaultValue is only available for PHP8+ I needed to slightly refactor the class.
4e3fae1
to
6a2bffd
Compare
All problems should be addressed, the behaviour is almost the same as before. I had to change two tests where a default value was provided in the code that wasn't passed into the OpenAPI-spec previously but is passed in now. This could be considered a BC-break but I'd argue that it was broken in the first place and is therefore a Bug-Fix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you @heiglandreas ❤️ |
## Description This change allows that defaults that are set in attributes can override the ones that are read from the code. This fixes #2330 Closes #2330 ## What type of PR is this? (check all applicable) - [x] Bug Fix - [ ] Feature - [ ] Refactor - [ ] Deprecation - [ ] Breaking Change - [ ] Documentation Update - [ ] CI ## Checklist - [ ] I have made corresponding changes to the documentation (`docs/`) - [ ] I have made corresponding changes to the changelog (`CHANGELOG.md`) (cherry picked from commit 84c7916)
Description
This change allows that defaults that are set in attributes can override the ones that are read from the code.
This fixes #2330
Closes #2330
What type of PR is this? (check all applicable)
Checklist
docs/
)CHANGELOG.md
)