diff --git a/src/jsonschema/CMakeLists.txt b/src/jsonschema/CMakeLists.txt index 8de677a11..068c9aa09 100644 --- a/src/jsonschema/CMakeLists.txt +++ b/src/jsonschema/CMakeLists.txt @@ -7,7 +7,8 @@ noa_library(NAMESPACE sourcemeta PROJECT jsontoolkit NAME jsonschema PRIVATE_HEADERS anchor.h bundle.h resolver.h walker.h reference.h frame.h error.h unevaluated.h keywords.h SOURCES jsonschema.cc default_walker.cc frame.cc - anchor.cc resolver.cc walker.cc bundle.cc unevaluated.cc + anchor.cc resolver.cc walker.cc bundle.cc + unevaluated.cc relativize.cc "${CMAKE_CURRENT_BINARY_DIR}/official_resolver.cc") if(JSONTOOLKIT_INSTALL) diff --git a/src/jsonschema/include/sourcemeta/jsontoolkit/jsonschema.h b/src/jsonschema/include/sourcemeta/jsontoolkit/jsonschema.h index 3f18f1648..0262d1bce 100644 --- a/src/jsonschema/include/sourcemeta/jsontoolkit/jsonschema.h +++ b/src/jsonschema/include/sourcemeta/jsontoolkit/jsonschema.h @@ -322,6 +322,12 @@ SOURCEMETA_JSONTOOLKIT_JSONSCHEMA_EXPORT auto schema_format_compare(const JSON::String &left, const JSON::String &right) -> bool; +// TODO: Test & document +SOURCEMETA_JSONTOOLKIT_JSONSCHEMA_EXPORT +auto relativize( + JSON &schema, const SchemaWalker &walker, const SchemaResolver &resolver, + const std::optional &default_dialect = std::nullopt) -> void; + } // namespace sourcemeta::jsontoolkit #endif diff --git a/src/jsonschema/relativize.cc b/src/jsonschema/relativize.cc new file mode 100644 index 000000000..40efd30a3 --- /dev/null +++ b/src/jsonschema/relativize.cc @@ -0,0 +1,17 @@ +#include + +#include // TODO DEBUG + +namespace sourcemeta::jsontoolkit { + +auto relativize(JSON &schema, const SchemaWalker &walker, + const SchemaResolver &resolver, + const std::optional &default_dialect) -> void { + for (const auto &subschema : + SchemaIterator{schema, walker, resolver, default_dialect}) { + sourcemeta::jsontoolkit::stringify(subschema.pointer, std::cerr); + std::cerr << "\n"; + } +} + +} // namespace sourcemeta::jsontoolkit