Repository: gklijs/schema_registry_converter (language: rust)

Issue:
Confluent Schema Registry needs a "schema" element as a string
The confluent schema registry takes a single "schema" element which contains the escaped JSON string of the schema.

Fix proposed in upcoming PR.


Discussion / hints:

Fix patch:
diff --git a/.gitignore b/.gitignore
index d889fbf..54e9c47 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
 /target
-**/*.rs.bk
 Cargo.lock
 .idea
+**/*.iml
diff --git a/README.md b/README.md
index a97a1b5..33b31cd 100644
--- a/README.md
+++ b/README.md
@@ -7,20 +7,20 @@
 [![docs.rs](https://docs.rs/schema_registry_converter/badge.svg)](https://docs.rs/schema_registry_converter/)
 ---
 
-This library is provides a way of using the Confluent Schema Registry in a way that is compliant with the usual jvm useage.
-Consuming/decoding and producing/encoding is supported. It's also possible to provide the schema to use when decoding. When no schema is provided the latest
-schema with the same `subject` will be used. As far as I know it's feature complete compared to the confluent java version.
-As I'm still pretty new to rust pr's/remarks for improvements are greatly appreciated.
+This library provides a way of using the Confluent Schema Registry in a way that is compliant with the usual jvm usage.
+Consuming/decoding and producing/encoding is supported. It's also possible to provide the schema to use when decoding. When no schema is provided, the latest
+schema with the same `subject` will be used. As far as I know, it's feature complete compared to the confluent java version.
+As I'm still pretty new to rust, pr's/remarks for improvements are greatly appreciated.
 
 ## Consumer
 
-For consuming messages encoded with the schema registry you need to fetch the correct schema from the schema registry to transform it into a record. For clarity error handling is omitted from the diagram. 
+For consuming messages encoded with the schema registry, you need to fetch the correct schema from the schema registry to transform it into a record. For clarity, error handling is omitted from the diagram. 
 
 ![Consumer activity flow](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.githubusercontent.com/gklijs/schema_registry_converter/master/uml/consumer.puml)
 
 ## Producer
 
-For producing messages which can be properly consumed by other clients the proper id needs to be encoded with the message, and to get the correct id it might be needed to register a new schema. For clarity error handling is omitted from the diagram.
+For producing messages which can be properly consumed by other clients, the proper id needs to be encoded with the message.  To get the correct id, it might be necessary to register a new schema. For clarity, error handling is omitted from the diagram.
 
 ![Producer activity flow](http://www.plantuml.com/plantuml/proxy?cache=no&src=https://raw.githubusercontent.com/gklijs/schema_registry_converter/master/uml/producer.puml)
 
@@ -90,13 +90,13 @@ fn main() {
 
 # Relation to related libraries
 
-The avro part of the conversion is handled by avro-rs as such I don't include tests for every possible schema.
-While I used rdkafka in combination to successfully consume from and produce to kafka, and it's used in the example this crate has no direct dependency to it.
+The avro part of the conversion is handled by avro-rs.  As such, I don't include tests for every possible schema.
+While I used rdkafka in combination to successfully consume from and produce to kafka, and while it's used in the example, this crate has no direct dependency on it.
 All this crate does is convert [u8] <-> avro_rs::types::Value.
 
 # Tests
 
-Do to mockito, used for mocking the schema registry responses, being run in a seperate thead, tests have to be run using ` --test-threads=1` for example like
+Due to mockito, used for mocking the schema registry responses, being run in a separate thread, tests have to be run using ` --test-threads=1` for example like
 `cargo +stable test --color=always -- --nocapture --test-threads=1`
 
 # License
@@ -114,4 +114,4 @@ at your option.
 
 Unless you explicitly state otherwise, any contribution intentionally submitted
 for inclusion in Schema Registry Converter by you, as defined in the Apache-2.0 license, shall be
-dual licensed as above, without any additional terms or conditions.
\ No newline at end of file
+dual licensed as above, without any additional terms or conditions.
diff --git a/src/lib.rs b/src/lib.rs
index 50cc335..a40a96c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -220,12 +220,12 @@ impl Decoder {
 ///
 /// let mut encoder = Encoder::new(SERVER_ADDRESS);
 ///
-/// let key_strategy = SubjectNameStrategy::TopicNameStrategy("heartbeat", true);
+/// let key_strategy = SubjectNameStrategy::TopicNameStrategy("heartbeat".into(), true);
 /// let bytes = encoder.encode(vec!(("name", Value::String("Some name".to_owned()))), &key_strategy);
 ///
 /// assert_eq!(bytes, Ok(vec!(0, 0, 0, 0, 4, 18, 83, 111, 109, 101, 32, 110, 97, 109, 101)));
 ///
-/// let value_strategy = SubjectNameStrategy::TopicNameStrategy("heartbeat", false);
+/// let value_strategy = SubjectNameStrategy::TopicNameStrategy("heartbeat".into(), false);
 /// let bytes = encoder.encode(vec!(("beat", Value::Long(3))), &value_strategy);
 ///
 /// assert_eq!(bytes, Ok(vec!(0,0,0,0,3,6)))
@@ -266,7 +266,7 @@ impl Encoder {
     ///  # use avro_rs::types::Value;
     ///
     /// let mut encoder = Encoder::new(SERVER_ADDRESS);
-    /// let strategy = SubjectNameStrategy::RecordNameStrategy("nl.openweb.data.Heartbeat");
+    /// let strategy = SubjectNameStrategy::RecordNameStrategy("nl.openweb.data.Heartbeat".into());
     ///
     /// let _m = mock("GET", "/subjects/nl.openweb.data.Heartbeat/versions/latest")
     ///     .with_status(404)
@@ -316,7 +316,7 @@ impl Encoder {
     ///     .create();
     ///
     /// let mut encoder = Encoder::new(SERVER_ADDRESS);
-    /// let strategy = SubjectNameStrategy::TopicRecordNameStrategy("heartbeat", "nl.openweb.data.Heartbeat");
+    /// let strategy = SubjectNameStrategy::TopicRecordNameStrategy("heartbeat".into(), "nl.openweb.data.Heartbeat".into());
     /// let bytes = encoder.encode(vec!(("beat", Value::Long(3))), &strategy);
     ///
     /// assert_eq!(bytes, Ok(vec!(0,0,0,0,3,6)))
@@ -622,7 +622,7 @@ mod tests {
 
         let mut encoder = Encoder::new(SERVER_ADDRESS);
 
-        let key_strategy = SubjectNameStrategy::TopicNameStrategy("heartbeat", true);
+        let key_strategy = SubjectNameStrategy::TopicNameStrategy("heartbeat".into(), true);
         let bytes = encoder.encode(
             vec![("name", Value::String("Some name".to_owned()))],
             &key_strategy,
@@ -635,7 +635,7 @@ mod tests {
             ])
         );
 
-        let value_strategy = SubjectNameStrategy::TopicNameStrategy("heartbeat", false);
+        let value_strategy = SubjectNameStrategy::TopicNameStrategy("heartbeat".into(), false);
         let bytes = encoder.encode(vec![("beat", Value::Long(3))], &value_strategy);
 
         assert_eq!(bytes, Ok(vec![0, 0, 0, 0, 3, 6]))
@@ -651,7 +651,7 @@ mod tests {
 
         let mut encoder = Encoder::new(SERVER_ADDRESS);
         let strategy =
-            SubjectNameStrategy::TopicRecordNameStrategy("heartbeat", "nl.openweb.data.Heartbeat");
+            SubjectNameStrategy::TopicRecordNameStrategy("heartbeat".into(), "nl.openweb.data.Heartbeat".into());
         let bytes = encoder.encode(vec![("beat", Value::Long(3))], &strategy);
 
         assert_eq!(bytes, Ok(vec![0, 0, 0, 0, 3, 6]))
@@ -667,7 +667,7 @@ mod tests {
 
         let mut encoder = Encoder::new(SERVER_ADDRESS);
         let strategy =
-            SubjectNameStrategy::TopicRecordNameStrategy("heartbeat", "nl.openweb.data.Heartbeat");
+            SubjectNameStrategy::TopicRecordNameStrategy("heartbeat".into(), "nl.openweb.data.Heartbeat".into());
         let bytes = encoder.encode(vec![("beat", Value::Long(3))], &strategy);
 
         assert_eq!(
@@ -680,7 +680,7 @@ mod tests {
     fn test_encoder_schema_registry_unavailable() {
         let mut encoder = Encoder::new("bogus");
         let strategy =
-            SubjectNameStrategy::TopicRecordNameStrategy("heartbeat", "nl.openweb.data.Balance");
+            SubjectNameStrategy::TopicRecordNameStrategy("heartbeat".into(), "nl.openweb.data.Balance".into());
         let result = encoder.encode(vec![("beat", Value::Long(3))], &strategy);
 
         assert_eq!(
@@ -696,7 +696,7 @@ mod tests {
     #[test]
     fn test_encoder_schema_registry_unavailable_with_record() {
         let mut encoder = Encoder::new("bogus");
-        let heartbeat_schema = SuppliedSchema::new(r#"{"type":"record","name":"Balance","namespace":"nl.openweb.data","fields":[{"name":"beat","type":"long"}]}"#);
+        let heartbeat_schema = SuppliedSchema::new(r#"{"type":"record","name":"Balance","namespace":"nl.openweb.data","fields":[{"name":"beat","type":"long"}]}"#.into());
         let strategy = SubjectNameStrategy::RecordNameStrategyWithSchema(heartbeat_schema);
         let result = encoder.encode(vec![("beat", Value::Long(3))], &strategy);
 
@@ -713,7 +713,7 @@ mod tests {
     #[test]
     fn test_encode_cache() {
         let mut encoder = Encoder::new(SERVER_ADDRESS);
-        let strategy = SubjectNameStrategy::RecordNameStrategy("nl.openweb.data.Heartbeat");
+        let strategy = SubjectNameStrategy::RecordNameStrategy("nl.openweb.data.Heartbeat".into());
 
         let _m = mock("GET", "/subjects/nl.openweb.data.Heartbeat/versions/latest")
             .with_status(404)
@@ -769,9 +769,9 @@ mod tests {
 
         let mut encoder = Encoder::new(SERVER_ADDRESS);
 
-        let name_schema = SuppliedSchema::new(r#"{"type":"record","name":"Name","namespace":"nl.openweb.data","fields":[{"name":"name","type":"string","avro.java.string":"String"}]}"#);
+        let name_schema = SuppliedSchema::new(r#"{"type":"record","name":"Name","namespace":"nl.openweb.data","fields":[{"name":"name","type":"string","avro.java.string":"String"}]}"#.into());
         let key_strategy =
-            SubjectNameStrategy::TopicNameStrategyWithSchema("heartbeat", true, name_schema);
+            SubjectNameStrategy::TopicNameStrategyWithSchema("heartbeat".into(), true, name_schema);
         let bytes = encoder.encode(
             vec![("name", Value::String("Some name".to_owned()))],
             &key_strategy,
@@ -782,9 +782,9 @@ mod tests {
                 0, 0, 0, 0, 3, 18, 83, 111, 109, 101, 32, 110, 97, 109, 101,
             ])
         );
-        let heartbeat_schema = SuppliedSchema::new(r#"{"type":"record","name":"Heartbeat","namespace":"nl.openweb.data","fields":[{"name":"beat","type":"long"}]}"#);
+        let heartbeat_schema = SuppliedSchema::new(r#"{"type":"record","name":"Heartbeat","namespace":"nl.openweb.data","fields":[{"name":"beat","type":"long"}]}"#.into());
         let value_strategy =
-            SubjectNameStrategy::TopicNameStrategyWithSchema("heartbeat", false, heartbeat_schema);
+            SubjectNameStrategy::TopicNameStrategyWithSchema("heartbeat".into(), false, heartbeat_schema);
         let bytes = encoder.encode(vec![("beat", Value::Long(3))], &value_strategy);
         assert_eq!(bytes, Ok(vec![0, 0, 0, 0, 4, 6]))
     }
@@ -799,7 +799,7 @@ mod tests {
 
         let mut encoder = Encoder::new(SERVER_ADDRESS);
 
-        let heartbeat_schema = SuppliedSchema::new(r#"{"type":"record","name":"Heartbeat","namespace":"nl.openweb.data","fields":[{"name":"beat","type":"long"}]}"#);
+        let heartbeat_schema = SuppliedSchema::new(r#"{"type":"record","name":"Heartbeat","namespace":"nl.openweb.data","fields":[{"name":"beat","type":"long"}]}"#.into());
         let strategy = SubjectNameStrategy::RecordNameStrategyWithSchema(heartbeat_schema);
         let bytes = encoder.encode(vec![("beat", Value::Long(3))], &strategy);
         assert_eq!(bytes, Ok(vec![0, 0, 0, 0, 11, 6]))
@@ -815,7 +815,7 @@ mod tests {
 
         let mut encoder = Encoder::new(SERVER_ADDRESS);
 
-        let heartbeat_schema = SuppliedSchema::new(r#"{"type":"record","name":"Heartbeat","namespace":"nl.openweb.data","fields":[{"name":"beat","type":"long"}]}"#);
+        let heartbeat_schema = SuppliedSchema::new(r#"{"type":"record","name":"Heartbeat","namespace":"nl.openweb.data","fields":[{"name":"beat","type":"long"}]}"#.into());
         let strategy = SubjectNameStrategy::RecordNameStrategyWithSchema(heartbeat_schema);
         let bytes = encoder.encode(vec![("beat", Value::Long(3))], &strategy);
         assert_eq!(
@@ -834,9 +834,9 @@ mod tests {
 
         let mut encoder = Encoder::new(SERVER_ADDRESS);
 
-        let heartbeat_schema = SuppliedSchema::new(r#"{"type":"record","name":"Heartbeat","namespace":"nl.openweb.data","fields":[{"name":"beat","type":"long"}]}"#);
+        let heartbeat_schema = SuppliedSchema::new(r#"{"type":"record","name":"Heartbeat","namespace":"nl.openweb.data","fields":[{"name":"beat","type":"long"}]}"#.into());
         let strategy =
-            SubjectNameStrategy::TopicRecordNameStrategyWithSchema("hb", heartbeat_schema);
+            SubjectNameStrategy::TopicRecordNameStrategyWithSchema("hb".into(), heartbeat_schema);
         let bytes = encoder.encode(vec![("beat", Value::Long(3))], &strategy);
         assert_eq!(bytes, Ok(vec![0, 0, 0, 0, 23, 6]))
     }
@@ -845,9 +845,9 @@ mod tests {
     fn test_encode_topic_record_name_strategy_schema_registry_not_available() {
         let mut encoder = Encoder::new(SERVER_ADDRESS);
 
-        let heartbeat_schema = SuppliedSchema::new(r#"{"type":"record","name":"Heartbeat","namespace":"nl.openweb.data","fields":[{"name":"beat","type":"long"}]}"#);
+        let heartbeat_schema = SuppliedSchema::new(r#"{"type":"record","name":"Heartbeat","namespace":"nl.openweb.data","fields":[{"name":"beat","type":"long"}]}"#.into());
         let strategy =
-            SubjectNameStrategy::TopicRecordNameStrategyWithSchema("hb", heartbeat_schema);
+            SubjectNameStrategy::TopicRecordNameStrategyWithSchema("hb".into(), heartbeat_schema);
         let error = encoder.encode(vec![("beat", Value::Long(3))], &strategy);
         assert_eq!(
             error,
diff --git a/src/schema_registry.rs b/src/schema_registry.rs
index 93afba8..254d816 100644
--- a/src/schema_registry.rs
+++ b/src/schema_registry.rs
@@ -6,7 +6,7 @@ extern crate serde_json;
 
 use self::avro_rs::Schema;
 use self::curl::easy::{Easy2, Handler, List, WriteError};
-use self::serde_json::Value as JsonValue;
+use self::serde_json::{Value as JsonValue, Map as JsonMap};
 use core::fmt;
 use std::error::Error;
 use std::ops::Deref;
@@ -16,15 +16,15 @@ use std::str;
 /// this struct so we keep them both together.
 #[derive(Clone, Debug)]
 pub struct SuppliedSchema {
-    raw: &'static str,
+    raw: String,
     parsed: Schema,
 }
 
 /// Will panic when the input is invalid.
 impl SuppliedSchema {
     /// Creates a new Supplied Schema
-    pub fn new(raw: &'static str) -> SuppliedSchema {
-        let parsed = match Schema::parse_str(raw) {
+    pub fn new(raw: String) -> SuppliedSchema {
+        let parsed = match Schema::parse_str(raw.as_str()) {
             Ok(v) => v,
             Err(e) => panic!(
                 "Supplied raw value {} cant be turned into a Schema, error: {}",
@@ -59,19 +59,19 @@ impl SuppliedSchema {
 ///
 /// let mut encoder = Encoder::new(SERVER_ADDRESS);
 ///
-/// let heartbeat_schema = SuppliedSchema::new(r#"{"type":"record","name":"Heartbeat","namespace":"nl.openweb.data","fields":[{"name":"beat","type":"long"}]}"#);
-/// let strategy = SubjectNameStrategy::TopicRecordNameStrategyWithSchema("hb", heartbeat_schema);
+/// let heartbeat_schema = SuppliedSchema::new(r#"{"type":"record","name":"Heartbeat","namespace":"nl.openweb.data","fields":[{"name":"beat","type":"long"}]}"#.into());
+/// let strategy = SubjectNameStrategy::TopicRecordNameStrategyWithSchema("hb".into(), heartbeat_schema);
 /// let bytes = encoder.encode(vec![("beat", Value::Long(3))], &strategy);
 /// assert_eq!(bytes, Ok(vec![0, 0, 0, 0, 23, 6]))
 /// ```
-#[derive(Debug)]
-pub enum SubjectNameStrategy<'a> {
-    RecordNameStrategy(&'a str),
-    TopicNameStrategy(&'a str, bool),
-    TopicRecordNameStrategy(&'a str, &'a str),
+#[derive(Clone, Debug)]
+pub enum SubjectNameStrategy {
+    RecordNameStrategy(String),
+    TopicNameStrategy(String, bool),
+    TopicRecordNameStrategy(String, String),
     RecordNameStrategyWithSchema(SuppliedSchema),
-    TopicNameStrategyWithSchema(&'a str, bool, SuppliedSchema),
-    TopicRecordNameStrategyWithSchema(&'a str, SuppliedSchema),
+    TopicNameStrategyWithSchema(String, bool, SuppliedSchema),
+    TopicRecordNameStrategyWithSchema(String, SuppliedSchema),
 }
 
 /// Gets a schema by an id. This is used to get the correct schema te deserialize bytes, when the
@@ -124,7 +124,7 @@ fn get_schema(subject_name_strategy: &SubjectNameStrategy) -> Option<SuppliedSch
 /// it's compatible with the Java client.
 pub fn get_subject(subject_name_strategy: &SubjectNameStrategy) -> String {
     match subject_name_strategy {
-        SubjectNameStrategy::RecordNameStrategy(rn) => String::from(*rn),
+        SubjectNameStrategy::RecordNameStrategy(rn) => rn.clone(),
         SubjectNameStrategy::TopicNameStrategy(t, is_key) => {
             if *is_key {
                 format!("{}-key", t)
@@ -205,8 +205,13 @@ fn schema_from_url(url: &str, id: Option<u32>) -> Result<(Schema, u32), SRCError
 /// registry, the matching id is returned. When it's not it depends on the settings of the schema
 /// registry. The default config will check if the schema is backwards compatible. One of the ways
 /// to do this is to add a default value for new fields.
-fn post_schema(url: &str, schema: SuppliedSchema) -> Result<(Schema, u32), SRCError> {
-    let easy = match perform_post(url, schema.raw) {
+pub fn post_schema(url: &str, schema: SuppliedSchema) -> Result<(Schema, u32), SRCError> {
+    let mut root_element = JsonMap::new();
+    root_element.insert("schema".into(), JsonValue::String(schema.raw.clone()));
+    let schema_element = JsonValue::Object(root_element);
+    let schema_str = schema_element.to_string();
+
+    let easy = match perform_post(url, schema_str.as_str()) {
         Ok(v) => v,
         Err(e) => {
             return Err(SRCError::new(
@@ -244,7 +249,7 @@ fn perform_post(url: &str, schema_raw: &str) -> Result<Easy2<Collector>, curl::E
     easy.post_fields_copy(schema_raw.as_bytes())?;
     let mut list = List::new();
     list.append("Content-Type: application/vnd.schemaregistry.v1+json")?;
-    list.append("Accept: json")?;
+    list.append("Accept: application/vnd.schemaregistry.v1+json")?;
     easy.http_headers(list)?;
     easy.perform()?;
     Ok(easy)
@@ -378,12 +383,12 @@ impl SRCError {
 #[test]
 #[should_panic]
 fn panic_when_invalid_schema() {
-    SuppliedSchema::new(r#"{"type":"record","name":"Name"}"#);
+    SuppliedSchema::new(r#"{"type":"record","name":"Name"}"#.into());
 }
 
 #[test]
 fn display_record_name_strategy() {
-    let sns = SubjectNameStrategy::RecordNameStrategy("bla");
+    let sns = SubjectNameStrategy::RecordNameStrategy("bla".into());
     assert_eq!(
         "RecordNameStrategy(\"bla\")".to_owned(),
         format!("{:?}", sns)
@@ -392,7 +397,7 @@ fn display_record_name_strategy() {
 
 #[test]
 fn display_topic_name_strategy() {
-    let sns = SubjectNameStrategy::TopicNameStrategy("bla", true);
+    let sns = SubjectNameStrategy::TopicNameStrategy("bla".into(), true);
     assert_eq!(
         "TopicNameStrategy(\"bla\", true)".to_owned(),
         format!("{:?}", sns)
@@ -401,7 +406,7 @@ fn display_topic_name_strategy() {
 
 #[test]
 fn display_topic_record_name_strategy() {
-    let sns = SubjectNameStrategy::TopicRecordNameStrategy("bla", "foo");
+    let sns = SubjectNameStrategy::TopicRecordNameStrategy("bla".into(), "foo".into());
     assert_eq!(
         "TopicRecordNameStrategy(\"bla\", \"foo\")".to_owned(),
         format!("{:?}", sns)
@@ -410,29 +415,29 @@ fn display_topic_record_name_strategy() {
 
 #[test]
 fn display_record_name_strategy_with_schema() {
-    let ss = SuppliedSchema::new(r#"{"type":"record","name":"Name","namespace":"nl.openweb.data","fields":[{"name":"name","type":"string","avro.java.string":"String"}]}"#);
+    let ss = SuppliedSchema::new(r#"{"type":"record","name":"Name","namespace":"nl.openweb.data","fields":[{"name":"name","type":"string","avro.java.string":"String"}]}"#.into());
     let sns = SubjectNameStrategy::RecordNameStrategyWithSchema(ss);
     assert_eq!("RecordNameStrategyWithSchema(SuppliedSchema { raw: \"{\\\"type\\\":\\\"record\\\",\\\"name\\\":\\\"Name\\\",\\\"namespace\\\":\\\"nl.openweb.data\\\",\\\"fields\\\":[{\\\"name\\\":\\\"name\\\",\\\"type\\\":\\\"string\\\",\\\"avro.java.string\\\":\\\"String\\\"}]}\", parsed: Record { name: Name { name: \"Name\", namespace: Some(\"nl.openweb.data\"), aliases: None }, doc: None, fields: [RecordField { name: \"name\", doc: None, default: None, schema: String, order: Ascending, position: 0 }], lookup: {\"name\": 0} } })".to_owned(), format!("{:?}", sns))
 }
 
 #[test]
 fn display_topic_name_strategy_with_schema() {
-    let ss = SuppliedSchema::new(r#"{"type":"record","name":"Name","namespace":"nl.openweb.data","fields":[{"name":"name","type":"string","avro.java.string":"String"}]}"#);
-    let sns = SubjectNameStrategy::TopicNameStrategyWithSchema("bla", true, ss);
+    let ss = SuppliedSchema::new(r#"{"type":"record","name":"Name","namespace":"nl.openweb.data","fields":[{"name":"name","type":"string","avro.java.string":"String"}]}"#.into());
+    let sns = SubjectNameStrategy::TopicNameStrategyWithSchema("bla".into(), true, ss);
     assert_eq!("TopicNameStrategyWithSchema(\"bla\", true, SuppliedSchema { raw: \"{\\\"type\\\":\\\"record\\\",\\\"name\\\":\\\"Name\\\",\\\"namespace\\\":\\\"nl.openweb.data\\\",\\\"fields\\\":[{\\\"name\\\":\\\"name\\\",\\\"type\\\":\\\"string\\\",\\\"avro.java.string\\\":\\\"String\\\"}]}\", parsed: Record { name: Name { name: \"Name\", namespace: Some(\"nl.openweb.data\"), aliases: None }, doc: None, fields: [RecordField { name: \"name\", doc: None, default: None, schema: String, order: Ascending, position: 0 }], lookup: {\"name\": 0} } })".to_owned(), format!("{:?}", sns))
 }
 
 #[test]
 fn display_topic_record_name_strategy_with_schema() {
-    let ss = SuppliedSchema::new(r#"{"type":"record","name":"Name","namespace":"nl.openweb.data","fields":[{"name":"name","type":"string","avro.java.string":"String"}]}"#);
-    let sns = SubjectNameStrategy::TopicRecordNameStrategyWithSchema("bla", ss);
+    let ss = SuppliedSchema::new(r#"{"type":"record","name":"Name","namespace":"nl.openweb.data","fields":[{"name":"name","type":"string","avro.java.string":"String"}]}"#.into());
+    let sns = SubjectNameStrategy::TopicRecordNameStrategyWithSchema("bla".into(), ss);
     assert_eq!("TopicRecordNameStrategyWithSchema(\"bla\", SuppliedSchema { raw: \"{\\\"type\\\":\\\"record\\\",\\\"name\\\":\\\"Name\\\",\\\"namespace\\\":\\\"nl.openweb.data\\\",\\\"fields\\\":[{\\\"name\\\":\\\"name\\\",\\\"type\\\":\\\"string\\\",\\\"avro.java.string\\\":\\\"String\\\"}]}\", parsed: Record { name: Name { name: \"Name\", namespace: Some(\"nl.openweb.data\"), aliases: None }, doc: None, fields: [RecordField { name: \"name\", doc: None, default: None, schema: String, order: Ascending, position: 0 }], lookup: {\"name\": 0} } })".to_owned(), format!("{:?}", sns))
 }
 
 #[test]
 #[should_panic]
 fn panic_when_schema_is_not_a_record() {
-    let ss = SuppliedSchema::new(r#"{"type":"boolean","value":"true"}"#);
+    let ss = SuppliedSchema::new(r#"{"type":"boolean","value":"true"}"#.into());
     let sns = SubjectNameStrategy::RecordNameStrategyWithSchema(ss);
     get_subject(&sns);
 }
@@ -440,8 +445,8 @@ fn panic_when_schema_is_not_a_record() {
 #[test]
 #[should_panic]
 fn panic_when_schema_is_not_a_record_2() {
-    let ss = SuppliedSchema::new(r#"{"type":"boolean","value":"true"}"#);
-    let sns = SubjectNameStrategy::TopicRecordNameStrategyWithSchema("bla", ss);
+    let ss = SuppliedSchema::new(r#"{"type":"boolean","value":"true"}"#.into());
+    let sns = SubjectNameStrategy::TopicRecordNameStrategyWithSchema("bla".into(), ss);
     get_subject(&sns);
 }
 


Test patch: