riferrei / srclient

Golang Client for Schema Registry
Apache License 2.0
236 stars 70 forks source link

Following the example i get unknown field "schemaType" response from schema registry #11

Closed alok87 closed 4 years ago

alok87 commented 4 years ago

Error

panic: 422 : Unrecognized field: schemaType

Program

package main

import (
    "encoding/binary"
    "encoding/json"
    "fmt"
    "io/ioutil"

    "github.com/riferrei/srclient"
)

func main() {
    topic := "loader-datapipe.inventory.products"
    schemaRegistryClient := srclient.CreateSchemaRegistryClient("XXXX:8081")

    schema, err := schemaRegistryClient.GetLatestSchema(topic, false)
    if schema == nil {
        schemaBytes, _ := ioutil.ReadFile("complexType.avsc")
        schema, err = schemaRegistryClient.CreateSchema(topic, string(schemaBytes), srclient.Avro, false)
        if err != nil {
            panic(fmt.Sprintf("Error creating the schema %s", err))
        }
    }
    schemaIDBytes := make([]byte, 4)
    binary.BigEndian.PutUint32(schemaIDBytes, uint32(schema.ID()))

    fmt.Printf("schemaIDBytes:%v\n" schemaIDBytes)

}