diff --git a/codegen/gradle.properties b/codegen/gradle.properties index eb24dc2cb3c..99fe933907c 100644 --- a/codegen/gradle.properties +++ b/codegen/gradle.properties @@ -1 +1 @@ -smithyVersion=1.17.0 +smithyVersion=1.21.0 diff --git a/codegen/sdk-codegen/aws-models/api-gateway.json b/codegen/sdk-codegen/aws-models/api-gateway.json index b7202b6fcbe..e592cf9407e 100644 --- a/codegen/sdk-codegen/aws-models/api-gateway.json +++ b/codegen/sdk-codegen/aws-models/api-gateway.json @@ -8318,6 +8318,7 @@ "traits": { "smithy.api#documentation": "

[Required] Specifies a put integration request's HTTP method.

", "smithy.api#httpLabel": {}, + "smithy.api#jsonName": "requestHttpMethod", "smithy.api#required": {} } }, diff --git a/internal/protocoltest/awsrestjson/api_op_AllQueryStringTypes_test.go b/internal/protocoltest/awsrestjson/api_op_AllQueryStringTypes_test.go index 3c5fc9a8c8c..2830a5dc7ef 100644 --- a/internal/protocoltest/awsrestjson/api_op_AllQueryStringTypes_test.go +++ b/internal/protocoltest/awsrestjson/api_op_AllQueryStringTypes_test.go @@ -176,6 +176,14 @@ func TestClient_AllQueryStringTypes_awsRestjson1Serialize(t *testing.T) { Params: &AllQueryStringTypesInput{ QueryFloat: ptr.Float32(float32(math.NaN())), QueryDouble: ptr.Float64(math.NaN()), + QueryParamsMapOfStringList: map[string][]string{ + "Float": { + "NaN", + }, + "Double": { + "NaN", + }, + }, }, ExpectMethod: "GET", ExpectURIPath: "/AllQueryStringTypesInput", @@ -192,6 +200,14 @@ func TestClient_AllQueryStringTypes_awsRestjson1Serialize(t *testing.T) { Params: &AllQueryStringTypesInput{ QueryFloat: ptr.Float32(float32(math.Inf(1))), QueryDouble: ptr.Float64(math.Inf(1)), + QueryParamsMapOfStringList: map[string][]string{ + "Float": { + "Infinity", + }, + "Double": { + "Infinity", + }, + }, }, ExpectMethod: "GET", ExpectURIPath: "/AllQueryStringTypesInput", @@ -208,6 +224,14 @@ func TestClient_AllQueryStringTypes_awsRestjson1Serialize(t *testing.T) { Params: &AllQueryStringTypesInput{ QueryFloat: ptr.Float32(float32(math.Inf(-1))), QueryDouble: ptr.Float64(math.Inf(-1)), + QueryParamsMapOfStringList: map[string][]string{ + "Float": { + "-Infinity", + }, + "Double": { + "-Infinity", + }, + }, }, ExpectMethod: "GET", ExpectURIPath: "/AllQueryStringTypesInput", diff --git a/internal/protocoltest/awsrestjson/api_op_MalformedSet.go b/internal/protocoltest/awsrestjson/api_op_MalformedSet.go index aa71b061234..e3bf083812d 100644 --- a/internal/protocoltest/awsrestjson/api_op_MalformedSet.go +++ b/internal/protocoltest/awsrestjson/api_op_MalformedSet.go @@ -25,6 +25,8 @@ func (c *Client) MalformedSet(ctx context.Context, params *MalformedSetInput, op } type MalformedSetInput struct { + BlobSet [][]byte + Set []string noSmithyDocumentSerde diff --git a/internal/protocoltest/awsrestjson/api_op_PostPlayerAction.go b/internal/protocoltest/awsrestjson/api_op_PostPlayerAction.go index c6da868e356..da5ffec4e82 100644 --- a/internal/protocoltest/awsrestjson/api_op_PostPlayerAction.go +++ b/internal/protocoltest/awsrestjson/api_op_PostPlayerAction.go @@ -27,8 +27,6 @@ func (c *Client) PostPlayerAction(ctx context.Context, params *PostPlayerActionI } type PostPlayerActionInput struct { - - // This member is required. Action types.PlayerAction noSmithyDocumentSerde @@ -84,9 +82,6 @@ func (c *Client) addOperationPostPlayerActionMiddlewares(stack *middleware.Stack if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { return err } - if err = addOpPostPlayerActionValidationMiddleware(stack); err != nil { - return err - } if err = stack.Initialize.Add(newServiceMetadataMiddleware_opPostPlayerAction(options.Region), middleware.Before); err != nil { return err } diff --git a/internal/protocoltest/awsrestjson/api_op_StreamingTraitsRequireLength.go b/internal/protocoltest/awsrestjson/api_op_StreamingTraitsRequireLength.go index 7f3fe03503f..c545d6f38fa 100644 --- a/internal/protocoltest/awsrestjson/api_op_StreamingTraitsRequireLength.go +++ b/internal/protocoltest/awsrestjson/api_op_StreamingTraitsRequireLength.go @@ -37,10 +37,6 @@ type StreamingTraitsRequireLengthInput struct { } type StreamingTraitsRequireLengthOutput struct { - Blob io.ReadCloser - - Foo *string - // Metadata pertaining to the operation's result. ResultMetadata middleware.Metadata @@ -83,6 +79,9 @@ func (c *Client) addOperationStreamingTraitsRequireLengthMiddlewares(stack *midd if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { return err } + if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { + return err + } if err = stack.Initialize.Add(newServiceMetadataMiddleware_opStreamingTraitsRequireLength(options.Region), middleware.Before); err != nil { return err } diff --git a/internal/protocoltest/awsrestjson/api_op_StreamingTraitsRequireLength_test.go b/internal/protocoltest/awsrestjson/api_op_StreamingTraitsRequireLength_test.go index c3895058eba..9810f90068a 100644 --- a/internal/protocoltest/awsrestjson/api_op_StreamingTraitsRequireLength_test.go +++ b/internal/protocoltest/awsrestjson/api_op_StreamingTraitsRequireLength_test.go @@ -7,18 +7,13 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/aws" awshttp "github.com/aws/aws-sdk-go-v2/aws/transport/http" - smithydocument "github.com/aws/smithy-go/document" smithyio "github.com/aws/smithy-go/io" "github.com/aws/smithy-go/middleware" "github.com/aws/smithy-go/ptr" smithyrand "github.com/aws/smithy-go/rand" smithytesting "github.com/aws/smithy-go/testing" - smithyhttp "github.com/aws/smithy-go/transport/http" - "github.com/google/go-cmp/cmp" - "github.com/google/go-cmp/cmp/cmpopts" "io" "io/ioutil" - "math" "net/http" "net/http/httptest" "net/url" @@ -155,108 +150,3 @@ func TestClient_StreamingTraitsRequireLength_awsRestjson1Serialize(t *testing.T) }) } } - -func TestClient_StreamingTraitsRequireLength_awsRestjson1Deserialize(t *testing.T) { - cases := map[string]struct { - StatusCode int - Header http.Header - BodyMediaType string - Body []byte - ExpectResult *StreamingTraitsRequireLengthOutput - }{ - // Serializes a blob in the HTTP payload with a required length - "RestJsonStreamingTraitsRequireLengthWithBlob": { - StatusCode: 200, - Header: http.Header{ - "Content-Type": []string{"application/octet-stream"}, - "X-Foo": []string{"Foo"}, - }, - BodyMediaType: "application/octet-stream", - Body: []byte(`blobby blob blob`), - ExpectResult: &StreamingTraitsRequireLengthOutput{ - Foo: ptr.String("Foo"), - Blob: smithyio.ReadSeekNopCloser{ReadSeeker: bytes.NewReader([]byte("blobby blob blob"))}, - }, - }, - // Serializes an empty blob in the HTTP payload - "RestJsonStreamingTraitsRequireLengthWithNoBlobBody": { - StatusCode: 200, - Header: http.Header{ - "X-Foo": []string{"Foo"}, - }, - BodyMediaType: "application/octet-stream", - Body: []byte(``), - ExpectResult: &StreamingTraitsRequireLengthOutput{ - Foo: ptr.String("Foo"), - }, - }, - } - for name, c := range cases { - t.Run(name, func(t *testing.T) { - serverURL := "http://localhost:8888/" - client := New(Options{ - HTTPClient: smithyhttp.ClientDoFunc(func(r *http.Request) (*http.Response, error) { - headers := http.Header{} - for k, vs := range c.Header { - for _, v := range vs { - headers.Add(k, v) - } - } - if len(c.BodyMediaType) != 0 && len(headers.Values("Content-Type")) == 0 { - headers.Set("Content-Type", c.BodyMediaType) - } - response := &http.Response{ - StatusCode: c.StatusCode, - Header: headers, - Request: r, - } - if len(c.Body) != 0 { - response.ContentLength = int64(len(c.Body)) - response.Body = ioutil.NopCloser(bytes.NewReader(c.Body)) - } else { - - response.Body = http.NoBody - } - return response, nil - }), - APIOptions: []func(*middleware.Stack) error{ - func(s *middleware.Stack) error { - s.Finalize.Clear() - s.Initialize.Remove(`OperationInputValidation`) - return nil - }, - }, - EndpointResolver: EndpointResolverFunc(func(region string, options EndpointResolverOptions) (e aws.Endpoint, err error) { - e.URL = serverURL - e.SigningRegion = "us-west-2" - return e, err - }), - IdempotencyTokenProvider: smithyrand.NewUUIDIdempotencyToken(&smithytesting.ByteLoop{}), - Region: "us-west-2", - }) - var params StreamingTraitsRequireLengthInput - result, err := client.StreamingTraitsRequireLength(context.Background(), ¶ms) - if err != nil { - t.Fatalf("expect nil err, got %v", err) - } - if result == nil { - t.Fatalf("expect not nil result") - } - opts := cmp.Options{ - cmpopts.IgnoreUnexported( - middleware.Metadata{}, - ), - cmp.FilterValues(func(x, y float64) bool { - return math.IsNaN(x) && math.IsNaN(y) - }, cmp.Comparer(func(_, _ interface{}) bool { return true })), - cmp.FilterValues(func(x, y float32) bool { - return math.IsNaN(float64(x)) && math.IsNaN(float64(y)) - }, cmp.Comparer(func(_, _ interface{}) bool { return true })), - cmpopts.IgnoreTypes(smithydocument.NoSerde{}), - } - if err := smithytesting.CompareValues(c.ExpectResult, result, opts...); err != nil { - t.Errorf("expect c.ExpectResult value match:\n%v", err) - } - }) - } -} diff --git a/internal/protocoltest/awsrestjson/deserializers.go b/internal/protocoltest/awsrestjson/deserializers.go index bf5fd2a5dbd..c50aa004c5a 100644 --- a/internal/protocoltest/awsrestjson/deserializers.go +++ b/internal/protocoltest/awsrestjson/deserializers.go @@ -8493,14 +8493,10 @@ func (m *awsRestjson1_deserializeOpStreamingTraitsRequireLength) HandleDeseriali output := &StreamingTraitsRequireLengthOutput{} out.Result = output - err = awsRestjson1_deserializeOpHttpBindingsStreamingTraitsRequireLengthOutput(output, response) - if err != nil { - return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("failed to decode response with invalid Http bindings, %w", err)} - } - - err = awsRestjson1_deserializeOpDocumentStreamingTraitsRequireLengthOutput(output, response.Body) - if err != nil { - return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("failed to deserialize response payload, %w", err)} + if _, err = io.Copy(ioutil.Discard, response.Body); err != nil { + return out, metadata, &smithy.DeserializationError{ + Err: fmt.Errorf("failed to discard response body, %w", err), + } } return out, metadata, err @@ -8557,27 +8553,6 @@ func awsRestjson1_deserializeOpErrorStreamingTraitsRequireLength(response *smith } } -func awsRestjson1_deserializeOpHttpBindingsStreamingTraitsRequireLengthOutput(v *StreamingTraitsRequireLengthOutput, response *smithyhttp.Response) error { - if v == nil { - return fmt.Errorf("unsupported deserialization for nil %T", v) - } - - if headerValues := response.Header.Values("X-Foo"); len(headerValues) != 0 { - headerValues[0] = strings.TrimSpace(headerValues[0]) - v.Foo = ptr.String(headerValues[0]) - } - - return nil -} -func awsRestjson1_deserializeOpDocumentStreamingTraitsRequireLengthOutput(v *StreamingTraitsRequireLengthOutput, body io.ReadCloser) error { - if v == nil { - return fmt.Errorf("unsupported deserialization of nil %T", v) - } - - v.Blob = body - return nil -} - type awsRestjson1_deserializeOpStreamingTraitsWithMediaType struct { } diff --git a/internal/protocoltest/awsrestjson/serializers.go b/internal/protocoltest/awsrestjson/serializers.go index a84a9a89ee6..fa8183b0aac 100644 --- a/internal/protocoltest/awsrestjson/serializers.go +++ b/internal/protocoltest/awsrestjson/serializers.go @@ -3709,6 +3709,13 @@ func awsRestjson1_serializeOpDocumentMalformedSetInput(v *MalformedSetInput, val object := value.Object() defer object.Close() + if v.BlobSet != nil { + ok := object.Key("blobSet") + if err := awsRestjson1_serializeDocumentBlobSet(v.BlobSet, ok); err != nil { + return err + } + } + if v.Set != nil { ok := object.Key("set") if err := awsRestjson1_serializeDocumentSimpleSet(v.Set, ok); err != nil { @@ -6044,6 +6051,20 @@ func awsRestjson1_serializeOpHttpBindingsUnitInputAndOutputInput(v *UnitInputAnd return nil } +func awsRestjson1_serializeDocumentBlobSet(v [][]byte, value smithyjson.Value) error { + array := value.Array() + defer array.Close() + + for i := range v { + av := array.Value() + if vv := v[i]; vv == nil { + continue + } + av.Base64EncodeBytes(v[i]) + } + return nil +} + func awsRestjson1_serializeDocumentDenseBooleanMap(v map[string]bool, value smithyjson.Value) error { object := value.Object() defer object.Close() diff --git a/internal/protocoltest/awsrestjson/validators.go b/internal/protocoltest/awsrestjson/validators.go index 992429859fe..90e5a10187d 100644 --- a/internal/protocoltest/awsrestjson/validators.go +++ b/internal/protocoltest/awsrestjson/validators.go @@ -529,26 +529,6 @@ func (m *validateOpMalformedTimestampQueryHttpDate) HandleInitialize(ctx context return next.HandleInitialize(ctx, in) } -type validateOpPostPlayerAction struct { -} - -func (*validateOpPostPlayerAction) ID() string { - return "OperationInputValidation" -} - -func (m *validateOpPostPlayerAction) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( - out middleware.InitializeOutput, metadata middleware.Metadata, err error, -) { - input, ok := in.Parameters.(*PostPlayerActionInput) - if !ok { - return out, metadata, fmt.Errorf("unknown input parameters type %T", in.Parameters) - } - if err := validateOpPostPlayerActionInput(input); err != nil { - return out, metadata, err - } - return next.HandleInitialize(ctx, in) -} - func addOpConstantQueryStringValidationMiddleware(stack *middleware.Stack) error { return stack.Initialize.Add(&validateOpConstantQueryString{}, middleware.After) } @@ -653,10 +633,6 @@ func addOpMalformedTimestampQueryHttpDateValidationMiddleware(stack *middleware. return stack.Initialize.Add(&validateOpMalformedTimestampQueryHttpDate{}, middleware.After) } -func addOpPostPlayerActionValidationMiddleware(stack *middleware.Stack) error { - return stack.Initialize.Add(&validateOpPostPlayerAction{}, middleware.After) -} - func validateOpConstantQueryStringInput(v *ConstantQueryStringInput) error { if v == nil { return nil @@ -1091,18 +1067,3 @@ func validateOpMalformedTimestampQueryHttpDateInput(v *MalformedTimestampQueryHt return nil } } - -func validateOpPostPlayerActionInput(v *PostPlayerActionInput) error { - if v == nil { - return nil - } - invalidParams := smithy.InvalidParamsError{Context: "PostPlayerActionInput"} - if v.Action == nil { - invalidParams.Add(smithy.NewErrParamRequired("Action")) - } - if invalidParams.Len() > 0 { - return invalidParams - } else { - return nil - } -}