'How can I register a protobuf schema with references in other packages in Kafka schema registry?

I'm running Kafka schema registry version 5.5.2, and trying to register a schema that contains a reference to another schema. I managed to do this when the referenced schema was in the same package with the referencing schema, with this curl command:

curl -X POST -H  "Content-Type: application/vnd.schemaregistry.v1+json" \
--data '{"schemaType":"PROTOBUF","references": [{"name": "other.proto","subject": "other.proto","version": 1}],"schema":"syntax = \"proto3\"; package com.acme; import \"other.proto\";\n\nmessage MyRecord {\n  string f1 = 1;\n  OtherRecord f2 = 2;\n }\n"}' \
http://localhost:8081/subjects/test-schema/versions

However, when I changed the package name of the referred schema, like this:

syntax = "proto3";
package some.other.package;

message OtherRecord {
  int32 other_id = 1;
}

I got {"error_code":42201,"message":"Either the input schema or one its references is invalid"} when I tried to register the referring schema, no matter what I put under the references name/subject. That's one of my trials:

curl -X POST -H  "Content-Type: application/vnd.schemaregistry.v1+json" \
--data '{"schemaType":"PROTOBUF","references": [{"name": "other.proto","subject": "other.proto","version": 1}],"schema":"syntax = \"proto3\"; package com.acme; import \"some.package.other.proto\";\n\nmessage MyRecord {\n  string f1 = 1;\n  OtherRecord f2 = 2;\n }\n"}' \
http://localhost:8081/subjects/test-shcema/versions


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source