Schema registry API

Provide a REST API to call with a schema registry.
Examples
List subjects
use reqwest::Url;
use schema_registry_api::SchemaRegistry;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let base_url = Url::parse("http://localhost:8081")?;
let sr = SchemaRegistry::build_default(base_url)?;
let subjects = sr.subject().list(None, None).await?;
if subjects.is_empty() {
println!("No subject found");
}
for subject in &subjects {
println!("Found subject '{subject}'");
}
Ok(())
}
Register a schema
use reqwest::Url;
use schema_registry_api::{RegisterSchema, SchemaRegistry};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let base_url = Url::parse("http://localhost:8081")?;
let sr = SchemaRegistry::build_default(base_url)?;
let subject = "a-topic-value".parse()?;
let schema = RegisterSchema {
schema: include_str!("../tests/assets/a_record.avsc").to_string(),
..Default::default()
};
let registered_schema = sr.subject().new_version(&subject, &schema, None).await?;
let schema_id = registered_schema.id;
println!("The schema #{schema_id} is registered for subject '{subject}'");
Ok(())
}
License
Licensed under either of
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.