Skip to content

Commit

Permalink
Merge pull request #5568 from BenPope/schema-registry-return-schematype
Browse files Browse the repository at this point in the history
schema_registry: Return schemaType for /schemas/ids/<id>
  • Loading branch information
BenPope committed Jul 22, 2022
2 parents 5bdd7d7 + 2412a24 commit 63235a5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/v/pandaproxy/api/api-doc/schema_registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@
"schema": {
"type": "object",
"properties": {
"schemaType": {
"type": "string"
},
"schema": {
"type": "string"
}
Expand Down
2 changes: 1 addition & 1 deletion src/v/pandaproxy/api/api-doc/schema_registry_header.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"swagger": "2.0",
"info": {
"title": "Pandaproxy Schema Registry",
"version": "1.0.0"
"version": "1.0.1"
},
"host": "{{Host}}",
"basePath": "/",
Expand Down
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 63235a5

Please sign in to comment.