asyncapi / asyncapi/optimizer

[BUG] moveAllComponents is not working as expected.

Open
#261 15 comments 0 reactions 0 assignees View on GitHub
bug stale
Dominant language
TypeScript
Stars
12
Forks
11
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug.

I tried to run the optimizer on this file:
```yaml
asyncapi: 3.0.0
info:
title: Account Service
version: "1.0"
channels:
userSignedUp:
address: user/signedup
messages:
UserSignedUp:
$ref: '#/components/messages/UserSignedUp'
components:
messages:
UserSignedUp:
payload:
type: object
properties:
email:
type: string

```
It generated the following invalid document.
```yaml
asyncapi: 3.0.0
info:
title: Account Service
version: '1.0'
channels:
userSignedUp:
$ref: '#/components/channels/userSignedUp'
components:
messages:
UserSignedUp:
payload:
type: object
properties:
email:
type: string
schemas: {}
channels:
userSignedUp:
address: user/signedup
messages:
UserSignedUp:
$ref: '#/components/messages/UserSignedUp'
payload:
properties:
email:
$ref: '#/components/schemas/email'
```

### Expected behavior

It should have generated:

```yaml
asyncapi: 3.0.0
info:
title: Account Service
version: "1.0"
channels:
userSignedUp:
address: user/signedup
messages:
UserSignedUp:
$ref: '#/components/messages/UserSignedUp'
components:
schemas:
email:
type: string
messages:
UserSignedUp:
payload:
type: object
properties:
email: "$ref: #/components/schemas/email"
```

### Screenshots

...

### How to Reproduce

Run the optimiser on the given AsyncAPI file.

### 🥦 Browser

None

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