-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add protocol tests for default values for awsJson1_0
- Loading branch information
1 parent
428c8a1
commit 3a778f5
Showing
4 changed files
with
949 additions
and
1 deletion.
There are no files selected for viewing
342 changes: 342 additions & 0 deletions
342
smithy-aws-protocol-tests/model/awsJson1_0/defaults.smithy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,342 @@ | ||
$version: "2.0" | ||
|
||
namespace aws.protocoltests.json10 | ||
|
||
use aws.protocols#awsJson1_0 | ||
use smithy.test#httpRequestTests | ||
use smithy.test#httpResponseTests | ||
|
||
apply OperationWithDefaults @httpRequestTests([ | ||
{ | ||
id: "AwsJson10ClientPopulatesDefaultValuesInOutputWhenMissing" | ||
documentation: "Client populates default values in output when missing." | ||
appliesTo: "client" | ||
tags: ["defaults"] | ||
protocol: awsJson1_0 | ||
method: "POST" | ||
bodyMediaType: "application/json" | ||
uri: "/" | ||
headers: {"Content-Type": "application/x-amz-json-1.0"} | ||
body: """ | ||
{ | ||
"defaults": { | ||
"defaultString": "hi", | ||
"defaultBoolean": true, | ||
"defaultList": [], | ||
"defaultDocumentMap": {}, | ||
"defaultDocumentString": "hi", | ||
"defaultDocumentBoolean": true, | ||
"defaultDocumentList": [], | ||
"defaultNullDocument": null, | ||
"defaultTimestamp": 0, | ||
"defaultBlob": "{}", | ||
"defaultByte": 1, | ||
"defaultShort": 1, | ||
"defaultInteger": 10, | ||
"defaultLong": 100, | ||
"defaultFloat": 0, | ||
"defaultDouble": 0, | ||
"defaultMap": {}, | ||
"defaultBigInteger": 0, | ||
"defaultBigDecimal": 0, | ||
"defaultEnum": "FOO", | ||
"defaultIntEnum": 1 | ||
} | ||
}""" | ||
params: { | ||
defaults: {} | ||
} | ||
} | ||
{ | ||
id: "AwsJson10ClientUsesExplicitlyProvidedMemberValuesOverDefaults" | ||
documentation: "Client uses explicitly provided member values over defaults" | ||
appliesTo: "client" | ||
tags: ["defaults"] | ||
protocol: awsJson1_0 | ||
method: "POST" | ||
bodyMediaType: "application/json" | ||
uri: "/" | ||
headers: {"Content-Type": "application/x-amz-json-1.0"} | ||
params: { | ||
defaults: { | ||
defaultString: "bye" | ||
defaultBoolean: false | ||
defaultList: ["a"] | ||
defaultDocumentMap: {name: "Jack"} | ||
defaultDocumentString: "bye" | ||
defaultDocumentBoolean: false | ||
defaultDocumentList: ["b"] | ||
defaultNullDocument: "notNull" | ||
defaultTimestamp: 1 | ||
defaultBlob: "abc" | ||
defaultByte: 2 | ||
defaultShort: 2 | ||
defaultInteger: 20 | ||
defaultLong: 200 | ||
defaultFloat: 1 | ||
defaultDouble: 1 | ||
defaultMap: {name: "Jack"} | ||
defaultBigInteger: 1 | ||
defaultBigDecimal: 1 | ||
defaultEnum: "BAR" | ||
defaultIntEnum: 2 | ||
} | ||
} | ||
body: """ | ||
{ | ||
"defaults": { | ||
"defaultString": "bye", | ||
"defaultBoolean": false, | ||
"defaultList": ["a"], | ||
"defaultDocumentMap": {"name": "Jack"}, | ||
"defaultDocumentString": "bye", | ||
"defaultDocumentBoolean": false, | ||
"defaultDocumentList": ["b"], | ||
"defaultNullDocument": "notNull", | ||
"defaultTimestamp": 1, | ||
"defaultBlob": "abc", | ||
"defaultByte": 2, | ||
"defaultShort": 2, | ||
"defaultInteger": 20, | ||
"defaultLong": 200, | ||
"defaultFloat": 1, | ||
"defaultDouble": 1, | ||
"defaultMap": {"name": "Jack"}, | ||
"defaultBigInteger": 1, | ||
"defaultBigDecimal": 1, | ||
"defaultEnum": "BAR", | ||
"defaultIntEnum": 2 | ||
} | ||
}""" | ||
} | ||
{ | ||
id: "AwsJson10ServerPopulatesDefaultsWhenMissingInRequestBody" | ||
documentation: "Server populates default values when missing in request body." | ||
appliesTo: "server" | ||
tags: ["defaults"] | ||
protocol: awsJson1_0 | ||
method: "POST" | ||
bodyMediaType: "application/json" | ||
uri: "/" | ||
headers: {"Content-Type": "application/x-amz-json-1.0"} | ||
body: """ | ||
{ | ||
"defaults": {} | ||
}""" | ||
params: { | ||
defaults: { | ||
defaultString: "hi" | ||
defaultBoolean: true | ||
defaultList: [] | ||
defaultDocumentMap: {} | ||
defaultDocumentString: "hi" | ||
defaultDocumentBoolean: true | ||
defaultDocumentList: [] | ||
defaultNullDocument: null | ||
defaultTimestamp: 0 | ||
defaultBlob: "{}" | ||
defaultByte: 1 | ||
defaultShort: 1 | ||
defaultInteger: 10 | ||
defaultLong: 100 | ||
defaultFloat: 0 | ||
defaultDouble: 0 | ||
defaultMap: {} | ||
defaultBigInteger: 0 | ||
defaultBigDecimal: 0 | ||
defaultEnum: "FOO" | ||
defaultIntEnum: 1 | ||
} | ||
} | ||
} | ||
]) | ||
|
||
apply OperationWithDefaults @httpResponseTests([ | ||
{ | ||
id: "AwsJson10ClientPopulatesDefaultsValuesWhenMissingInResponse" | ||
documentation: "Client populates default values when missing in response." | ||
appliesTo: "client" | ||
tags: ["defaults"] | ||
protocol: awsJson1_0 | ||
code: 200 | ||
bodyMediaType: "application/json" | ||
headers: {"Content-Type": "application/x-amz-json-1.0"} | ||
body: "{}" | ||
params: { | ||
defaultString: "hi" | ||
defaultBoolean: true | ||
defaultList: [] | ||
defaultDocumentMap: {} | ||
defaultDocumentString: "hi" | ||
defaultDocumentBoolean: true | ||
defaultDocumentList: [] | ||
defaultNullDocument: null | ||
defaultTimestamp: 0 | ||
defaultBlob: "{}" | ||
defaultByte: 1 | ||
defaultShort: 1 | ||
defaultInteger: 10 | ||
defaultLong: 100 | ||
defaultFloat: 0 | ||
defaultDouble: 0 | ||
defaultMap: {} | ||
defaultBigInteger: 0 | ||
defaultBigDecimal: 0 | ||
defaultEnum: "FOO" | ||
defaultIntEnum: 1 | ||
} | ||
} | ||
{ | ||
id: "AwsJson10ClientIgnoresDefaultValuesIfMemberValuesArePresentInResponse" | ||
documentation: "Client ignores default values if member values are present in the response." | ||
appliesTo: "client" | ||
tags: ["defaults"] | ||
protocol: awsJson1_0 | ||
code: 200 | ||
bodyMediaType: "application/json" | ||
headers: {"Content-Type": "application/x-amz-json-1.0"} | ||
body: """ | ||
{ | ||
"defaultString": "bye", | ||
"defaultBoolean": false, | ||
"defaultList": ["a"], | ||
"defaultDocumentMap": {"name": "Jack"}, | ||
"defaultDocumentString": "bye", | ||
"defaultDocumentBoolean": false, | ||
"defaultDocumentList": ["b"], | ||
"defaultNullDocument": "notNull", | ||
"defaultTimestamp": 1, | ||
"defaultBlob": "abc", | ||
"defaultByte": 2, | ||
"defaultShort": 2, | ||
"defaultInteger": 20, | ||
"defaultLong": 200, | ||
"defaultFloat": 1, | ||
"defaultDouble": 1, | ||
"defaultMap": {"name": "Jack"}, | ||
"defaultBigInteger": 1, | ||
"defaultBigDecimal": 1, | ||
"defaultEnum": "BAR", | ||
"defaultIntEnum": 2 | ||
}""" | ||
params: { | ||
defaultString: "bye" | ||
defaultBoolean: false | ||
defaultList: ["a"] | ||
defaultDocumentMap: {name: "Jack"} | ||
defaultDocumentString: "bye" | ||
defaultDocumentBoolean: false | ||
defaultDocumentList: ["b"] | ||
defaultNullDocument: "notNull" | ||
defaultTimestamp: 1 | ||
defaultBlob: "abc" | ||
defaultByte: 2 | ||
defaultShort: 2 | ||
defaultInteger: 20 | ||
defaultLong: 200 | ||
defaultFloat: 1 | ||
defaultDouble: 1 | ||
defaultMap: {name: "Jack"} | ||
defaultBigInteger: 1 | ||
defaultBigDecimal: 1 | ||
defaultEnum: "BAR" | ||
defaultIntEnum: 2 | ||
} | ||
} | ||
{ | ||
id: "AwsJson10ServerPopulatesDefaultsInResponseWhenMissingInParams" | ||
documentation: "Server populates default values in response when missing in params." | ||
appliesTo: "server" | ||
tags: ["defaults"] | ||
protocol: awsJson1_0 | ||
code: 200 | ||
bodyMediaType: "application/json" | ||
headers: {"Content-Type": "application/x-amz-json-1.0"} | ||
body: """ | ||
{ | ||
"defaultString": "hi", | ||
"defaultBoolean": true, | ||
"defaultList": [], | ||
"defaultDocumentMap": {}, | ||
"defaultDocumentString": "hi", | ||
"defaultDocumentBoolean": true, | ||
"defaultDocumentList": [], | ||
"defaultNullDocument": null, | ||
"defaultTimestamp": 0, | ||
"defaultBlob": "{}", | ||
"defaultByte": 1, | ||
"defaultShort": 1, | ||
"defaultInteger": 10, | ||
"defaultLong": 100, | ||
"defaultFloat": 0, | ||
"defaultDouble": 0, | ||
"defaultMap": {}, | ||
"defaultBigInteger": 0, | ||
"defaultBigDecimal": 0, | ||
"defaultEnum": "FOO", | ||
"defaultIntEnum": 1 | ||
}""" | ||
params: { | ||
} | ||
} | ||
]) | ||
|
||
operation OperationWithDefaults { | ||
input := { | ||
@required | ||
defaults: Defaults | ||
|
||
topLevelDefault: String = "hi" // Client should ignore default values in input shape | ||
} | ||
|
||
output := with [DefaultsMixin] { | ||
} | ||
} | ||
|
||
structure Defaults with [DefaultsMixin] { | ||
} | ||
|
||
@mixin | ||
structure DefaultsMixin { | ||
defaultString: String = "hi" | ||
defaultBoolean: Boolean = true | ||
defaultList: TestStringList = [] | ||
defaultDocumentMap: Document = {} | ||
defaultDocumentString: Document = "hi" | ||
defaultDocumentBoolean: Document = true | ||
defaultDocumentList: Document = [] | ||
defaultNullDocument: Document = null | ||
defaultTimestamp: Timestamp = 0 | ||
defaultBlob: Blob = "{}" | ||
defaultByte: Byte = 1 | ||
defaultShort: Short = 1 | ||
defaultInteger: Integer = 10 | ||
defaultLong: Long = 100 | ||
defaultFloat: Float = 0 | ||
defaultDouble: Double = 0 | ||
defaultMap: TestStringMap = {} | ||
defaultBigInteger: BigInteger = 0 | ||
defaultBigDecimal: BigDecimal = 0 | ||
defaultEnum: TestEnum = "FOO" | ||
defaultIntEnum: TestIntEnum = 1 | ||
} | ||
|
||
list TestStringList { | ||
member: String | ||
} | ||
|
||
map TestStringMap { | ||
key: String | ||
value: String | ||
} | ||
|
||
enum TestEnum { | ||
FOO | ||
BAR | ||
BAZ | ||
} | ||
|
||
intEnum TestIntEnum { | ||
ONE = 1 | ||
TWO = 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.