Repository: asyncapi/parser-js
Pull request #834 (2023-08-10 10:21:35)

fix: add reply() to the Operation model
**Description**

Fixes https://github.com/asyncapi/parser-js/issues/831.

**Related issue(s)**
https://github.com/asyncapi/parser-js/issues/831

sonarcloud[bot]: Kudos, SonarCloud Quality Gate passed!&nbsp; &nbsp; [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=asyncapi_parser-js&pullRequest=834)

[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=asyncapi_parser-js&pullRequest=834&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=asyncapi_parser-js&pullRequest=834&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=asyncapi_parser-js&pullRequest=834&resolved=false&types=BUG)  
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=asyncapi_parser-js&pullRequest=834&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=asyncapi_parser-js&pullRequest=834&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=asyncapi_parser-js&pullRequest=834&resolved=false&types=VULNERABILITY)  
[![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=asyncapi_parser-js&pullRequest=834&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=asyncapi_parser-js&pullRequest=834&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=asyncapi_parser-js&pullRequest=834&resolved=false&types=SECURITY_HOTSPOT)  
[![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=asyncapi_parser-js&pullRequest=834&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=asyncapi_parser-js&pullRequest=834&resolved=false&types=CODE_SMELL) [0 Code Smells](https://sonarcloud.io/project/issues?id=asyncapi_parser-js&pullRequest=834&resolved=false&types=CODE_SMELL)

[![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=asyncapi_parser-js&pullRequest=834) No Coverage information  
[![No Duplication information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/NoDuplicationInfo-16px.png 'No Duplication information')](https://sonarcloud.io/component_measures?id=asyncapi_parser-js&pullRequest=834&metric=duplicated_lines_density&view=list) No Duplication information


jonaslagoni: /rtm

Patch:
diff --git a/src/models/operation.ts b/src/models/operation.ts
index 1bb3722..6a92b9c 100644
--- a/src/models/operation.ts
+++ b/src/models/operation.ts
@@ -1,6 +1,7 @@
 import type { BaseModel } from './base';
 import type { ChannelsInterface } from './channels';
 import type { MessagesInterface } from './messages';
+import type { OperationReplyInterface } from './operation-reply';
 import type { OperationTraitsInterface } from './operation-traits';
 import type { OperationTraitInterface } from './operation-trait';
 import type { ServersInterface } from './servers';
@@ -14,5 +15,6 @@ export interface OperationInterface extends BaseModel, OperationTraitInterface {
   servers(): ServersInterface;
   channels(): ChannelsInterface;
   messages(): MessagesInterface;
+  reply(): OperationReplyInterface | undefined;
   traits(): OperationTraitsInterface;
 }
diff --git a/src/models/v2/operation.ts b/src/models/v2/operation.ts
index b1193dd..4fb696d 100644
--- a/src/models/v2/operation.ts
+++ b/src/models/v2/operation.ts
@@ -12,6 +12,7 @@ import type { ChannelsInterface } from '../channels';
 import type { ChannelInterface } from '../channel';
 import type { MessagesInterface } from '../messages';
 import type { OperationInterface, OperationAction } from '../operation';
+import type { OperationReplyInterface } from '../operation-reply';
 import type { OperationTraitsInterface } from '../operation-traits';
 import type { ServersInterface } from '../servers';
 import type { ServerInterface } from '../server';
@@ -76,6 +77,10 @@ export class Operation extends OperationTrait<v2.OperationObject> implements Ope
     );
   }
 
+  reply(): OperationReplyInterface | undefined {
+    return;
+  }
+
   traits(): OperationTraitsInterface {
     return new OperationTraits(
       (this._json.traits || []).map((trait: any, index: number) => {


Test patch:
diff --git a/test/models/v2/operation.spec.ts b/test/models/v2/operation.spec.ts
index bed03a1..ee076ab 100644
--- a/test/models/v2/operation.spec.ts
+++ b/test/models/v2/operation.spec.ts
@@ -179,6 +179,14 @@ describe('Operation model', function() {
     });
   });
 
+  describe('.reply()', function() {
+    it('should return always undefined as it is not a feature part of v2', function() {
+      const doc = { reply: {} };
+      const d = new Operation(doc);
+      expect(d.reply()).toBeUndefined();
+    });
+  });
+
   describe('.traits()', function() {
     it('should return collection of traits', function() {
       const doc = { traits: [{ operationId: '...' }] };