postman-code-generators
postman-code-generators copied to clipboard
Go: Wrong code generation if body contains an empty string in string array
Describe the bug Wrong Go code is generated if the request body of type array of string contains an empty string. ex. ["b", "", "a"]
To Reproduce Use following request body and generate go code
[
"b",
"",
"a"
]
Expected code snippet and corresponding request Request -
curl --location --request POST 'https://example.com/users/roles' \
--header 'Content-Type: application/json' \
--data-raw '[
"b",
"",
"a"
]'
Generated code - https://play.golang.org/p/kJuPMKHIm__y
payload := strings.NewReader(`[`+"
"+`
"b",`+"
"+`
"",`+"
"+`
"a"`+"
"+`
]`)
Expected code - https://play.golang.org/p/q35o4Ll4NMV
payload := strings.NewReader(`[
"b",
"",
"a"
]`)
Screenshots N/A
Additional context I feel, additional spaces are causing problems. If we can omit the space and use raw body, this problem can be fixed.
Version of postman-code-generators/Postman app: Postman v8.8.0
@akshaybharambe14 This issue seems to have been fixed in the latest version of Postman (v10.13). Can you confirm?
Strange, I am using Version 10.13.6 and it is still producing the same result.