Skip to content

Commit

Permalink
Rename official_resolver to schema_official_resolver
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <[email protected]>
  • Loading branch information
jviotti committed Jan 30, 2025
1 parent 8cf5a49 commit a5b48e4
Show file tree
Hide file tree
Showing 72 changed files with 501 additions and 499 deletions.
2 changes: 1 addition & 1 deletion src/core/jsonschema/bundle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ auto is_official_metaschema_reference(const sourcemeta::core::Pointer &pointer,
const std::string &destination) -> bool {
return !pointer.empty() && pointer.back().is_property() &&
pointer.back().to_property() == "$schema" &&
sourcemeta::core::official_resolver(destination).has_value();
sourcemeta::core::schema_official_resolver(destination).has_value();
}

auto bundle_schema(sourcemeta::core::JSON &root, const std::string &container,
Expand Down
20 changes: 10 additions & 10 deletions src/core/jsonschema/include/sourcemeta/core/jsonschema.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ enum class SchemaIdentificationStrategy : std::uint8_t {
/// })JSON");
///
/// std::optional<std::string> id{sourcemeta::core::identify(
/// document, sourcemeta::core::official_resolver)};
/// document, sourcemeta::core::schema_official_resolver)};
/// assert(id.has_value());
/// assert(id.value() == "https://sourcemeta.com/example-schema");
/// ```
Expand Down Expand Up @@ -121,7 +121,7 @@ auto identify(const JSON &schema, const std::string &base_dialect,
/// "https://json-schema.org/draft/2020-12/schema");
///
/// std::optional<std::string> id{sourcemeta::core::identify(
/// document, sourcemeta::core::official_resolver)};
/// document, sourcemeta::core::schema_official_resolver)};
/// assert(!id.has_value());
/// ```
SOURCEMETA_CORE_JSONSCHEMA_EXPORT
Expand All @@ -145,10 +145,10 @@ auto anonymize(JSON &schema, const std::string &base_dialect) -> void;
///
/// sourcemeta::core::reidentify(document,
/// "https://example.com/my-new-id",
/// sourcemeta::core::official_resolver);
/// sourcemeta::core::schema_official_resolver);
///
/// std::optional<std::string> id{sourcemeta::core::identify(
/// document, sourcemeta::core::official_resolver)};
/// document, sourcemeta::core::schema_official_resolver)};
/// assert(id.has_value());
/// assert(id.value() == "https://example.com/my-new-id");
/// ```
Expand Down Expand Up @@ -210,7 +210,7 @@ auto dialect(const JSON &schema,
///
/// const sourcemeta::core::JSON metaschema{
/// sourcemeta::core::metaschema(
/// document, sourcemeta::core::official_resolver)};
/// document, sourcemeta::core::schema_official_resolver)};
///
/// sourcemeta::core::prettify(metaschema, std::cout);
/// std::cout << std::endl;
Expand Down Expand Up @@ -242,7 +242,7 @@ auto metaschema(
///
/// const std::optional<std::string> base_dialect{
/// sourcemeta::core::base_dialect(
/// document, sourcemeta::core::official_resolver)};
/// document, sourcemeta::core::schema_official_resolver)};
///
/// assert(base_dialect.has_value());
/// assert(base_dialect.value() ==
Expand Down Expand Up @@ -275,7 +275,7 @@ auto base_dialect(const JSON &schema, const SchemaResolver &resolver,
///
/// const std::map<std::string, bool> vocabularies{
/// sourcemeta::core::vocabularies(
/// document, sourcemeta::core::official_resolver)};
/// document, sourcemeta::core::schema_official_resolver)};
///
/// assert(vocabularies.at("https://json-schema.org/draft/2020-12/vocab/core"));
/// assert(vocabularies.at("https://json-schema.org/draft/2020-12/vocab/applicator"));
Expand Down Expand Up @@ -341,7 +341,7 @@ auto schema_format_compare(const JSON::String &left, const JSON::String &right)
///
/// sourcemeta::core::unidentify(schema,
/// sourcemeta::core::schema_official_walker,
/// sourcemeta::core::official_resolver);
/// sourcemeta::core::schema_official_resolver);
///
/// const sourcemeta::core::JSON expected =
/// sourcemeta::core::parse_json(R"JSON({
Expand Down Expand Up @@ -387,7 +387,7 @@ using SchemaVisitorReference = std::function<void(
///
/// sourcemeta::core::reference_visit(schema,
/// sourcemeta::core::schema_official_walker,
/// sourcemeta::core::official_resolver,
/// sourcemeta::core::schema_official_resolver,
/// sourcemeta::core::reference_visitor_relativize);
///
/// const sourcemeta::core::JSON expected =
Expand Down Expand Up @@ -437,7 +437,7 @@ auto reference_visitor_relativize(JSON &subschema, const URI &base,
///
/// sourcemeta::core::reference_visit(schema,
/// sourcemeta::core::schema_official_walker,
/// sourcemeta::core::official_resolver,
/// sourcemeta::core::schema_official_resolver,
/// visitor);
/// ```
SOURCEMETA_CORE_JSONSCHEMA_EXPORT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace sourcemeta::core {
/// "type": "string"
/// })JSON");
/// } else {
/// return sourcemeta::core::official_resolver(identifier);
/// return sourcemeta::core::schema_official_resolver(identifier);
/// }
/// }
///
Expand Down Expand Up @@ -94,7 +94,7 @@ auto bundle(sourcemeta::core::JSON &schema, const SchemaWalker &walker,
/// "type": "string"
/// })JSON");
/// } else {
/// return sourcemeta::core::official_resolver(identifier);
/// return sourcemeta::core::schema_official_resolver(identifier);
/// }
/// }
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace sourcemeta::core {
/// sourcemeta::core::SchemaSchemaFrame frame;
/// frame.analyse(document,
/// sourcemeta::core::schema_official_walker,
/// sourcemeta::core::official_resolver);
/// sourcemeta::core::schema_official_resolver);
///
/// // IDs
/// assert(frame.locations().contains({sourcemeta::core::SchemaReferenceType::Static,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace sourcemeta::core {
///
/// For convenience, we provide the following default resolvers:
///
/// - sourcemeta::core::official_resolver
/// - sourcemeta::core::schema_official_resolver
///
/// You can implement resolvers to read from a local storage, to send HTTP
/// requests, or anything your application might require. Unless your resolver
Expand All @@ -35,7 +35,7 @@ using SchemaResolver = std::function<std::optional<JSON>(std::string_view)>;
/// @ingroup jsonschema
/// A default resolver that relies on built-in official schemas.
SOURCEMETA_CORE_JSONSCHEMA_EXPORT
auto official_resolver(std::string_view identifier)
auto schema_official_resolver(std::string_view identifier)
-> std::optional<sourcemeta::core::JSON>;

/// @ingroup jsonschema
Expand All @@ -48,7 +48,7 @@ auto official_resolver(std::string_view identifier)
///
/// // (1) Create a map resolver that falls back to the official resolver
/// sourcemeta::core::SchemaMapResolver
/// resolver{sourcemeta::core::official_resolver};
/// resolver{sourcemeta::core::schema_official_resolver};
///
/// const sourcemeta::core::JSON schema =
/// sourcemeta::core::parse_json(R"JSON({
Expand Down Expand Up @@ -105,7 +105,7 @@ class SOURCEMETA_CORE_JSONSCHEMA_EXPORT SchemaMapResolver {
///
/// // (1) Create a flat file resolver that falls back to the official resolver
/// sourcemeta::core::SchemaFlatFileResolver
/// resolver{sourcemeta::core::official_resolver};
/// resolver{sourcemeta::core::schema_official_resolver};
///
/// // (2) Register a schema by path
/// resolver.add("path/to/example.schema.json");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class SOURCEMETA_CORE_JSONSCHEMA_EXPORT SchemaTransformRule {
///
/// // Apply the transformation bundle to the schema
/// bundle.apply(schema, sourcemeta::core::schema_official_walker,
/// sourcemeta::core::official_resolver);
/// sourcemeta::core::schema_official_resolver);
///
/// // `foo` keywords are gone
/// assert(!schema.defines("foo"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ using SchemaUnevaluatedEntries = std::map<std::string, SchemaUnevaluatedEntry>;
/// sourcemeta::core::SchemaSchemaFrame frame;
/// frame.analyse(document,
/// sourcemeta::core::schema_official_walker,
/// sourcemeta::core::official_resolver);
/// sourcemeta::core::schema_official_resolver);
/// const auto result{sourcemeta::core::unevaluated(
/// schema, frame,
/// sourcemeta::core::schema_official_walker,
/// sourcemeta::core::official_resolver)};
/// sourcemeta::core::schema_official_resolver)};
///
/// assert(result.contains("#/unevaluatedProperties"));
/// assert(!result.at("#/unevaluatedProperties").dynamic);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ struct SchemaIteratorEntry {
/// for (const auto &entry :
/// sourcemeta::core::SchemaIterator{
/// document, sourcemeta::core::schema_official_walker,
/// sourcemeta::core::official_resolver}) {
/// sourcemeta::core::schema_official_resolver}) {
/// sourcemeta::core::prettify(
/// sourcemeta::core::get(document, entry.pointer), std::cout);
/// std::cout << "\n";
Expand Down Expand Up @@ -164,7 +164,7 @@ class SOURCEMETA_CORE_JSONSCHEMA_EXPORT SchemaIterator {
/// for (const auto &entry :
/// sourcemeta::core::SchemaIteratorFlat{
/// document, sourcemeta::core::schema_official_walker,
/// sourcemeta::core::official_resolver}) {
/// sourcemeta::core::schema_official_resolver}) {
/// sourcemeta::core::prettify(
/// sourcemeta::core::get(document, entry.pointer), std::cout);
/// std::cout << "\n";
Expand Down Expand Up @@ -222,7 +222,7 @@ class SOURCEMETA_CORE_JSONSCHEMA_EXPORT SchemaIteratorFlat {
///
/// const auto vocabularies{
/// sourcemeta::core::vocabularies(
/// document, sourcemeta::core::official_resolver)};
/// document, sourcemeta::core::schema_official_resolver)};
///
/// assert(sourcemeta::core::schema_keyword_priority(
/// "prefixItems", vocabularies,
Expand Down Expand Up @@ -261,7 +261,7 @@ auto SOURCEMETA_CORE_JSONSCHEMA_EXPORT schema_keyword_priority(
/// for (const auto &entry :
/// sourcemeta::core::SchemaKeywordIterator{
/// document, sourcemeta::core::schema_official_walker,
/// sourcemeta::core::official_resolver}) {
/// sourcemeta::core::schema_official_resolver}) {
/// sourcemeta::core::stringify(entry.pointer, std::cout);
/// std::cout << "\n";
/// }
Expand Down
2 changes: 1 addition & 1 deletion src/core/jsonschema/official_resolver.in.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <sourcemeta/core/jsonschema_resolver.h>

auto sourcemeta::core::official_resolver(std::string_view identifier)
auto sourcemeta::core::schema_official_resolver(std::string_view identifier)
-> std::optional<sourcemeta::core::JSON> {
// JSON Schema 2020-12
if (identifier == "https://json-schema.org/draft/2020-12/schema") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ enum class AlterSchemaCategory {
/// })JSON");
///
/// bundle.apply(schema, sourcemeta::core::schema_official_walker,
/// sourcemeta::core::official_resolver);
/// sourcemeta::core::schema_official_resolver);
/// ```
SOURCEMETA_CORE_ALTERSCHEMA_EXPORT
auto add(SchemaTransformer &bundle, const AlterSchemaCategory category) -> void;
Expand Down
4 changes: 2 additions & 2 deletions test/alterschema/alterschema_test_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
sourcemeta::core::add(bundle, \
sourcemeta::core::AlterSchemaCategory::SyntaxSugar); \
bundle.apply(document, sourcemeta::core::schema_official_walker, \
sourcemeta::core::official_resolver);
sourcemeta::core::schema_official_resolver);

#define LINT_AND_FIX_FOR_ANALYSIS(document) \
sourcemeta::core::SchemaTransformer bundle; \
Expand All @@ -32,6 +32,6 @@
sourcemeta::core::add(bundle, \
sourcemeta::core::AlterSchemaCategory::Desugar); \
bundle.apply(document, sourcemeta::core::schema_official_walker, \
sourcemeta::core::official_resolver);
sourcemeta::core::schema_official_resolver);

#endif
24 changes: 12 additions & 12 deletions test/jsonschema/jsonschema_base_dialect_2019_09_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ TEST(JSONSchema_base_dialect_2019_09, jsonschema_schema) {
"type": "object"
})JSON");
const std::optional<std::string> base_dialect{sourcemeta::core::base_dialect(
document, sourcemeta::core::official_resolver)};
document, sourcemeta::core::schema_official_resolver)};
EXPECT_TRUE(base_dialect.has_value());
EXPECT_EQ(base_dialect.value(),
"https://json-schema.org/draft/2019-09/schema");
Expand All @@ -20,7 +20,7 @@ TEST(JSONSchema_base_dialect_2019_09, jsonschema_hyperschema) {
"type": "object"
})JSON");
const std::optional<std::string> base_dialect{sourcemeta::core::base_dialect(
document, sourcemeta::core::official_resolver)};
document, sourcemeta::core::schema_official_resolver)};
EXPECT_TRUE(base_dialect.has_value());
EXPECT_EQ(base_dialect.value(),
"https://json-schema.org/draft/2019-09/hyper-schema");
Expand All @@ -31,7 +31,7 @@ TEST(JSONSchema_base_dialect_2019_09, jsonschema_links) {
"$schema": "https://json-schema.org/draft/2019-09/links"
})JSON");
const std::optional<std::string> base_dialect{sourcemeta::core::base_dialect(
document, sourcemeta::core::official_resolver)};
document, sourcemeta::core::schema_official_resolver)};
EXPECT_TRUE(base_dialect.has_value());
EXPECT_EQ(base_dialect.value(),
"https://json-schema.org/draft/2019-09/schema");
Expand All @@ -42,7 +42,7 @@ TEST(JSONSchema_base_dialect_2019_09, jsonschema_output) {
"$schema": "https://json-schema.org/draft/2019-09/output/schema"
})JSON");
const std::optional<std::string> base_dialect{sourcemeta::core::base_dialect(
document, sourcemeta::core::official_resolver)};
document, sourcemeta::core::schema_official_resolver)};
EXPECT_TRUE(base_dialect.has_value());
EXPECT_EQ(base_dialect.value(),
"https://json-schema.org/draft/2019-09/schema");
Expand All @@ -53,7 +53,7 @@ TEST(JSONSchema_base_dialect_2019_09, jsonschema_output_hyperschema) {
"$schema": "https://json-schema.org/draft/2019-09/output/hyper-schema"
})JSON");
const std::optional<std::string> base_dialect{sourcemeta::core::base_dialect(
document, sourcemeta::core::official_resolver)};
document, sourcemeta::core::schema_official_resolver)};
EXPECT_TRUE(base_dialect.has_value());
EXPECT_EQ(base_dialect.value(),
"https://json-schema.org/draft/2019-09/schema");
Expand All @@ -64,7 +64,7 @@ TEST(JSONSchema_base_dialect_2019_09, jsonschema_meta_applicator) {
"$schema": "https://json-schema.org/draft/2019-09/meta/applicator"
})JSON");
const std::optional<std::string> base_dialect{sourcemeta::core::base_dialect(
document, sourcemeta::core::official_resolver)};
document, sourcemeta::core::schema_official_resolver)};
EXPECT_TRUE(base_dialect.has_value());
EXPECT_EQ(base_dialect.value(),
"https://json-schema.org/draft/2019-09/schema");
Expand All @@ -75,7 +75,7 @@ TEST(JSONSchema_base_dialect_2019_09, jsonschema_meta_content) {
"$schema": "https://json-schema.org/draft/2019-09/meta/content"
})JSON");
const std::optional<std::string> base_dialect{sourcemeta::core::base_dialect(
document, sourcemeta::core::official_resolver)};
document, sourcemeta::core::schema_official_resolver)};
EXPECT_TRUE(base_dialect.has_value());
EXPECT_EQ(base_dialect.value(),
"https://json-schema.org/draft/2019-09/schema");
Expand All @@ -86,7 +86,7 @@ TEST(JSONSchema_base_dialect_2019_09, jsonschema_meta_core) {
"$schema": "https://json-schema.org/draft/2019-09/meta/core"
})JSON");
const std::optional<std::string> base_dialect{sourcemeta::core::base_dialect(
document, sourcemeta::core::official_resolver)};
document, sourcemeta::core::schema_official_resolver)};
EXPECT_TRUE(base_dialect.has_value());
EXPECT_EQ(base_dialect.value(),
"https://json-schema.org/draft/2019-09/schema");
Expand All @@ -97,7 +97,7 @@ TEST(JSONSchema_base_dialect_2019_09, jsonschema_meta_format) {
"$schema": "https://json-schema.org/draft/2019-09/meta/format"
})JSON");
const std::optional<std::string> base_dialect{sourcemeta::core::base_dialect(
document, sourcemeta::core::official_resolver)};
document, sourcemeta::core::schema_official_resolver)};
EXPECT_TRUE(base_dialect.has_value());
EXPECT_EQ(base_dialect.value(),
"https://json-schema.org/draft/2019-09/schema");
Expand All @@ -108,7 +108,7 @@ TEST(JSONSchema_base_dialect_2019_09, jsonschema_meta_hyperschema) {
"$schema": "https://json-schema.org/draft/2019-09/meta/hyper-schema"
})JSON");
const std::optional<std::string> base_dialect{sourcemeta::core::base_dialect(
document, sourcemeta::core::official_resolver)};
document, sourcemeta::core::schema_official_resolver)};
EXPECT_TRUE(base_dialect.has_value());
EXPECT_EQ(base_dialect.value(),
"https://json-schema.org/draft/2019-09/hyper-schema");
Expand All @@ -119,7 +119,7 @@ TEST(JSONSchema_base_dialect_2019_09, jsonschema_meta_meta_data) {
"$schema": "https://json-schema.org/draft/2019-09/meta/meta-data"
})JSON");
const std::optional<std::string> base_dialect{sourcemeta::core::base_dialect(
document, sourcemeta::core::official_resolver)};
document, sourcemeta::core::schema_official_resolver)};
EXPECT_TRUE(base_dialect.has_value());
EXPECT_EQ(base_dialect.value(),
"https://json-schema.org/draft/2019-09/schema");
Expand All @@ -130,7 +130,7 @@ TEST(JSONSchema_base_dialect_2019_09, jsonschema_meta_validation) {
"$schema": "https://json-schema.org/draft/2019-09/meta/validation"
})JSON");
const std::optional<std::string> base_dialect{sourcemeta::core::base_dialect(
document, sourcemeta::core::official_resolver)};
document, sourcemeta::core::schema_official_resolver)};
EXPECT_TRUE(base_dialect.has_value());
EXPECT_EQ(base_dialect.value(),
"https://json-schema.org/draft/2019-09/schema");
Expand Down
Loading

0 comments on commit a5b48e4

Please sign in to comment.