Importing schemas using Schema Registry API

One of the methods of importing schemas that were exported from one Schema Registry instance into another Schema Registry instance is using the Schema Registry API. You can also import schemas using curl through the command line.

The following steps describe how to import schemas by using the Schema Registry Swagger UI.

  • Ensure that the cluster, its hosts, and all its services are healthy.
  • Ensure that Schema Registry is commissioned and running.
  • Ensure that you have access to all credentials that are required to access and use Schema Registry.
  • Ensure that you have access to a JSON file that contains the exported schemas that you want to import. For more information on how to export schemas, see Exporting schemas using Schema Registry API.
  • Ensure that you are logged in as a user with access to the CDP environment containing the cluster with Schema Registry.
  1. In Management Console, go to Data Hub clusters.
  2. Find and select the Data Hub cluster you want to import schemas to.
  3. Under Services, click Schema Registry.
    The Schema Registry web UI opens in a new tab.
  4. In the tab that has the Schema Registry web UI open, replace /ui/# at the end of the URL with /swagger.
  5. Click 3. Export/Import.
  6. Click POST /api/v1/schemaregistry/import.
  7. Click Try it out.
  8. Set format to 0.
  9. Set failOnError to true.
  10. Click Choose file and select a JSON file containing the schema data that you want to import.
  11. Click Execute.
Schemas are successfully imported into the target Schema Registry instance.

On successful import, a number of SchemaMetadata, SchemaBranch, and SchemaVersionInfo objects are added to the Schema Registry database.

Objects added to the database retain the following property values from the import file:
  • Schema Metadata objects retain the ID, type, schemaGroup, name, description, compatibility, validationLevel, and evolve properties.
  • SchemaBranch objects retain the ID, name, schemaMetadataName, and description properties.
  • SchemaVersionInfo objects retain the ID, schemaMetadataId, name, description, version, and schemaText properties.
A successful import also results in a JSON file that contains the following:
{
  "successCount": 0,
  "failedCount": 0,
  "failedIds": [

    0
  ]
}
Where,
  • successCount is the number of successfully imported SchemaVersionInfo objects.
  • failedCount is the number of SchemaVersionInfo objects that failed to import.
  • failedIds contains the IDs of failed SchemaVersionInfo objects.

Schemas (metadata/branch/version) that are already present in the database are skipped during an import. Skipped schemas are not counted in successCount or failedCount.