Skip to content

Offer a way to query the mode of a SchemaFrame #1626

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

Merged
merged 1 commit into from
Apr 16, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ class SOURCEMETA_CORE_JSONSCHEMA_EXPORT SchemaFrame {

SchemaFrame(const Mode mode) : mode_{mode} {}

// Query the current mode that the schema frame was configured with
auto mode() const noexcept -> Mode { return this->mode_; }

/// A single entry in a JSON Schema reference map
struct ReferencesEntry {
std::string destination;
Expand Down
3 changes: 3 additions & 0 deletions test/jsonschema/jsonschema_frame_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,8 @@ TEST(JSONSchema_frame, mode_references) {
frame.analyse(document, sourcemeta::core::schema_official_walker,
sourcemeta::core::schema_official_resolver);

EXPECT_EQ(frame.mode(), sourcemeta::core::SchemaFrame::Mode::References);

EXPECT_EQ(frame.locations().size(), 9);
EXPECT_FRAME_STATIC_RESOURCE(frame, "https://www.example.com",
"https://www.example.com", "",
Expand Down Expand Up @@ -781,6 +783,7 @@ TEST(JSONSchema_frame, mode_locations) {
frame.analyse(document, sourcemeta::core::schema_official_walker,
sourcemeta::core::schema_official_resolver);

EXPECT_EQ(frame.mode(), sourcemeta::core::SchemaFrame::Mode::Locations);
EXPECT_EQ(frame.locations().size(), 9);
EXPECT_FRAME_STATIC_RESOURCE(frame, "https://www.example.com",
"https://www.example.com", "",
Expand Down