-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exporting/importing AVRO Schemas files #789
Comments
Export$ export TOPIC=topicName
$ curl http://kafka-schema:8081/subjects/$TOPIC-value/versions/latest | jq -r '.schema|fromjson' > $TOPIC-value.avsc Repeat for key schema, if needed ImportGet the schema string $ export SCHEMA=$(jq tostring $TOPIC-value.avsc)
$ echo "{\"schema\":$SCHEMA}"
{"schema":"{\"type\":\"record\",\"name\":...} Post the schema $ curl -XPOST -H "Content-Type:application/json" -d"{\"schema\":$SCHEMA}" http://kafka-schema:8081/subjects/$TOPIC-value/versions |
Thanks for pointing to |
Alternative solution with HTTPie and jq # import schema from file
http -v POST :8081/subjects/example.with-schema.user-value/versions \
Accept:application/vnd.schemaregistry.v1+json \
schema=@avro/src/main/avro/user.avsc
# export schema to file
http :8081/subjects/example.with-schema.user-value/versions/latest \
| jq -r '.schema|fromjson' \
| tee avro/src/main/avro/user-latest.avsc You can check the full example here |
In that repo, I would suggest trying to download as part of the SBT compile phase,much like how you can use the Maven plugin otherwise |
I'm looking for sbt alternatives to kafka-schema-registry-maven-plugin. @Cricket007 anything to recommend? So far, I found sbt-schema-registry-downloader, but is not production ready and if I don't find one, I was thinking to write a plugin that does the same as the maven plugin (probably using http4s instead of Akka) that can be integrated with sbt-avrohugger |
@niqdev I'm not too familiar with SBT plugins myself. I primarily stick to Maven&Gradle |
You can try using the below script. This will migrate you schema cross-cluster schema registry service. schema_registry_source='http://hostname:8081' curl -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" -d"{"schema":$schemapayload}" $schema_registry_sink/subjects/$TOPIC-value/versions |
Looks like export and import feature omit the schema Id and version number. How this supposed to work in this case: #1236 ? thanks, Jdang |
@jdang67 Last I checked, it's not possible to upload a schema to a particular ID. |
How can I export/import AVRO schemas from/to the schema-registry to/from an AVSC file?
The text was updated successfully, but these errors were encountered: