Skip to content

Commit e6ac1a4

Browse files
committed
return uninterpreted options as an array
1 parent 6e441a8 commit e6ac1a4

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

packages/proto-loader/src/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,18 @@ function createSerializer(cls: Protobuf.Type): Serialize<object> {
250250
}
251251

252252
function mapMethodOptions(options: Partial<MethodOptions>[] | undefined): MethodOptions {
253-
return (options || []).reduce((obj: MethodOptions, item: Partial<MethodOptions>) => ({ ...obj, ...item }),
253+
return (options || []).reduce((obj: MethodOptions, item: Partial<MethodOptions>) => {
254+
for (const [key, value] of Object.entries(item)) {
255+
switch (key) {
256+
case 'uninterpreted_option' :
257+
obj.uninterpreted_option.push(item.uninterpreted_option as UninterpretedOption);
258+
break;
259+
default:
260+
obj[key] = value
261+
}
262+
}
263+
return obj
264+
},
254265
{
255266
deprecated: false,
256267
idempotency_level: IdempotencyLevel.IDEMPOTENCY_UNKNOWN,

packages/proto-loader/test/descriptor_type_test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,18 @@ describe('Descriptor types', () => {
140140
assert.deepStrictEqual(service.Hello.options, {
141141
deprecated: true,
142142
idempotency_level: 'NO_SIDE_EFFECTS',
143-
uninterpreted_option: {
143+
uninterpreted_option: [{
144144
name: {
145145
name_part: 'foo',
146-
is_extension: false,
146+
is_extension: false,
147147
},
148148
identifier_value: 'bar',
149149
positive_int_value: 9007199254740991,
150150
negative_int_value: -9007199254740991,
151151
double_value: 1.2345,
152152
string_value: 'foobar',
153153
aggregate_value: 'foobar'
154-
},
154+
}],
155155
'(google.api.http)': {
156156
post: '/hello',
157157
body: '*',

0 commit comments

Comments
 (0)