Skip to content

Commit

Permalink
schema_registry: Return schemaType for /schemas/ids/<id>
Browse files Browse the repository at this point in the history
If the schema type is not avro, then set schemaType field in the
response.

Signed-off-by: Ben Pope <ben@redpanda.com>
  • Loading branch information
BenPope committed Jul 22, 2022
1 parent 374a4d2 commit 68cdd7b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ inline void rjson_serialize(
::json::Writer<::json::StringBuffer>& w,
const get_schemas_ids_id_response& res) {
w.StartObject();
if (res.definition.type() != schema_type::avro) {
w.Key("schemaType");
::json::rjson_serialize(w, to_string_view(res.definition.type()));
}
w.Key("schema");
::json::rjson_serialize(w, res.definition.raw());
w.EndObject();
Expand Down
9 changes: 9 additions & 0 deletions tests/rptest/tests/schema_registry_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,15 @@ def test_protobuf(self):
assert result_raw.status_code == requests.codes.ok
assert result_raw.text.strip() == simple_proto_def.strip()

result_raw = self._request("GET",
f"schemas/ids/1",
headers=HTTP_GET_HEADERS)
self.logger.info(result_raw)
assert result_raw.status_code == requests.codes.ok
result = result_raw.json()
assert result["schemaType"] == "PROTOBUF"
assert result["schema"].strip() == simple_proto_def.strip()

result_raw = self._get_subjects_subject_versions_version_referenced_by(
"simple", 1)
self.logger.info(result_raw)
Expand Down

0 comments on commit 68cdd7b

Please sign in to comment.