Skip to content

Commit

Permalink
Ignore unknown metadata and shape keys
Browse files Browse the repository at this point in the history
  • Loading branch information
alextwoods committed Aug 28, 2024
1 parent ffd96a8 commit b9fb735
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,31 @@ def deprecated?
@deprecated
end

# @return list of validation messages
def validate
errors = []
@api.fetch('metadata', {}).keys.sort.each do |key|
if AwsSdkCodeGenerator::Views::ClientApiModule::METADATA_KEYS[key].nil?
errors << {
type: :invalid_key,
message: "invalid/unsupported metadata key `#{key}`"
}
end
end

@api.fetch('shapes', {}).each do |shape_name, shape|
shape.each_pair do |key, _|
unless AwsSdkCodeGenerator::Views::ClientApiModule::SHAPE_KEYS.key?(key)
errors << {
type: :invalid_key,
message: "invalid/unsupported shape key `#{key}` on `#{shape_name}`"
}
end
end
end
errors
end

# @api private
def inspect
"#<#{self.class.name}>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def metadata
value: @service.api['metadata'][key].inspect
}
elsif METADATA_KEYS[key].nil?
raise "unhandled metadata key #{key.inspect}"
warn "unhandled metadata key #{key.inspect}"
end
end
metadata
Expand Down Expand Up @@ -317,7 +317,7 @@ def shape_constructor_args(shape_name, shape)

args << "#{key}: #{value.inspect}"
elsif SHAPE_KEYS[key].nil?
raise "unhandled shape key #{key.inspect}"
warn "unhandled shape key #{key.inspect}"
end
end
args.join(', ')
Expand Down

0 comments on commit b9fb735

Please sign in to comment.