-
Notifications
You must be signed in to change notification settings - Fork 470
Experiment: Detect link methods that do NOT return resources #629
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
Conversation
@olivergierke I wrote some code that detects if the Spring MVC endpoints return type is NOT a In this coding, it logs a warning AND throws a This looks like a keen mechanism to warn users that they've misconstructed their controllers. |
Detect endpoints that do NOT return classes assignable to `ResourceSupport`. Question: Do we post a warning, or actually break?
606d9b2
to
36a58a7
Compare
"Wrong JSON"? What problem are we actually solving here? When creating links, we must not care whether the resource we point to is hypermedia enabled or not. How would I point to a controller method serving a PDF? Also, note that it's very common to use |
The problem is that some users of Spring HATEOAS have controllers returning By catching these scenarios, we'll stop getting issues opened like #532, that turned out to simply be a bad return type for Spring HATEOAS. |
I think part of this is due to Seems like a simple thing we can detect and either warn or fail fast for the user. |
Hm, I see. Maybe I am just not getting why this has anything to do with link creation? These are completely orthogonal issues, right? Wrapping an The problem of |
The reason I picked link creation as the point of detection is because it appeared the only place to sniff out the return type of a Spring MVC controller. Well perhaps my check isn't sophisticated enough. If it's a Spring MVC response container, check its payload type? And your point about being intentionally done by the end user is why I speculated this might best be a logged warning, not an exception, perhaps with an option to disable? When I say option to disable, perhaps an annotation that signals "I know what I'm doing" on the endpoint? @SupressResourceValidation or something? |
Related to #690 |
Closed in light of #416. |
>>> DO NOT MERGE <<<
Detect endpoints that do NOT return classes assignable to
ResourceSupport
.Question: Do we post a warning, or actually break?