event-catalog / event-catalog/generators

Updating the version of an Async API breaks the generator

Open
#19 6 comments 2 reactions 0 assignees View on GitHub
generator-asyncapi
Dominant language
TypeScript
Stars
15
Forks
16
Avg merge
25m
Merged PRs (30d)
4

Description

### I tried this:

In my own project I am experiencing issues with versioning. The problem occurs when messages are shared between services (sender -> receiver). I cloned the eventcatalog-asyncapi-example repository and attempted the same process there, with the same result.

**Steps**
1. Clone the eventcatalog-asyncapi-example
2. Run the ```generate``` command
3. Update the version of the inventory-service to 1.0.1
4. Run the ```generate``` command again
5. Observe

### This happened:

When the generator encounters the first shared message - in this case, shared between the inventory-service and the order-service - the generator fails:

```
Processing domain: Orders (v0.0.1)
- Domain (v0.0.1) already exists, skipped creation...
Processing message: OrderCreated (v1.0.0)
- Message (v1.0.0) created
- Schema added to message (v1.0.0)
Processing message: OrderUpdated (v1.0.0)
- Message (v1.0.0) created
- Schema added to message (v1.0.0)
Processing message: OrderCancelled (v1.0.0)
- Message (v1.0.0) created
- Schema added to message (v1.0.0)
Processing message: OrderCompleted (v1.0.0)
- Message (v1.0.0) created
- Schema added to message (v1.0.0)
Processing message: PaymentProcessed (v1.0.0)
- Message (v1.0.0) created
- Schema added to message (v1.0.0)
Processing message: InventoryReserved (v1.0.0)
- Versioned previous message: (v1.0.1)
Error loading plugin: Error: Failed to write event as the version 1.0.0 already exists
at writeResource (/eventcatalog-asyncapi-example/node_modules/@eventcatalog/sdk/dist/index.js:160:11)
at async src_default (/eventcatalog-asyncapi-example/node_modules/@eventcatalog/generator-asyncapi/dist/index.js:248:9)
at async generate (file:///eventcatalog-asyncapi-example/.eventcatalog-core/scripts/generate.js:50:9)
````

### I expected this:

_No response_

### Is there a workaround?

_No response_

### Anything else?

_No response_

### EventCatalog Version

latest

### Node.js Version

20.15.0

### Platform(s)

MacOS

### Community Notes

* Please vote by adding a 👍 reaction to the issue to help us prioritize.
* If you are interested to work on this issue, please leave a comment.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.