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

Add JSON protocol tests for document-valued maps #2125

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions smithy-aws-protocol-tests/model/restJson1/documents.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,73 @@ apply DocumentTypeAsPayload @httpResponseTests([
}
}
])

/// This example serializes documents as the value of maps.
@idempotent
@http(uri: "/DocumentTypeAsMapKey", method: "PUT")
operation DocumentTypeAsMapKey {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document is the map value in these tests, all the names should be updated accordingly.

input: DocumentTypeAsMapKeyInputOutput,
output: DocumentTypeAsMapKeyInputOutput,
}

structure DocumentTypeAsMapKeyInputOutput {
docValuedMap: DocumentValuedMap,
}

map DocumentValuedMap {
key: String,
value: Document,
}

apply DocumentTypeAsMapKey @httpRequestTests([
{
id: "DocumentTypeAsMapKeyInput",
documentation: "Serializes a map that uses documents as the value.",
protocol: restJson1,
method: "PUT",
uri: "/DocumentTypeAsMapKey",
body: """
{
"docValuedMap": {
"foo": { "f": 1, "o": 2 },
"bar": [ "b", "a", "r" ],
"baz": "BAZ"
}
}""",
bodyMediaType: "application/json",
headers: {"Content-Type": "application/json"},
params: {
docValuedMap: {
"foo": { "f": 1, "o": 2 },
"bar": [ "b", "a", "r" ],
"baz": "BAZ",
},
},
},
])

apply DocumentTypeAsMapKey @httpResponseTests([
{
id: "DocumentTypeAsMapKeyOutput",
documentation: "Deserializes a map that uses documents as the value.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
documentation: "Deserializes a map that uses documents as the value.",
documentation: "Serializes a map that uses documents as the value.",

nit: Since this isn't client specific

protocol: restJson1,
code: 200,
body: """
{
"docValuedMap": {
"foo": { "f": 1, "o": 2 },
"bar": [ "b", "a", "r" ],
"baz": "BAZ"
}
}""",
bodyMediaType: "application/json",
headers: {"Content-Type": "application/json"},
params: {
docValuedMap: {
"foo": { "f": 1, "o": 2 },
"bar": [ "b", "a", "r" ],
"baz": "BAZ",
},
},
},
])
1 change: 1 addition & 0 deletions smithy-aws-protocol-tests/model/restJson1/main.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ service RestJson {
// Documents
DocumentType,
DocumentTypeAsPayload,
DocumentTypeAsMapKey,

// Unions
JsonUnions,
Expand Down
Loading