Skip to content

Commit

Permalink
Allow accept to be the default document content type
Browse files Browse the repository at this point in the history
  • Loading branch information
JordonPhillips committed Aug 11, 2021
1 parent 768d9dd commit 9cfa328
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ apply NoInputAndNoOutput @httpRequestTests([
method: "POST",
uri: "/NoInputAndNoOutput",
body: ""
},
{
id: "RestJsonNoInputAllowsAccept",
documentation: """
Servers should allow the accept header to be set to the
default content-type.""",
protocol: restJson1,
method: "POST",
uri: "/NoInputAndNoOutput",
body: "",
headers: {
"Accept": "application/json"
},
appliesTo: "server",
}
])

Expand Down Expand Up @@ -63,7 +77,10 @@ apply NoInputAndOutput @httpRequestTests([
protocol: restJson1,
method: "POST",
uri: "/NoInputAndOutputOutput",
body: ""
body: "",
headers: {
"Accept": "application/json"
},
}
])

Expand Down
40 changes: 39 additions & 1 deletion smithy-aws-protocol-tests/model/restJson1/http-payload.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,45 @@ apply HttpPayloadTraits @httpResponseTests([
params: {
foo: "Foo"
}
}
},
{
id: "RestJsonHttpPayloadTraitsWithBlobAcceptsAllContentTypes",
documentation: """
Servers must accept any content type for blob inputs
without the media type trait.""",
protocol: restJson1,
code: 200,
body: "This is definitely a jpeg",
bodyMediaType: "application/octet-stream",
headers: {
"X-Foo": "Foo",
"Content-Type": "image/jpeg"
},
params: {
foo: "Foo",
blob: "This is definitely a jpeg"
},
appliesTo: "server",
},
{
id: "RestJsonHttpPayloadTraitsWithBlobAcceptsAllAccepts",
documentation: """
Servers must accept any accept header for blob inputs
without the media type trait.""",
protocol: restJson1,
code: 200,
body: "This is definitely a jpeg",
bodyMediaType: "application/octet-stream",
headers: {
"X-Foo": "Foo",
"Accept": "image/jpeg"
},
params: {
foo: "Foo",
blob: "This is definitely a jpeg"
},
appliesTo: "server",
},
])

structure HttpPayloadTraitsInputOutput {
Expand Down
1 change: 0 additions & 1 deletion smithy-aws-protocol-tests/model/restJson1/main.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ service RestJson {
MalformedContentTypeWithBody,
MalformedContentTypeWithPayload,
MalformedContentTypeWithGenericString,
MalformedAcceptWithoutBody,
MalformedAcceptWithBody,
MalformedAcceptWithPayload,
MalformedAcceptWithGenericString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,6 @@ use smithy.test#httpMalformedRequestTests
use aws.protocoltests.shared#GreetingStruct
use aws.protocoltests.shared#JpegBlob

apply MalformedAcceptWithoutBody @httpMalformedRequestTests([
{
id: "RestJsonWithoutBodyExpectsEmptyAccept",
documentation: """
When there is no modeled output, accept must not be set.""",
protocol: restJson1,
request: {
method: "POST",
uri: "/MalformedAcceptWithoutBody",
headers: {
// this should be omitted
"accept": "application/json"
}
},
response: {
code: 406,
headers: {
"x-amzn-errortype": "NotAcceptableException"
}
},
tags: [ "accept" ]
}
])

apply MalformedAcceptWithBody @httpMalformedRequestTests([
{
id: "RestJsonWithBodyExpectsApplicationJsonAccept",
Expand Down Expand Up @@ -104,9 +80,6 @@ apply MalformedAcceptWithGenericString @httpMalformedRequestTests([
}
])

@http(method: "POST", uri: "/MalformedAcceptWithoutBody")
operation MalformedAcceptWithoutBody {}

@http(method: "POST", uri: "/MalformedAcceptWithBody")
operation MalformedAcceptWithBody {
output: GreetingStruct
Expand Down

0 comments on commit 9cfa328

Please sign in to comment.