diff --git a/DEPENDENCIES b/DEPENDENCIES index 177a63858..f4c7ca075 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -1,3 +1,3 @@ vendorpull https://github.com/sourcemeta/vendorpull 1dcbac42809cf87cb5b045106b863e17ad84ba02 -core https://github.com/sourcemeta/core 6f882d44bce7788ce37d22b6b29aaeb2c7aca385 +core https://github.com/sourcemeta/core d894234fa272759a998fc6ac108583af86532bf8 jsonschema-test-suite https://github.com/json-schema-org/JSON-Schema-Test-Suite f4e41b0c10702620e718d5c309696ee03d963c00 diff --git a/vendor/core/config.cmake.in b/vendor/core/config.cmake.in index ecdba9404..e4ad27f01 100644 --- a/vendor/core/config.cmake.in +++ b/vendor/core/config.cmake.in @@ -79,6 +79,7 @@ foreach(component ${SOURCEMETA_CORE_COMPONENTS}) include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_jsonschema.cmake") include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_editorschema.cmake") elseif(component STREQUAL "schemaconfig") + include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_io.cmake") include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_uri.cmake") include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_json.cmake") include("${CMAKE_CURRENT_LIST_DIR}/sourcemeta_core_jsonpointer.cmake") diff --git a/vendor/core/src/core/jsonschema/jsonschema.cc b/vendor/core/src/core/jsonschema/jsonschema.cc index 7f3dc4926..ef07eeb55 100644 --- a/vendor/core/src/core/jsonschema/jsonschema.cc +++ b/vendor/core/src/core/jsonschema/jsonschema.cc @@ -188,44 +188,6 @@ auto sourcemeta::core::reidentify(JSON &schema, assert(is_schema(schema)); assert(schema.is_object()); schema.assign(id_keyword(base_dialect), JSON{new_identifier}); - - if (schema.defines("$ref")) { - // Workaround top-level `$ref` with `allOf` - if (base_dialect == "http://json-schema.org/draft-07/schema#" || - base_dialect == "http://json-schema.org/draft-07/hyper-schema#" || - base_dialect == "http://json-schema.org/draft-06/schema#" || - base_dialect == "http://json-schema.org/draft-06/hyper-schema#" || - base_dialect == "http://json-schema.org/draft-04/schema#" || - base_dialect == "http://json-schema.org/draft-04/hyper-schema#") { - // Note that if the schema already has an `allOf`, we can safely - // remove it, as it was by definition ignored by `$ref` already - if (schema.defines("allOf")) { - schema.erase("allOf"); - } - - schema.assign("allOf", JSON::make_array()); - auto conjunction{JSON::make_object()}; - conjunction.assign("$ref", schema.at("$ref")); - schema.at("allOf").push_back(std::move(conjunction)); - schema.erase("$ref"); - } - - // Workaround top-level `$ref` with `extends` - if (base_dialect == "http://json-schema.org/draft-03/schema#" || - base_dialect == "http://json-schema.org/draft-03/hyper-schema#") { - // Note that if the schema already has an `extends`, we can safely - // remove it, as it was by definition ignored by `$ref` already - if (schema.defines("extends")) { - schema.erase("extends"); - } - - schema.assign("extends", JSON::make_object()); - schema.at("extends").assign("$ref", schema.at("$ref")); - schema.erase("$ref"); - } - } - - assert(identify(schema, base_dialect).has_value()); } auto sourcemeta::core::dialect( diff --git a/vendor/core/src/extension/schemaconfig/CMakeLists.txt b/vendor/core/src/extension/schemaconfig/CMakeLists.txt index 84990c15a..444236763 100644 --- a/vendor/core/src/extension/schemaconfig/CMakeLists.txt +++ b/vendor/core/src/extension/schemaconfig/CMakeLists.txt @@ -8,3 +8,4 @@ endif() target_link_libraries(sourcemeta_core_schemaconfig PUBLIC sourcemeta::core::json) target_link_libraries(sourcemeta_core_schemaconfig PUBLIC sourcemeta::core::jsonpointer) target_link_libraries(sourcemeta_core_schemaconfig PRIVATE sourcemeta::core::uri) +target_link_libraries(sourcemeta_core_schemaconfig PRIVATE sourcemeta::core::io) diff --git a/vendor/core/src/extension/schemaconfig/find.cc b/vendor/core/src/extension/schemaconfig/find.cc index cdbbdb405..717227f26 100644 --- a/vendor/core/src/extension/schemaconfig/find.cc +++ b/vendor/core/src/extension/schemaconfig/find.cc @@ -1,11 +1,17 @@ +#include #include +#include // assert + namespace sourcemeta::core { auto SchemaConfig::find(const std::filesystem::path &path) -> std::optional { - auto current = - std::filesystem::is_directory(path) ? path : path.parent_path(); + const auto canonical{sourcemeta::core::weakly_canonical(path)}; + assert(canonical.is_absolute()); + auto current = std::filesystem::is_directory(canonical) + ? canonical + : canonical.parent_path(); while (!current.empty()) { auto candidate = current / "jsonschema.json";