Configuration option to disable HTML escaping when using Gson#298
Conversation
The default implementation of Gson will escape certain characters by default. This includes the `=` character, which is used in base64 encoding and cause problems when deserializing the value to a base64 encoded string in a service. Adding an option for disabling this feature makes it easier to generate client code with sane defaults.
|
PR to swagger-codegen was approved by @jeff9finger |
|
cc @bbdouglas (2017/07) @JFCote (2017/08) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) for review. |
| }) | ||
| ; | ||
| return fireBuilder.createGsonBuilder(); | ||
| GsonBuilder builder = fireBuilder.createGsonBuilder(); |
There was a problem hiding this comment.
did you forget to put the {{#disableHtmlEscaping}} ?
There was a problem hiding this comment.
No, I did not forget, I chose to always declare the variable and conditionally set disableHtmlEscaping:
{{#disableHtmlEscaping}}
builder.disableHtmlEscaping();
{{/disableHtmlEscaping}}
This keeps the complexity of the mustache code low, and makes it easy to accommodate more options in the future. For example:
{{#disableHtmlEscaping}}
builder.disableHtmlEscaping();
{{/disableHtmlEscaping}}
{{#someNewOption}}
builder.someNewOption();
{{/someNewOption}}
I can modify the template to handle the "no options" situation to avoid declaring the variable in generated Java-classes, if that is preferable?
There was a problem hiding this comment.
It's my bad, since the path to the file was truncated by github UI, I did not realize it was a generated sample. Makes total sense! Keep it that way :)
| }) | ||
| ; | ||
| return fireBuilder.createGsonBuilder(); | ||
| GsonBuilder builder = fireBuilder.createGsonBuilder(); |
| }) | ||
| ; | ||
| return fireBuilder.createGsonBuilder(); | ||
| GsonBuilder builder = fireBuilder.createGsonBuilder(); |
wing328
left a comment
There was a problem hiding this comment.
Tested locally and the result is good 👍
Already merged into swagger-codegen, see 7966.