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

Expand default value protocol tests #2049

Merged
Merged
Changes from all commits
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
136 changes: 131 additions & 5 deletions smithy-aws-protocol-tests/model/awsJson1_0/defaults.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@ apply OperationWithDefaults @httpRequestTests([
"defaultDouble": 1.0,
"defaultMap": {},
"defaultEnum": "FOO",
"defaultIntEnum": 1
"defaultIntEnum": 1,
"emptyString": "",
"falseBoolean": false,
"emptyBlob": "",
"zeroByte": 0,
"zeroShort": 0,
"zeroInteger": 0,
"zeroLong": 0,
"zeroFloat": 0.0,
"zeroDouble": 0.0
}
}"""
params: {
Expand Down Expand Up @@ -91,6 +100,15 @@ apply OperationWithDefaults @httpRequestTests([
defaultMap: {name: "Jack"}
defaultEnum: "BAR"
defaultIntEnum: 2
emptyString: "foo"
falseBoolean: true
emptyBlob: "hi"
zeroByte: 1
zeroShort: 1
zeroInteger: 1
zeroLong: 1
zeroFloat: 1.0
zeroDouble: 1.0
}
}
body: """
Expand All @@ -114,7 +132,16 @@ apply OperationWithDefaults @httpRequestTests([
"defaultDouble": 2.0,
"defaultMap": {"name": "Jack"},
"defaultEnum": "BAR",
"defaultIntEnum": 2
"defaultIntEnum": 2,
"emptyString": "foo",
"falseBoolean": true,
"emptyBlob": "aGk=",
"zeroByte": 1,
"zeroShort": 1,
"zeroInteger": 1,
"zeroLong": 1,
"zeroFloat": 1.0,
"zeroDouble": 1.0
}
}"""
}
Expand Down Expand Up @@ -152,8 +179,56 @@ apply OperationWithDefaults @httpRequestTests([
defaultMap: {}
defaultEnum: "FOO"
defaultIntEnum: 1
emptyString: ""
falseBoolean: false
emptyBlob: ""
zeroByte: 0
zeroShort: 0
zeroInteger: 0
zeroLong: 0
zeroFloat: 0.0
zeroDouble: 0.0
},
topLevelDefault: "hi"
otherTopLevelDefault: 0
}
}
{
id: "AwsJson10ClientUsesExplicitlyProvidedValuesInTopLevel"
documentation: "Any time a value is provided for a member in the top level of input, it is used, regardless of if its the default."
appliesTo: "client"
tags: ["defaults"]
protocol: awsJson1_0
method: "POST"
bodyMediaType: "application/json"
uri: "/"
headers: {"Content-Type": "application/x-amz-json-1.0"}
body: """
{
"topLevelDefault": "hi",
"otherTopLevelDefault": 0
}"""
params: {
topLevelDefault: "hi"
otherTopLevelDefault: 0
}
}
{
id: "AwsJson10ClientIgnoresNonTopLevelDefaultsOnMembersWithClientOptional"
documentation: "Typically, non top-level members would have defaults filled in, but if they have the clientOptional trait, the defaults should be ignored."
appliesTo: "client"
tags: ["defaults"]
protocol: awsJson1_0
method: "POST"
bodyMediaType: "application/json"
uri: "/"
headers: {"Content-Type": "application/x-amz-json-1.0"}
body: """
{
"clientOptionalDefaults": {}
}"""
params: {
clientOptionalDefaults: {}
}
}
])
Expand Down Expand Up @@ -188,6 +263,15 @@ apply OperationWithDefaults @httpResponseTests([
defaultMap: {}
defaultEnum: "FOO"
defaultIntEnum: 1
emptyString: ""
falseBoolean: false
emptyBlob: ""
zeroByte: 0
zeroShort: 0
zeroInteger: 0
zeroLong: 0
zeroFloat: 0.0
zeroDouble: 0.0
}
}
{
Expand Down Expand Up @@ -219,7 +303,16 @@ apply OperationWithDefaults @httpResponseTests([
"defaultDouble": 2.0,
"defaultMap": {"name": "Jack"},
"defaultEnum": "BAR",
"defaultIntEnum": 2
"defaultIntEnum": 2,
"emptyString": "foo",
"falseBoolean": true,
"emptyBlob": "aGk=",
"zeroByte": 1,
"zeroShort": 1,
"zeroInteger": 1,
"zeroLong": 1,
"zeroFloat": 1.0,
"zeroDouble": 1.0
}"""
params: {
defaultString: "bye"
Expand All @@ -241,6 +334,15 @@ apply OperationWithDefaults @httpResponseTests([
defaultMap: {name: "Jack"}
defaultEnum: "BAR"
defaultIntEnum: 2
emptyString: "foo"
falseBoolean: true
emptyBlob: "hi"
zeroByte: 1
zeroShort: 1
zeroInteger: 1
zeroLong: 1
zeroFloat: 1.0
zeroDouble: 1.0
}
}
{
Expand Down Expand Up @@ -271,7 +373,16 @@ apply OperationWithDefaults @httpResponseTests([
"defaultDouble": 1.0,
"defaultMap": {},
"defaultEnum": "FOO",
"defaultIntEnum": 1
"defaultIntEnum": 1,
"emptyString": "",
"falseBoolean": false,
"emptyBlob": "",
"zeroByte": 0,
"zeroShort": 0,
"zeroInteger": 0,
"zeroLong": 0,
"zeroFloat": 0.0,
"zeroDouble": 0.0
}"""
params: {}
}
Expand All @@ -280,15 +391,21 @@ apply OperationWithDefaults @httpResponseTests([
operation OperationWithDefaults {
input := {
defaults: Defaults

clientOptionalDefaults: ClientOptionalDefaults
topLevelDefault: String = "hi" // Client should ignore default values in input shape
otherTopLevelDefault: Integer = 0
}

output := with [DefaultsMixin] {}
}

structure Defaults with [DefaultsMixin] {}

structure ClientOptionalDefaults {
@clientOptional
member: Integer = 0
}

@mixin
structure DefaultsMixin {
defaultString: String = "hi"
Expand All @@ -310,6 +427,15 @@ structure DefaultsMixin {
defaultMap: TestStringMap = {}
defaultEnum: TestEnum = "FOO"
defaultIntEnum: TestIntEnum = 1
emptyString: String = ""
falseBoolean: Boolean = false
emptyBlob: Blob = ""
zeroByte: Byte = 0
zeroShort: Short = 0
zeroInteger: Integer = 0
zeroLong: Long = 0
zeroFloat: Float = 0.0
zeroDouble: Double = 0.0
}

list TestStringList {
Expand Down