Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benissimo/d4fa3a9bd5561e14e96d029ffd6eee1d to your computer and use it in GitHub Desktop.
Save benissimo/d4fa3a9bd5561e14e96d029ffd6eee1d to your computer and use it in GitHub Desktop.
Manually tested with Confluent Platform 6.2.0
#!/bin/bash
# set -x
function schemaPost {
# Use heredoc to strip out newlines, needed so that post is pure JSON
cat <<EOF
{
"schemaType": "PROTOBUF",
"schema": "${escapedSchema}"
}
EOF
}
valueSchema="`cat test_value_schema0.proto`"
escapedSchema=${valueSchema//\"/\\\"} # escape double quotes
curl -s "http://localhost:8081/subjects/TEST-value/versions" -H "Content-Type: application/vnd.schemaregistry.v1+json" --data @<(cat <<EOF
$(schemaPost)
EOF
)
@benissimo
Copy link
Author

This assumes you have a protobuf file test_value_schema0.proto and that you have Confluent Schema Registry running on port 8081.

@TengHuo
Copy link

TengHuo commented Sep 3, 2021

Marked, thanks Ben, really helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment