How to convert an avro schema into an asyncapi programatically?

25 Views Asked by At

I would like to now if exist a cli tool to convert an avro schema file into a asyncapi file.

Many thanks in advance

1

There are 1 best solutions below

0
Lukasz Gornicki On

I do not know if such a tool exists and if it every will. The thing is that these standards are for a different purpose

Avro: it like a schema format that defines the structure of a message

AsyncAPI: it is on a higher level, it describes application behaviour and can have a lot of additional information about brokers it connects to, channels where messages are sent and consumed from.

Because Avro scope is limited, any CLI that would convert to AsyncAPI, would have to have some custom functionality that would enable you to provide more metadata required for the AsyncAPI document.

The good part is that you can use Avro inside AsyncAPI

Example of a message described in AsyncAPI document:

messages:
  userSignedUp:
    payload:
      schemaFormat: 'application/vnd.apache.avro;version=1.9.0'
      schema:
        type: record
        name: UserSignedUp
        namespace: com.company
        doc: User sign-up information
        fields:
          - name: userId
            type: int
          - name: userEmail
            type: string

More details in: https://www.asyncapi.com/docs/tutorials/kafka/configure-kafka-avro