From 6426c0200f4870d2e0f690808fa3b4c3f1a4519d Mon Sep 17 00:00:00 2001 From: Alex Woods Date: Tue, 29 Oct 2024 16:32:19 -0700 Subject: [PATCH 1/2] Use model to translate operationInput parameters --- .../spec/endpoint_provider_spec_class.rb | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/spec/endpoint_provider_spec_class.rb b/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/spec/endpoint_provider_spec_class.rb index 0ab96126c5d..32c28fb9eb2 100644 --- a/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/spec/endpoint_provider_spec_class.rb +++ b/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/spec/endpoint_provider_spec_class.rb @@ -48,9 +48,7 @@ def initialize(options) @operation_inputs = operation_inputs.map do |operation_inputs_test| OperationInputsTest.new( service: @service, - operation_name: Underscore.underscore( - operation_inputs_test['operationName'] - ), + operation_name: operation_inputs_test['operationName'], operation_params: operation_inputs_test['operationParams'] || {}, built_in_params: operation_inputs_test['builtInParams'] || {}, client_params: operation_inputs_test['clientParams'] || {} @@ -110,9 +108,13 @@ class OperationInputsTest def initialize(options) @service = options[:service] - @operation_name = options[:operation_name] + @api = @service.api + @operation_name = Underscore.underscore(options[:operation_name]) + input_shape_name = @api['operations'][options[:operation_name]]['input']['shape'] + input = @api['shapes'][input_shape_name] @operation_params = options[:operation_params].map do |k,v| - Param.new(Underscore.underscore(k), transform_operation_values(v)) + member_shape = @api['shapes'][input['members'][k]['shape']] + Param.new(Underscore.underscore(k), transform_operation_values(v, member_shape)) end @client_params = options[:client_params].map do |k,v| Param.new(Underscore.underscore(k), v) @@ -138,14 +140,21 @@ def initialize(options) attr_reader :client_params private - def transform_operation_values(value) - case value - when Hash + def transform_operation_values(value, ref) + case ref['type'] + when 'structure', 'union' value.each_with_object({}) do |(k, v), o| - o[Underscore.underscore(k).to_sym] = transform_operation_values(v) + member_shape = @api['shapes'][ref['members'][k]['shape']] + o[Underscore.underscore(k).to_sym] = transform_operation_values(v, member_shape) + end + when 'list' + member_shape = @api['shapes'][ref['member']['shape']] + value.map { |v| transform_operation_values(v, member_shape) } + when 'map' + member_shape = @api['shapes'][ref['value']['shape']] + value.each_with_object({}) do |(k, v), o| + o[k] = transform_operation_values(v, member_shape) end - when Array - value.map { |v| transform_operation_values(v) } else value end From 76575577575af11d5586b9ac21842f44daed786c Mon Sep 17 00:00:00 2001 From: Alex Woods Date: Wed, 30 Oct 2024 10:57:48 -0700 Subject: [PATCH 2/2] Set simple_attributes: false for ddb --- .../views/spec/endpoint_provider_spec_class.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/spec/endpoint_provider_spec_class.rb b/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/spec/endpoint_provider_spec_class.rb index 32c28fb9eb2..205f51a8a61 100644 --- a/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/spec/endpoint_provider_spec_class.rb +++ b/build_tools/aws-sdk-code-generator/lib/aws-sdk-code-generator/views/spec/endpoint_provider_spec_class.rb @@ -128,6 +128,10 @@ def initialize(options) !options[:built_in_params].include?('AWS::S3::UseGlobalEndpoint') @client_params << built_in_to_param('AWS::S3::UseGlobalEndpoint', false) end + + if @service.identifier == 'dynamodb' + @client_params << Param.new(:simple_attributes, false, true) + end end # @return String