Provide a REST API to call with a schema registry.
List subjects
```rust, norun use reqwest::Url; use schemaregistry_api::SchemaRegistry;
// Create a SchemaRegistry
let baseurl = Url::parse("http://localhost:8081")?;
let sr = SchemaRegistry::builddefault(base_url)?;
// List subjects let subjects = sr.subject().list(None, None).await?;
if subjects.is_empty() { println!("No subject found"); } for subject in &subjects { println!("Found subject '{subject}'"); }
```
Register a schema
```rust, norun use reqwest::Url; use schemaregistry_api::{RegisterSchema, SchemaRegistry};
// Create a SchemaRegistry
let baseurl = Url::parse("http://localhost:8081")?;
let sr = SchemaRegistry::builddefault(base_url)?;
// Create a subject
let subject = "a-topic-value".parse()?;
// Create the RegisterSchema
let schema = RegisterSchema {
schema: includestr!("../tests/assets/arecord.avsc").to_string(),
..Default::default()
};
// Register the schema for the subject let registeredschema = sr.subject().newversion(&subject, &schema, None).await?; // Get the schema id let schemaid = registeredschema.id;
println!("The schema #{schema_id} is registered for subject '{subject}'");
```
Licensed under either of
at your option.
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.