Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/735-binding-excess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@asyncapi/parser': patch
---

Allow protocol-specific excess properties on the `Binding` type (issue #735).
2 changes: 2 additions & 0 deletions packages/parser/src/spec-types/v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ export interface CorrelationIDObject extends SpecificationExtensions {

export interface Binding {
bindingVersion?: string;
// protocol-specific binding fields (excess properties)
[propName: string]: any;
}

export interface SpecificationExtensions {
Expand Down
2 changes: 2 additions & 0 deletions packages/parser/src/spec-types/v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,8 @@ export interface AsyncAPISchemaDefinition extends SpecificationExtensions {

export interface Binding {
bindingVersion?: string;
// protocol-specific binding fields (excess properties)
[propName: string]: any;
}

export interface SpecificationExtensions {
Expand Down
9 changes: 9 additions & 0 deletions packages/parser/test/models/v2/bindings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,13 @@ describe('Bindings model', function () {
expect(bindings.extensions().get('x-anotherOne')?.value()).toEqual({ someKey: 123 });
});
});

describe('excess properties (issue #735)', function () {
it('should preserve protocol-specific excess fields on a binding value', function () {
const b = new Binding({ clientId: 'my-client', clean: true } as any, { asyncapi: {} as any, pointer: '', protocol: 'mqtt' });
const value = b.value() as Record<string, any>;
expect(value).toHaveProperty('clientId', 'my-client');
expect(value).toHaveProperty('clean', true);
});
});
});
Loading