Skip to content

Commit 8b666cd

Browse files
committed
Clean document specs
1 parent a1e46cc commit 8b666cd

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

gems/smithy-schema/lib/smithy-schema/document_utils.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ def apply_union(data, schema, type)
105105
return if key.nil?
106106

107107
if (member = member_with_json_name(key, shape))
108-
apply_union_member(member.name, shape, type)
108+
apply_union_member(member.name, value, shape, type)
109109
elsif shape.name_by_member_name?(key)
110-
apply_union_member(key, shape, type)
110+
apply_union_member(key, value, shape, type)
111111
else
112112
shape.member_type(:unknown).new(key, value)
113113
end
114114
end
115115

116-
def apply_union_member(key, shape, type)
116+
def apply_union_member(key, value, shape, type)
117117
member_name = shape.name_by_member_name(key)
118118
type = shape.member_type(member_name) if type.nil?
119119
type.new(apply(value, shape.member(member_name)))

gems/smithy-schema/spec/smithy-schema/document_spec.rb

+1-8
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def self.name
194194
foo_map: { foo: ['Thing1'], bar: ['Thing2'] },
195195
structure: { list: ['AnotherThing'] },
196196
union: { union_string: 'hello world' },
197-
timestamp: 1_735_084_800,
197+
timestamp: '2024-12-25T00:00:00Z',
198198
blob: 'foo'
199199
}
200200
)
@@ -205,13 +205,6 @@ def self.name
205205
expect(typed_shape).to be_a(simple_runtime)
206206
expect(typed_shape[:string]).to eq('foo')
207207
end
208-
209-
it 'converts document with jsonName trait as a runtime shape' do
210-
typed_shape = runtime.new(string: 'foo', union: { union_string: 'bar' })
211-
doc = Document.new(typed_shape, schema: schema, use_json_name: true).as_typed(schema)
212-
expect(doc.string).to eq('foo')
213-
expect(doc.union.value).to eq('bar')
214-
end
215208
end
216209
end
217210

0 commit comments

Comments
 (0)