Skip to content

Commit

Permalink
Update frame output to include Type, with correction in test
Browse files Browse the repository at this point in the history
  • Loading branch information
suprith-hub committed Jul 20, 2024
1 parent 09282c0 commit 6ab1671
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
29 changes: 28 additions & 1 deletion src/command_frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,34 @@ auto intelligence::jsonschema::cli::frame(
std::cout << print_stream.str() << std::endl;
} else {
for (const auto &[key, entry] : frame) {
std::cout << "(LOCATION) URI: " << key.second << "\n";
switch (entry.type) {
case sourcemeta::jsontoolkit::ReferenceEntryType::Resource:
std::cout << "(LOCATION)";
break;
case sourcemeta::jsontoolkit::ReferenceEntryType::Anchor:
std::cout << "(ANCHOR)";
break;
case sourcemeta::jsontoolkit::ReferenceEntryType::Pointer:
std::cout << "(POINTER)";
break;
default:
// We should never get here
assert(false);
std::cout << "(UNKNOWN)";
break;
}

std::cout << " URI: ";
std::cout << key.second << "\n";

std::cout << " Type : ";
if (key.first == sourcemeta::jsontoolkit::ReferenceType::Dynamic) {
std::cout << "Dynamic";
} else {
std::cout << "Static";
}
std::cout << "\n";

std::cout << " Schema : "
<< entry.root.value_or("<ANONYMOUS>") << "\n";
std::cout << " Pointer :";
Expand Down
19 changes: 13 additions & 6 deletions test/frame/pass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,49 @@ EOF

cat << 'EOF' > "$TMP/expected.txt"
(LOCATION) URI: https://example.com
Type : Static
Schema : https://example.com
Pointer :
Base URI : https://example.com
Relative Pointer :
Dialect : https://json-schema.org/draft/2020-12/schema
(LOCATION) URI: https://example.com#/$defs
(POINTER) URI: https://example.com#/$defs
Type : Static
Schema : https://example.com
Pointer : /$defs
Base URI : https://example.com
Relative Pointer : /$defs
Dialect : https://json-schema.org/draft/2020-12/schema
(LOCATION) URI: https://example.com#/$defs/string
(POINTER) URI: https://example.com#/$defs/string
Type : Static
Schema : https://example.com
Pointer : /$defs/string
Base URI : https://example.com
Relative Pointer : /$defs/string
Dialect : https://json-schema.org/draft/2020-12/schema
(LOCATION) URI: https://example.com#/$defs/string/type
(POINTER) URI: https://example.com#/$defs/string/type
Type : Static
Schema : https://example.com
Pointer : /$defs/string/type
Base URI : https://example.com
Relative Pointer : /$defs/string/type
Dialect : https://json-schema.org/draft/2020-12/schema
(LOCATION) URI: https://example.com#/$id
(POINTER) URI: https://example.com#/$id
Type : Static
Schema : https://example.com
Pointer : /$id
Base URI : https://example.com
Relative Pointer : /$id
Dialect : https://json-schema.org/draft/2020-12/schema
(LOCATION) URI: https://example.com#/$ref
(POINTER) URI: https://example.com#/$ref
Type : Static
Schema : https://example.com
Pointer : /$ref
Base URI : https://example.com
Relative Pointer : /$ref
Dialect : https://json-schema.org/draft/2020-12/schema
(LOCATION) URI: https://example.com#/$schema
(POINTER) URI: https://example.com#/$schema
Type : Static
Schema : https://example.com
Pointer : /$schema
Base URI : https://example.com
Expand Down

0 comments on commit 6ab1671

Please sign in to comment.