asyncapi / asyncapi/cli

[BUG] bundle creates invalid document (refs)

Open
#1,989 7 comments 0 reactions 0 assignees View on GitHub
bug stale
Dominant language
TypeScript
Stars
272
Forks
375
Avg merge
3h 22m
Merged PRs (30d)
8

Description

### Describe the bug.

`asyncapi bundle` creates invalid documents.

`main.yaml`
```yml
asyncapi: 3.0.0
info:
title: demo
version: '1'
operations:
A:
$ref: "./_sub.yaml#/components/operations/A"
channels:
A:
$ref: "./_sub.yaml#/components/channels/A"
```

`_sub.yaml`
```yml
components:
operations:
A:
action: send
channel:
$ref: '#/components/channels/A'
messages:
- $ref: '#/components/channels/A/messages/A'
channels:
A:
messages:
A:
$ref: '#/components/messages/A'
messages:
A:
payload:
type: object
```

```sh
asyncapi validate main.yaml
asyncapi bundle ./main.yaml --output final.yml
asyncapi validate final.yml
```

produced invalid output:
```yaml
asyncapi: 3.0.0
info:
title: demo
version: '1'
channels:
A:
messages:
A:
payload:
type: object
operations:
A:
action: send
channel:
$ref: '#/components/channels/A'
messages:
- $ref: '#/components/channels/A/messages/A'
```

### Expected behavior

It should've either updated the refs to root or moved the channels/ops/messages to `components` (if allowed).

### Screenshots

-

### How to Reproduce

see above

### 🖥️ Device Information [optional]

- Operating System (OS): macOS latest
- Browser: WF
- Browser Version: latest

### 👀 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 ?

No, someone else can work on it

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.