Skip to content

Commit

Permalink
fix(go-sdk): dont escape HTML characters in conditions
Browse files Browse the repository at this point in the history
The behaviour of json.Marshal is to escape any HTML characters in a string, by using json.Encoder
we are able to disable the escaping of these characters
  • Loading branch information
ewanharris committed Jan 23, 2024
1 parent 34a8deb commit d37c09a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions config/clients/go/template/model.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ package {{packageName}}

{{#models}}
import (
{{#model}}
{{^isEnum}}
"bytes"
{{/isEnum}}
{{/model}}

"encoding/json"
{{#imports}}
"{{import}}"
Expand Down
9 changes: 8 additions & 1 deletion config/clients/go/template/model_simple.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,14 @@ func (o {{classname}}) MarshalJSON() ([]byte, error) {
}
{{/isAdditionalPropertiesTrue}}
return json.Marshal(toSerialize)
var b bytes.Buffer
enc := json.NewEncoder(&b)
enc.SetEscapeHTML(false)
err := enc.Encode(toSerialize)
if err != nil {
return nil, err
}
return b.Bytes(), nil
}
{{#isAdditionalPropertiesTrue}}
Expand Down

0 comments on commit d37c09a

Please sign in to comment.