-
Notifications
You must be signed in to change notification settings - Fork 193
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
Add server extra tests #1497
Add server extra tests #1497
Changes from all commits
0e8fa80
deb7aec
d4e9c57
6c21fb0
f9ff234
dc3dda0
ea49afc
4dd0c39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../codegen-test/model/rest-json-extras.smithy |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,16 +73,26 @@ service RestJsonExtras { | |
@httpResponseTests([ | ||
{ | ||
documentation: "Upper case error modeled lower case", | ||
id: "ServiceLevelError", | ||
id: "ServiceLevelErrorClient", | ||
protocol: "aws.protocols#restJson1", | ||
code: 500, | ||
body: "", | ||
headers: { "X-Amzn-Errortype": "ExtraError" }, | ||
params: {} | ||
params: {}, | ||
appliesTo: "client", | ||
}, | ||
{ | ||
documentation: "Upper case error modeled lower case", | ||
id: "ServiceLevelErrorServer", | ||
protocol: "aws.protocols#restJson1", | ||
code: 500, | ||
body: "{}", | ||
headers: { "X-Amzn-Errortype": "ExtraError" }, | ||
params: {}, | ||
appliesTo: "server", | ||
} | ||
]) | ||
@error("server") | ||
82marbag marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@error("server") | ||
structure ExtraError {} | ||
|
||
@http(uri: "/StringPayload", method: "POST") | ||
|
@@ -113,7 +123,8 @@ structure StringPayloadInput { | |
uri: "/primitive-document", | ||
method: "POST", | ||
body: "{}", | ||
params: {} | ||
headers: { "Content-Type": "application/json" }, | ||
params: {}, | ||
}]) | ||
@http(uri: "/primitive-document", method: "POST") | ||
operation PrimitiveIntOp { | ||
|
@@ -131,14 +142,14 @@ structure PrimitiveIntDocument { | |
protocol: "aws.protocols#restJson1", | ||
code: 200, | ||
headers: { "x-field": "123" }, | ||
params: { field: 123 } | ||
params: { field: 123 }, | ||
}, | ||
{ | ||
id: "DeserPrimitiveHeaderMissing", | ||
protocol: "aws.protocols#restJson1", | ||
code: 200, | ||
headers: { }, | ||
params: { field: 0 } | ||
params: { field: 0 }, | ||
} | ||
]) | ||
@http(uri: "/primitive", method: "POST") | ||
|
@@ -201,7 +212,8 @@ structure MapWithEnumKeyInputOutput { | |
method: "POST", | ||
protocol: "aws.protocols#restJson1", | ||
body: "{\"map\":{\"enumvalue\":\"something\"}}", | ||
params: { map: { "enumvalue": "something" } } | ||
headers: { "Content-Type": "application/json" }, | ||
params: { map: { "enumvalue": "something" } }, | ||
}, | ||
]) | ||
@httpResponseTests([ | ||
|
@@ -239,6 +251,7 @@ structure EscapedStringValuesInputOutput { | |
method: "POST", | ||
protocol: "aws.protocols#restJson1", | ||
body: "{\"enum\":\"has\\\"quotes\",\"also\\\"has\\\"quotes\":\"test\"}", | ||
headers: { "Content-Type": "application/json" }, | ||
params: { enum: "has\"quotes", someString: "test" }, | ||
} | ||
]) | ||
|
@@ -283,6 +296,7 @@ structure NullInNonSparseOutput { | |
code: 200, | ||
body: "{\"list\":[null,\"one\",null,\"two\",null],\"map\":{\"zero\":null,\"one\":\"1\"}}", | ||
params: { list: ["one", "two"], map: { "one": "1" } }, | ||
appliesTo: "client", | ||
} | ||
]) | ||
operation NullInNonSparse { | ||
|
@@ -296,13 +310,14 @@ operation CaseInsensitiveErrorOperation { | |
|
||
@httpResponseTests([ | ||
{ | ||
documentation: "Upper case error modeled lower case", | ||
documentation: "Upper case error modeled lower case. See: https://github.com/awslabs/smithy-rs/blob/6c21fb0eb377c7120a8179f4537ba99a4b50ba96/rust-runtime/inlineable/src/json_errors.rs#L51-L51", | ||
id: "UpperErrorModeledLower", | ||
protocol: "aws.protocols#restJson1", | ||
code: 500, | ||
body: "{\"Message\": \"hello\"}", | ||
headers: { "X-Amzn-Errortype": "CaseInsensitiveError" }, | ||
params: { message: "hello" } | ||
params: { message: "hello" }, | ||
appliesTo: "client", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would expand the documentation to justify why this is a client-only test; took me a while to figure out why. It turns out that smithy-rs clients should be able to parse error messages if the JSON keys them as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a comment with the link |
||
} | ||
]) | ||
@error("server") | ||
|
@@ -322,7 +337,8 @@ structure EmptyStructWithContentOnWireOpOutput { | |
protocol: "aws.protocols#restJson1", | ||
code: 200, | ||
body: "{\"empty\": {\"value\":\"not actually empty\"}}", | ||
params: { empty: {} } | ||
params: { empty: {} }, | ||
appliesTo: "client", | ||
} | ||
]) | ||
operation EmptyStructWithContentOnWireOp { | ||
|
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.
This test fails for the server because servers are expected to serialize
{}
when the output parameters are empty.Hence why we have a
serverStructureSerializer
that behaves like that. We should arguably modify the Kotlin docs forserverStructureSerializer
calling this out.Anyway, this test can remain for the client only, but we should duplicate it in a new test that only applies to the server and that has
body: "{}"
, and copy over the documentation fromRestJsonGreetingWithErrors
to justify why we're doing so.