-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
private/protocol/restjson: Define JSONValue marshaling for body and querystring #1640
Conversation
ea89600
to
ac7e163
Compare
@@ -1354,6 +1387,27 @@ | |||
"name": "OperationName" | |||
}, | |||
"params": { | |||
"Body": { | |||
"BodyListField": [{"Foo":"Bar"}] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is testing for empty output, may want to have nothing in the params.
"response": { | ||
"status_code": 200, | ||
"headers": {}, | ||
"body": "{\"BodyListField\":[\"{\\\"Foo\\\":\\\"Bar\\\"}\"]}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
if err != nil { | ||
return fmt.Errorf("unable to encode JSONValue, %v", err) | ||
} | ||
buf.WriteString(str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized we squash all these error. Is that something we want to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
definitely want to return errors from these functions. If the protocol marshaler is squashing them then those marshalers should be updated not to squash the errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah you mean errors on write, sorry missed that. Those should be captured... I don't think the SDK does that for any writes currently like this since the type is a bytes.buffer.
private/protocol/jsonvalue.go
Outdated
fmt.Println("JSONVAlue decode", u, v, err) | ||
b = []byte(u) | ||
default: | ||
b = []byte(v) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to default to NoEscape
? We may want to check for NoEscape
in a switch case and return an error, if it is of invalid escaping type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this do a switch on the known types and return an error if the escape mode is a value that is unknown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, that sounds good
@@ -0,0 +1,69 @@ | |||
package protocol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to add tests for these new functions.
ac7e163
to
809795b
Compare
Adds support for APIs which use JSONValue for body and querystring targets.
Fix #1636