Register proto schema with REST api

The REST api supports registering schema versions for protobuf file if the body of the POST request is a JSON version of the proto file.

Where can I find the utility that converts .proto files to .json content? Some Confluent training videos make mention of a protoJsonFmt.sh tool, but I cannot find that anywhere.

Hi @KenHuffman ,

I can’t find the file, but here’s the body of the script that you should be able to copy/paste into a file:

PROTO_JSON=$(awk '{gsub(/\n/,"\\\n"); gsub(/"/, "\\\"");print}' $1) \
    && SCHEMA="{\"schemaType\":\"PROTOBUF\",\"schema\":\"${PROTO_JSON}\"\n}" \
    && echo ${SCHEMA}

Here’s how you would execute it:

/protoJsonFmt.sh src/main/proto/purchase.proto 

You can adjust the parameter to be the path wherever you have your proto file

HTH,
Bill