Fix REST API response of methods with String return type - #754
Conversation
geomacy
left a comment
There was a problem hiding this comment.
Can you add some explanation of what the problem is and how this change fixes it?
| @ApiResponses(value = { | ||
| @ApiResponse(code = 404, message = "Could not find task or stream") | ||
| }) | ||
| @Produces(MediaType.TEXT_PLAIN + ";qs=0.9") |
There was a problem hiding this comment.
why the qs? it's not actually a valid parameter on Content-Type, it's some sort of Apache webserver hack.
c54775a to
299c2ab
Compare
…tGetConfig tests to work with the rest api fix
|
retest this please |
|
I got the following: looks like it is caused by the changed response format. |
|
@iyovcheva I think this breaks backwards compatibility so we need to be clear where and what it is changing and what it might impact. Agree it makes sense to be clear are we returning JSON (e.g. wrap string in quotes) or PLAIN. However we may also have the problem that in some places a string we return will itself be wrapped. And in other places the client might want an unwrapped string (ie not JSON). |
|
Thanks @geomacy , I updated the test. "retest this please" triggers a rebuild. |
|
@ahgittin This is a list of the GET requests the change impacts: The one that was broken in the UI was For The controversial options IMO are the two What do you think about:
|
|
👍 +1 to your suggestions @iyovcheva If I understand correctly, the changes to add |
|
Suggest we keep the changes for @ahgittin Backwards compatibility is debatable. If we used to return plain strings as |
|
per @neykov's suggestion, merging this with the policy changes included. |
Fix REST API response of methods with String return type Using the REST API from the GUI used to return `"error": "no response from server"` and return code 0 for methods that return String. The problem was that the received response was not in json format, while the expected response content type is `application/json`.
| Map<String, Object> result = Maps.newLinkedHashMap(); | ||
| for (Map.Entry<String, Object> ek : source.entrySet()) { | ||
| result.put(ek.getKey(), getStringValueForDisplay(brooklyn(), policy, ek.getValue())); | ||
| result.put(ek.getKey(), WebResourceUtils.getValueForDisplay(mapper(), getStringValueForDisplay(brooklyn(), policy, ek.getValue()), true, true)); |
There was a problem hiding this comment.
This is not needed, fixes only needed for methods returning String. This one will get converted to json by the framework.
Using the REST API from the GUI used to return
"error": "no response from server"and return code 0 for methods that return String.The problem was that the received response was not in json format, while the expected response content type is
application/json.