cli icon indicating copy to clipboard operation
cli copied to clipboard

[FEATURE] Avro Validation

Open Lazzaretti opened this issue 6 months ago • 3 comments

Why do we need this improvement?

Currently, the Avro Schema is not validated with the CLI.

How will this change help?

This change will help to write valid Avro Schemas in AsyncAPI.

Screenshots

No response

How could it be implemented/designed?

  1. Extract the Avro schemas (can also be helpful as a separate command)
  2. Parse the Avro schema.
  3. Show errors and warnings if any come up.

🚧 Breaking changes

No

👀 Have you checked for similar open issues?

  • [x] I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue?

None

Lazzaretti avatar Jun 25 '25 12:06 Lazzaretti

Minimal example

AsyncAPI with an Avro schema that contains a single field with a wrong type: type: notexisting.

The cli however, does not detect the error:

$ asyncapi validate asyncapi.yaml

File asyncapi.yaml is valid! File asyncapi.yaml and referenced documents don't have governance issues.
# yaml-language-server: $schema=https://asyncapi.com/schema-store/3.0.0-without-$id.json
asyncapi: 3.0.0
info:
  title: Coffee Bar Checkout Events
  version: 1.0.0
  description: AsyncAPI definition for order execution events in a coffee bar microservice.

channels:
  orderExecuted:
    address: coffee-bar.checkout.order-executed
    messages:
      orderExecuted:
        $ref: '#/components/messages/orderExecuted'

operations:
  sendAdCreated:
    action: receive
    channel:
      $ref: '#/channels/orderExecuted'

components:
  messages:
    orderExecuted:
      payload:
        schemaFormat: 'application/vnd.apache.avro+yaml;version=1.9.0'
        schema:
          type: record
          namespace: io.examples.checkout
          name: OrderExecuted
          fields:
          - name: orderId
            type: notexisting

Lazzaretti avatar Jun 25 '25 12:06 Lazzaretti

Hi @Lazzaretti,

I have submitted a pull request according to the contributions.md file.

Let me know if any further changes are needed. Thanks!

sarthakNITT avatar Aug 02 '25 16:08 sarthakNITT

Hi @sarthakNITT, thanks a lot for the PR! I started looking at the PR and added some questions.

Lazzaretti avatar Sep 30 '25 09:09 Lazzaretti