asyncapi / asyncapi/parser-js

[BUG] Custom Parsers aren't triggered on payloads that are defined though `Operations.Channel`

Open Beginner friendly
#1,099 7 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
144
Forks
144
Avg merge
6m
Merged PRs (30d)
11

Description

### Describe the bug.

A custom parser isn't triggered on a root document like:
```
operations:
FooOperation:
action: send
channel:
$ref: otherFile.yaml#/channels/BarChannel
```

And there is another file that defines the channel and message
```
channels:
BarChannel:
address:
messages:
AMessage:
$ref: '#/components/messages/AMessage'
components:
messages:
AMessage:
payload:
schemaFormat: ....
schema: ......
```

In the parsed json that is handled by packages/parser/src/custom-operations/parse-schema.ts#86 (in the variable detailed.parsed) the path to the payload with the custom schema is
`$.operations.FooOperation.channel.messages.AMessage.payload`

which is not covered in packages/parser/src/custom-operations/parse-schema.ts#25

A work around to this is to also re-specify the channel in the root document eg
````
channels:
BarChannel:
$ref: otherFile.yaml#/channels/BarChannel

operations:
FooOperation:
action: send
channel:
$ref: #/channels/BarChannel
````
but this feels weird as the channel is already fully defined in the other file and I am looking to re-use channels for other definitions

### Expected behavior

I believe customSchemasPathsV3 should also include
`$.operations.*.channel.messages.*.payload`

### Screenshots

NA

### How to Reproduce

Root AsyncApi file:

```
operations:
FooOperation:
action: send
channel:
$ref: otherFile.yaml#/channels/BarChannel
```

Other referenced file:
```
channels:
BarChannel:
address:
messages:
AMessage:
$ref: '#/components/messages/AMessage'
components:
messages:
AMessage:
payload:
schemaFormat: ....
schema: ......
```

### 🖥️ Device Information [optional]

AsyncApi v3

### 👀 Have you checked for similar open issues?

- [x] I checked and didn't find similar issue

### 🏢 Have you read the Contributing Guidelines?

- [x] I have read the [Contributing Guidelines](https://github.com/asyncapi/.github/blob/master/CONTRIBUTING.md)

### Are you willing to work on this issue ?

Yes I am willing to submit a PR!

Contributor guide

Open the contributing guide

Research direction

Start in packages/parser/src/custom-operations/parse-schema.ts, especially the customSchemasPathsV3 definition around line 25 and parsing around line 86. Reproduce the AsyncAPI v3 external-channel example and verify that $.operations.*.channel.messages.*.payload is recognized alongside the existing paths. Done means the custom parser is triggered for that payload.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.