-
Notifications
You must be signed in to change notification settings - Fork 56
Expose Named Arguments in Error Responses #46
Conversation
Codecov Report
@@ Coverage Diff @@
## master #46 +/- ##
============================================
+ Coverage 91.18% 91.37% +0.19%
- Complexity 207 230 +23
============================================
Files 24 27 +3
Lines 465 545 +80
Branches 56 72 +16
============================================
+ Hits 424 498 +74
+ Misses 25 22 -3
- Partials 16 25 +9
Continue to review full report at Codecov.
|
I like the idea of returning as much as data possible and letting the client to assemble the message. |
1247518
to
e83665e
Compare
@zarebski-m The
How can we access to the binding exception source?
Proposed SolutionIf the underlying
I will push this solution on top of your commits! |
Extracting named arguments was moved to separate method In addition two more arguments are exposed from constraint violations at the end of argument list:
|
There seems to be some inconsistency with Java 9. I am looking into this now. |
@zarebski-m I had fun today, thanks 🙏 |
Signed-off-by: Ali Dehghani <ali.dehghani.g@gmail.com>
Signed-off-by: Ali Dehghani <ali.dehghani.g@gmail.com>
Signed-off-by: Ali Dehghani <ali.dehghani.g@gmail.com>
Signed-off-by: Ali Dehghani <ali.dehghani.g@gmail.com>
Signed-off-by: Ali Dehghani <ali.dehghani.g@gmail.com>
According to the documentation, Class#getMethods() does not guarantee any order. https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getMethods--
Signed-off-by: Ali Dehghani <ali.dehghani.g@gmail.com>
Signed-off-by: Ali Dehghani <ali.dehghani.g@gmail.com>
0c100a9
to
ae84f80
Compare
Signed-off-by: Ali Dehghani <ali.dehghani.g@gmail.com>
Signed-off-by: Ali Dehghani <ali.dehghani.g@gmail.com>
Signed-off-by: Ali Dehghani <ali.dehghani.g@gmail.com>
Signed-off-by: Ali Dehghani <ali.dehghani.g@gmail.com>
Signed-off-by: Ali Dehghani <ali.dehghani.g@gmail.com>
Signed-off-by: Ali Dehghani <ali.dehghani.g@gmail.com>
Signed-off-by: Ali Dehghani <ali.dehghani.g@gmail.com>
Signed-off-by: Ali Dehghani <ali.dehghani.g@gmail.com>
@zarebski-m Thanks. Great Work. |
Hello. :) I hope this contribution will be as helpful as the previous one.
Currently response for each error exposes only code and message. Unfortunately, the exception arguments are not exposed explicitly, but only through interpolation of error message.
This feature provides enhancement, where all exception arguments can be exposed as a map. It is regulated by configuration property
spring.errors.expose-arguments
, which by default has valuenever
. This is consistent with current bahavior.When set to
non_empty
oralways
, rensponse payload includes map of named properties. With the following annotation:the following payload will be returned:
There is a problem with Spring Validation – there are no argument names exposed by
ObjectError
. For this problem I've decided to just assign those arguments names"arg0"
,"arg1"
, etc. If you have a better idea, please let me know.Closes #44