Examples of interacting with Schema Registry

Learn about different ways of interacting with Schema Registry.

Schema Registry UI

You can use the Schema Registry UI to create schema groups, schema metadata, and add schema versions.


Schema Registry API

You can access the Schema Registry API swagger directly from the UI.

To do this, you need to append your URL with /swagger/. For example: https://localhost:7790/swagger/.

For example, you can create a schema by using Swagger, as shown in the following steps:

  1. Navigate to the Swagger UI: http:<sr-host>:<sr-port>/swagger/
  2. Go to the Schema section and open POST /api/v1/schemaregistry/schemas.
  3. Click Try it out.
  4. Enter the input for your schema in the body field.

    There is already an example input in the body. You can also edit it.

  5. Click Execute.

    After the successful execution of the command, you see the newly created schema in you Schema Registry UI

For more information about the tasks you can perform through Swagger, see Cloudera Schema Registry REST API Reference.

Java client

You can review the following GitHub repositories for examples of how to interact with the Schema Registry Java client:

Java and Scala

See the following examples of using schema related API:

https://github.com/hortonworks/registry/blob/HDF-3.4.1.0-5-tag/examples/schema-registry/avro/src/main/java/com/hortonworks/registries/schemaregistry/examples/avro/SampleSchemaRegistryClientApp.java

https://github.com/hortonworks/registry/blob/HDF-2.1.0.0/schema-registry/README.md

Kafka SerDes

See the following example of using the Schema Registry Kafka SerDes:

https://github.com/hortonworks/registry/blob/0.9.0/examples/schema-registry/avro/src/main/java/com/hortonworks/registries/schemaregistry/examples/avro/KafkaAvroSerDesApp.java

Schema Registry also supports serializing objects as JSON. To enable JSON serialization or deserialization, set the following properties:
  • value.serializer=com.hortonworks.registries.schemaregistry.serdes.json.kafka.KafkaJsonSerial
  • value.deserializer=com.hortonworks.registries.schemaregistry.serdes.json.kafka.KafkaJsonDeserializer

Jackson 2 is used for serialization, so any Java object which can be processed with this library is also going to be processed by Schema Registry.

.NET client

See the following examples of interacting with the Schema Registry .NET client:

.NET client examples