Skip to content

Commit 530f516

Browse files
committed
refactor(asyncapi): add default value for streetlightId parameter
1 parent 53e594a commit 530f516

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

packages/asyncapi-typescript-plugin/src/transform/components-object.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,19 @@ function transformParameters(
330330
);
331331
}
332332

333+
if (typeof param.default === 'string') {
334+
members.push(
335+
ts.factory.createPropertySignature(
336+
tsModifiers({ readonly: ctx.immutable }),
337+
tsPropertyIndex('default'),
338+
undefined,
339+
ts.factory.createLiteralTypeNode(
340+
ts.factory.createStringLiteral(param.default)
341+
)
342+
)
343+
);
344+
}
345+
333346
if (Array.isArray(param.enum) && param.enum.length > 0) {
334347
members.push(
335348
ts.factory.createPropertySignature(

packages/test-fixtures/asyncapi.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"streetlight-1",
7474
"streetlight-2"
7575
],
76+
"default": "streetlight-1",
7677
"location": "$message.payload#/item/id"
7778
}
7879
},
@@ -828,6 +829,7 @@
828829
"streetlight-1",
829830
"streetlight-2"
830831
],
832+
"default": "streetlight-1",
831833
"location": "$message.payload#/item/id"
832834
}
833835
},

0 commit comments

Comments
 (0)