Skip to content

Commit

Permalink
schema_registry/store: get_schema now returns references
Browse files Browse the repository at this point in the history
`GET /schemas/ids/<id>` now returns its references.

Fixes #11194

Signed-off-by: Ben Pope <ben@redpanda.com>
  • Loading branch information
BenPope committed Jun 6, 2023
1 parent c13d874 commit 9298788
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/v/pandaproxy/schema_registry/requests/get_schemas_ids_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ inline void rjson_serialize(
}
w.Key("schema");
::json::rjson_serialize(w, res.definition.raw());
if (!res.definition.refs().empty()) {
w.Key("references");
w.StartArray();
for (const auto& ref : res.definition.refs()) {
w.StartObject();
w.Key("name");
::json::rjson_serialize(w, ref.name);
w.Key("subject");
::json::rjson_serialize(w, ref.sub);
w.Key("version");
::json::rjson_serialize(w, ref.version);
w.EndObject();
}
w.EndArray();
}
w.EndObject();
}

Expand Down
7 changes: 7 additions & 0 deletions src/v/pandaproxy/schema_registry/test/sharded_store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ SEASTAR_THREAD_TEST_CASE(test_sharded_store_referenced_by) {
store.is_referenced(pps::subject{"simple.proto"}, pps::schema_version{1})
.get());

auto importing = store.get_schema_definition(pps::schema_id{2}).get();
BOOST_REQUIRE_EQUAL(importing.refs().size(), 1);
BOOST_REQUIRE_EQUAL(importing.refs()[0].sub, imported.refs()[0].sub);
BOOST_REQUIRE_EQUAL(
importing.refs()[0].version, imported.refs()[0].version);
BOOST_REQUIRE_EQUAL(importing.refs()[0].name, imported.refs()[0].name);

// soft delete subject
store
.upsert(
Expand Down

0 comments on commit 9298788

Please sign in to comment.