-
Notifications
You must be signed in to change notification settings - Fork 66
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
Add the ability to default all JSON fields if not selector specified. #221
Comments
There are a couple of options for this. We have a weekly Google Hangout discussing these types of things, and we thought that overriding the MessageBodyWriter isWritable() method should probably work in your case for the short term. Simply return false if there is no selector parameter in the request or the class isn't one that you want yoga to render. There is another user that did something like that, i.e. only return true if the class is in a particular set of classes that were converted. In the longer term, we need to figure out how to make this type of thing easier. We're working on improving the initial experience, and we'll work to ease the transition from JAX-RS standard behavior to Yoga rendering. Can you please test out the isWritable() approach for the time being? |
Sounds like a good solution Solomon. I'll try it out and get back to you. I might be able to get back to you later today. From: Solomon Duskis <notifications@github.commailto:notifications@github.com> There are a couple of options for this. We have a weekly Google Hangout discussing these types of things, and we thought that overriding the MessageBodyWriter isWritable() method should probably work in your case for the short term. Simply return false if there is no selector parameter in the request or the class isn't one that you want yoga to render. There is another user that did something like that, i.e. only return true if the class is in a particular set of classes that were converted. In the longer term, we need to figure out how to make this type of thing easier. We're working on improving the initial experience, and we'll work to ease the transition from JAX-RS standard behavior to Yoga rendering. Can you please test out the isWritable() approach for the time being? — |
Solomon, I did a quick look and debugged all the variables available in the MessageBodyWriter.isWriteable(). When this method is called, I can't find anything in the class that tells me if there is a selector parameter. The GDataSelectorParser.parse method is called after MessageBodyWriter.isWriteable() is called. Because of that, I don't see how to condition the isWriteable return value. Any ideas? Bob From: Bob Krier <rkrier@axway.commailto:rkrier@axway.com> Sounds like a good solution Solomon. I'll try it out and get back to you. I might be able to get back to you later today. From: Solomon Duskis <notifications@github.commailto:notifications@github.com> There are a couple of options for this. We have a weekly Google Hangout discussing these types of things, and we thought that overriding the MessageBodyWriter isWritable() method should probably work in your case for the short term. Simply return false if there is no selector parameter in the request or the class isn't one that you want yoga to render. There is another user that did something like that, i.e. only return true if the class is in a particular set of classes that were converted. In the longer term, we need to figure out how to make this type of thing easier. We're working on improving the initial experience, and we'll work to ease the transition from JAX-RS standard behavior to Yoga rendering. Can you please test out the isWritable() approach for the time being? — |
You should have access to the HttpServletRequest via the request protected -Solomon On Wed, Jul 31, 2013 at 12:39 PM, Bob Krier notifications@github.comwrote:
|
Sorry, I should have figured that out. I tried it and it works great. Thanks! From: Solomon Duskis <notifications@github.commailto:notifications@github.com> You should have access to the HttpServletRequest via the request protected -Solomon On Wed, Jul 31, 2013 at 12:39 PM, Bob Krier <notifications@github.commailto:notifications@github.com>wrote:
— |
What should we do for spring-mvc? Is there any workaround for it? |
I'm also looking for a solution to this issue for the spring-mvc version. Any input there? |
Selecting all possible fields would cause infinite looping in cases where your persisted objects have a lot of relationships with other persisted objects. I'd rather not add that logic to the ResultTraverser. |
thanks @sduskis for quick reply. i will try that. |
I've been thinking about this (see my comment on the the map issue). I think there may be a value for a non-recursive select all. I definitely understand the danger of a recursive select all. |
I really really love this library and it's very useful, but at the same time it would be great to have it return all fields if no "selector" is specified. Any movement on a solution for this? I'm very keen on using Yoga, it's pretty darn awesome. |
This is a popular request. I'll see if I can finagle * to include a single level of "all fields." I'll also add an alternative "use all if no selector specified" selector mechanism, either in the existing selectors or a new selector type. |
For what it is worth it is possible to do this by extending the JsonSelectorMessageBodyWriter and defining an alternative selector. We have support for @default annotations (of course we had inside help from the skyscreamer team) which show when no selector is specified |
Solomon, that would be fantastic to have both the "*" to return all fields at single level in addition to returning all if no selector is specified. Appreciate you responding so quickly on this and if you have anything to test I will gladly give it a shot. Have a great day. -Chris |
If your entity does not have any @core annotated fields and the client does a GET request without a selector, it would be nice to have the entity return all fields (the default behavior for JAX-WS).
The text was updated successfully, but these errors were encountered: