public void RegisterSchema()
        {
            string groupName = TestEnvironment.SchemaRegistryGroup;

            #region Snippet:SchemaRegistryRegisterSchema
            string            name = "employeeSample";
            SerializationType type = SerializationType.Avro;
            // Example schema's content
            string content = @"
            {
               ""type"" : ""record"",
                ""namespace"" : ""TestSchema"",
                ""name"" : ""Employee"",
                ""fields"" : [
                { ""name"" : ""Name"" , ""type"" : ""string"" },
                { ""name"" : ""Age"", ""type"" : ""int"" }
                ]
            }";

            Response <SchemaProperties> schemaProperties = client.RegisterSchema(groupName, name, content, type);
            #endregion

            Assert.NotNull(schemaProperties);
            _schemaProperties = schemaProperties.Value;
            _content          = content;
        }
        public void RegisterSchema()
        {
            string groupName = TestEnvironment.SchemaRegistryGroup;

            #region Snippet:SchemaRegistryRegisterSchema
            string       name   = "employeeSample";
            SchemaFormat format = SchemaFormat.Avro;
            // Example schema's definition
            string definition = @"
            {
               ""type"" : ""record"",
                ""namespace"" : ""TestSchema"",
                ""name"" : ""Employee"",
                ""fields"" : [
                { ""name"" : ""Name"" , ""type"" : ""string"" },
                { ""name"" : ""Age"", ""type"" : ""int"" }
                ]
            }";

            Response <SchemaProperties> schemaProperties = client.RegisterSchema(groupName, name, definition, format);
            #endregion

            Assert.NotNull(schemaProperties);
            _schemaProperties = schemaProperties.Value;
            _definition       = definition;
        }
        private string GetSchemaId(Schema schema, CancellationToken cancellationToken)
        {
            var schemaProperties = _options.AutoRegisterSchemas
                ? _client.RegisterSchema(_groupName, schema.Fullname, schema.ToString(), SerializationType.Avro, cancellationToken)
                : _client.GetSchemaProperties(_groupName, schema.Fullname, schema.ToString(), SerializationType.Avro, cancellationToken);

            return(schemaProperties.Id);
        }
Example #4
0
        public void RegisterSchema()
        {
            var client = new SchemaRegistryClient(TestEnvironment.SchemaRegistryUri, TestEnvironment.Credential);

            #region Snippet:SchemaRegistryRegisterSchema
            string            schemaName = "<schema_name>";
            string            groupName  = "<schema_group_name>";
            SerializationType schemaType = SerializationType.Avro;
            // Example schema's content
            string schemaContent = @"
            {
               ""type"" : ""record"",
                ""namespace"" : ""TestSchema"",
                ""name"" : ""Employee"",
                ""fields"" : [
                { ""name"" : ""Name"" , ""type"" : ""string"" },
                { ""name"" : ""Age"", ""type"" : ""int"" }
                ]
            }";

            Response <SchemaProperties> schemaProperties = client.RegisterSchema(groupName, schemaName, schemaType, schemaContent);
            #endregion
        }