boyney123 / eventcatalog

Discover, Explore and Document your Event Driven Architectures powered by Markdown.

Home Page:https://eventcatalog.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[eventcatalog-plugin-generator-asyncapi] Cannot model flow between services

autodidaddict opened this issue · comments

Have you read the Contributing Guidelines on issues?

Description

I am building an event sourcing example and I am using eventcatalog to provide documentation and modeling help with it. I'm also trying to figure out how to incorporate eventcatalog in an automated code generation pipeline. I have created two async API yaml files, one for each service, and each of these files uses a $ref to look up the message definition.

The message definition comes across, as do both services. However, only one direction is ever populated. I can change variants and get the producer to populate instead of consumer and the reverse, but I cannot get a flow from one service to another to show up.

Steps to reproduce

I've taken quite a number of different steps, but here is the most recent variant.

  1. Create a rover_aggregate.yaml file
  2. Create a rover_projector.yaml file
  3. Create the events.asyncapi.yaml file

Run npm generate

I will add the corresponding YAML files in a comment

Expected behavior

I would expect that by modeling publish and subscribe across the same (or even different, I've tried both) channel in async API would show up in event catalog as 2 services, one that publishes and the other that consumes.

I am using services to model event sourcing aggregates, projectors, process managers, etc and I can't use eventcatalog as a downstream consumer of async API if it behaves like this.

Actual behavior

Depending on which variant I've tried, this is what I see.

  1. one service publishes the "position changed" event
  2. the other service does not consume it

I have tried this with the message being defined locally to each service or with the entire message being the target of the $ref

Your environment

  • EventCatalog version used: latest
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): Chrome and Arc
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): macOS newest

NOTE I have tried both listing 2 files in a single generator pass config or using 2 different single-file generator passes. They both produce the same results.

Rover Projector

asyncapi: '2.6.0'
id: https://cosmonic.com/concordance/schemas/rover-projector.yaml
info:
  title: Rover Projector
  version: 1.0.0
  description: This is the rover projector
  contact:
    name: Cosmonic
    url: https://cosmonic.com
    email: info@cosmonic.com
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html

defaultContentType: application/json 
tags:
  - name: projector   

channels:
  rover/position:
    publish:      
      message:               
        $ref: "events.asyncapi.yaml#/components/messages/PositionChanged"

Rover Aggregate

asyncapi: '2.6.0'
id: https://cosmonic.com/concordance/schemas/rover-aggregate.yaml
info:
  title: Rover Aggregate
  version: 1.0.0
  description: This is the rover aggregate
  contact:
    name: Cosmonic
    url: https://cosmonic.com
    email: info@cosmonic.com
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html

defaultContentType: application/json 
tags:
  - name: aggregate    

channels:
  rover/position:
    subscribe:      
      message:              
        $ref: "events.asyncapi.yaml#/components/messages/PositionChanged"

Shared Message Schema

asyncapi: '2.6.0'
info:
  title: Common
  version: 1.0.0
  description: Common

components:
  messages:
    PositionChanged:
      summary: position
      description: position
      payload:
        $ref: '#/components/schemas/positionChangedPayload'
        
  schemas:
    positionChangedPayload:
      type: object
      properties:          
        position:
          type: number
          description: The position
        timestamp:
          type: string
          format: date-time
          description: The timestamp of the position  

+1. It's a pretty basic expectation and the plugin-doc-generator-asyncapi is no use if it does not support flow of events between services. All of my events are being duplicated.

I kind of have the similar issue, in my case if I import the asyncapi using versioning the latest version of the event doesn't get the proper association with consumer only producer.

In the base folder the index.md get generated with the proper association to producer and consumer but the versioned folder doesn't get the association with the consumer.

If I import a new version the previous one versioned gets the associations properly but the latest version only producer association is set, the base file the associations are ok.

Note

The files for testing can be any, the services both need to define de same message and schema and the issue can be replicated

See images bellow:
The base index (Ok ✅)
Base Index
The versioned 0.1.0 (Ok ✅)
Versioned 0.1.0
The versioned 0.2.0 (Not Ok ❌ )
Versioned 0.2.0