Skip to content
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

schema_registry: Return schemaType for /schemas/ids/<id> #5568

Merged
merged 2 commits into from
Jul 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious: is this version type exposed anywhere?

Copy link
Member Author

@BenPope BenPope Jul 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curl -s localhost:8081/v1 | jq '.info.version'
"1.0.1"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I should set up a better home for the swagger

},
"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) {
jrkinley marked this conversation as resolved.
Show resolved Hide resolved
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