Skip to content

Commit c43c946

Browse files
committed
refactor(asyncapi): simplify channel parameter handling and enforce string type
1 parent 067a99d commit c43c946

2 files changed

Lines changed: 2 additions & 25 deletions

File tree

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,13 @@ export default function transformChannelsObject(
8383
if (channel.parameters && typeof channel.parameters === 'object') {
8484
const paramMembers: ts.TypeElement[] = [];
8585

86-
for (const [paramId, param] of Object.entries(channel.parameters)) {
87-
let paramType: ts.TypeNode;
88-
89-
if (param && '$ref' in param) {
90-
paramType = oapiRef((param as ReferenceObject).$ref);
91-
} else {
92-
paramType = ts.factory.createKeywordTypeNode(
93-
ts.SyntaxKind.UnknownKeyword
94-
);
95-
}
96-
86+
for (const [paramId] of Object.entries(channel.parameters)) {
9787
paramMembers.push(
9888
ts.factory.createPropertySignature(
9989
tsModifiers({ readonly: ctx.immutable }),
10090
tsPropertyIndex(paramId),
10191
undefined,
102-
paramType
92+
ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword)
10393
)
10494
);
10595
}

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -316,19 +316,6 @@ function transformParameters(
316316
)) {
317317
const members: ts.TypeElement[] = [];
318318

319-
if (param.description) {
320-
members.push(
321-
ts.factory.createPropertySignature(
322-
tsModifiers({ readonly: ctx.immutable }),
323-
tsPropertyIndex('description'),
324-
undefined,
325-
ts.factory.createLiteralTypeNode(
326-
ts.factory.createStringLiteral(param.description)
327-
)
328-
)
329-
);
330-
}
331-
332319
if (param.location) {
333320
members.push(
334321
ts.factory.createPropertySignature(

0 commit comments

Comments
 (0)