To allow user to customize the root element of xml output - #272
Conversation
There was a problem hiding this comment.
@bajtos when input is string, js2xmlparser gets syntax error, then try catch block from sendBodyXml() throws 500 , should we modify the data so it doesn't internal server error? or should we not let user pass in just one string. (We do modify the data when passed as array)
|
also added {
"returns": {
"root": true,
"xml": { "declaration": false }
},
"http": { "path": "/" }
}to not include the declaration of <?xml version="1.0" encoding="UTF-8"?>To address this https://github.com/strongloop-internal/scrum-cs/issues/396
@bajtos, @ritch not sure if this feature is needed, and not sure where to add documentation for such, any advice? |
I don't think this exactly addresses the issue, but it might be a welcome feature. |
There was a problem hiding this comment.
use typeof input not typeof(input)
b8ecc8f to
ff0e7a9
Compare
|
@ritch, I have addressed the 2 suggestions you made, please review |
|
@bajtos review please :) |
|
@slnode test please |
There was a problem hiding this comment.
AFAICT, this is adding another feature, which is to allow the developer to specify whether XML declaration is included in the response. I can live with the fact that it's introduced together with other changes, but please add a unit-test to verify.
There was a problem hiding this comment.
Unit-test added.
|
@davidcheung reviewed, see my comments above. |
|
hi @bajtos, have added unit test for the changes. Please review again :) |
There was a problem hiding this comment.
Please modify the test to use a custom root element, e.g. <text> instead of <response>.
|
@davidcheung great, this is almost ready. Please address my comments above and squash the commits into a single one. Make sure the commit message mentions all new features ( |
3adba80 to
b4689ac
Compare
|
@bajtos i have addressed the comments above, I believe the PR is good to go. Please review again |
There was a problem hiding this comment.
...xml declaration..., not decoration.
|
@slnode test please |
- Add option to customize the XML rootElement tag
(default: "response")
- Add flag to disable declaration from response
(default: declaration is present)
- Bugfix changing behavior: `string` results from remote methods are
now quoted to avoid json2xmlparser throwing syntax error and returning
500 instead of a regular response body.
User can set the returned XML root element as follows:
"returns": {
"xml": { "wrapperElement": "Parent" }
}
User can disable XML declaration as follows:
"returns": {
"xml": { "declaration": false }
}
b4689ac to
ba5b064
Compare
|
@davidcheung I have fixed the test name myself and improved the commit message a bit. The patch LGTM, I'll land it as soon as I get CI build results. |
To allow user to customize the root element of xml output
- Add option to customize the XML rootElement tag
(default: "response")
- Add flag to disable declaration from response
(default: declaration is present)
- Bugfix changing behavior: `string` results from remote methods are
now quoted to avoid json2xmlparser throwing syntax error and returning
500 instead of a regular response body.
User can set the returned XML root element as follows:
"returns": {
"xml": { "wrapperElement": "Parent" }
}
User can disable XML declaration as follows:
"returns": {
"xml": { "declaration": false }
}
This is a back-port of the following GitHub pull request:
#272
To take wrapperElement as an option in remoteMethod setup
Objective is to allow user to produce output as follow
Fixes #262
connected to /issues/262