How to refer an Avro schema from Confluent schema registry

139 views Asked by At

I'm building the documentation of a Kafka message using AsyncAPI. I have an Avro schema on Confluent schema registry (as shown on the following image). The current version is version 9

enter image description here

I would like to use that schema on my AsyncAPI yaml file.

Assuming that my schema registry has the following information:

shema registry url: https://pkdx-rmu1p.eu-central-1.aws.confluent.cloud
key: registryKey
secret: registrySecret

Here is the syntax I'm using on my asynApi file

channels:
  person:    
    publish: 
      message:
        name: personupload
        schemaFormat: 'application/vnd.apache.avro;version=1.9.0'                    
        payload:
          $ref: 'https://registryKey:[email protected]/subjects/person-value/versions/9/schema'

But the schema is not getting downloaded. From Visual Studio Code, I have the following error while trying to visualize the asyncApi document.

Error: Error downloading https://registryKey:registrySecret@https://https://pkdx-rmu1p.eu-central-1.aws.confluent.cloud/subjects/person-value/versions/9/schema Failed to fetch

What is the right syntax to refer an Avro schema from Confluent schema registry in an asyncAPI file?

1

There are 1 answers

3
Lukasz Gornicki On

I think it doesn't work for you as you have an error in Reference Object

$ref: '$ref: 'https://registryKey:registrySecret@https://pkdx-rmu1p.eu-central-1.aws.confluent.cloud/subjects/person-value/versions/9/schema'

and additionally you duplicate https://. You should provide scheme just once at the beginning of the ref, and after @ you just go directly with domain name like below:

$ref is duplicated. It should be like:

$ref: 'https://registryKey:[email protected]/subjects/person-value/versions/9/schema'

here you also have another example: https://github.com/asyncapi/avro-schema-parser#usage-with-confluent-schema-registry