Skip to content

Commit 39fd52e

Browse files
authored
Implement a is_known_schema convenience function (#2280)
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
1 parent 0d97ef7 commit 39fd52e

4 files changed

Lines changed: 428 additions & 110 deletions

File tree

src/core/jsonschema/bundle.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ auto is_official_metaschema_reference(
1919
assert(!pointer.empty());
2020
assert(pointer.back().is_property());
2121
return pointer.back().to_property() == "$schema" &&
22-
sourcemeta::core::schema_resolver(destination).has_value();
22+
sourcemeta::core::is_known_schema(destination);
2323
}
2424

2525
auto dependencies_internal(const sourcemeta::core::JSON &schema,

src/core/jsonschema/include/sourcemeta/core/jsonschema.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ namespace sourcemeta::core {
4040
SOURCEMETA_CORE_JSONSCHEMA_EXPORT
4141
auto schema_resolver(const std::string_view identifier) -> std::optional<JSON>;
4242

43+
/// @ingroup jsonschema
44+
/// Check if a given identifier corresponds to a known built-in schema
45+
SOURCEMETA_CORE_JSONSCHEMA_EXPORT
46+
auto is_known_schema(const std::string_view identifier) noexcept -> bool;
47+
4348
/// @ingroup jsonschema
4449
/// A default schema walker with support for a wide range of drafts
4550
SOURCEMETA_CORE_JSONSCHEMA_EXPORT

0 commit comments

Comments
 (0)