Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON producer adds newline character to the end of JSON body #20

Closed
mandrean opened this issue Nov 11, 2016 · 1 comment
Closed

JSON producer adds newline character to the end of JSON body #20

mandrean opened this issue Nov 11, 2016 · 1 comment

Comments

@mandrean
Copy link

mandrean commented Nov 11, 2016

I've spent the last couple of hours debugging an issue we've run into where the hash of the request body sent (using go-swagger/go-openapi) isn't what it's supposed to be (using other common tools).

I've narrowed it down to the JSON producer, which adds a newline char at the end...

skarmavbild 2016-11-11 kl 13 14 57
skarmavbild 2016-11-11 kl 13 14 30

So I go and have a look at the unit tests. And they seem cheat by appending a newline char in the assert:

https://github.com/go-openapi/runtime/blob/master/json_test.go#L61

assert.Equal(t, consProdJSON+"\n", rw.Body.String())

What the...?

ping @casualjim

@mandrean
Copy link
Author

Up on further investigation, the issue lies even further upstream with how the encoding package handles JSON streams. See https://git.io/vXr1P and https://golang.org/src/encoding/json/stream.go?s=4272:4319#L173

So I guess this issue can be closed but might be a good reference for others later on searching for the same answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant