Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ if(NOT JSONSCHEMA_PORTABLE OR APPLE)
endif()

find_package(Blaze REQUIRED)
find_package(JSONBinPack REQUIRED)

add_subdirectory(src)

Expand Down
5 changes: 2 additions & 3 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
vendorpull https://github.com/sourcemeta/vendorpull 1dcbac42809cf87cb5b045106b863e17ad84ba02
core https://github.com/sourcemeta/core 9889529cd1d863eb39fc77289581414a183cce19
jsonbinpack https://github.com/sourcemeta/jsonbinpack 147050385dce7086a28ce93e18a4c3baa9719136
blaze https://github.com/sourcemeta/blaze 53b3d89652504c1d61f908c8eb25ee3b46921e0b
core https://github.com/sourcemeta/core 7e3e5ee79ae79d2111a976d8d365cc6818661b47
blaze https://github.com/sourcemeta/blaze 2c5efbd14f5f24dbe3860be8c8d80279edc20d10
ctrf https://github.com/ctrf-io/ctrf 93ea827d951390190171d37443bff169cf47c808
5 changes: 0 additions & 5 deletions cmake/FindJSONBinPack.cmake

This file was deleted.

3 changes: 1 addition & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ target_link_libraries(jsonschema_cli PRIVATE sourcemeta::core::jsonschema)
target_link_libraries(jsonschema_cli PRIVATE sourcemeta::core::openapi)
target_link_libraries(jsonschema_cli PRIVATE sourcemeta::blaze::editor)
target_link_libraries(jsonschema_cli PRIVATE sourcemeta::blaze::configuration)
target_link_libraries(jsonschema_cli PRIVATE sourcemeta::jsonbinpack::compiler)
target_link_libraries(jsonschema_cli PRIVATE sourcemeta::jsonbinpack::runtime)
target_link_libraries(jsonschema_cli PRIVATE sourcemeta::blaze::binpack)
target_link_libraries(jsonschema_cli PRIVATE sourcemeta::blaze::compiler)
target_link_libraries(jsonschema_cli PRIVATE sourcemeta::blaze::evaluator)
target_link_libraries(jsonschema_cli PRIVATE sourcemeta::blaze::output)
Expand Down
11 changes: 5 additions & 6 deletions src/command_decode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
#include <sourcemeta/core/json.h>
#include <sourcemeta/core/jsonschema.h>

#include <sourcemeta/jsonbinpack/compiler.h>
#include <sourcemeta/jsonbinpack/runtime.h>
#include <sourcemeta/blaze/binpack.h>

#include <filesystem> // std::filesystem
#include <fstream> // std::ifstream
Expand Down Expand Up @@ -50,17 +49,17 @@ auto sourcemeta::jsonschema::decode(const sourcemeta::core::Options &options)
const auto &custom_resolver{
resolver(options, options.contains("http"), dialect, configuration)};

sourcemeta::jsonbinpack::compile(schema, sourcemeta::core::schema_walker,
custom_resolver);
const auto encoding{sourcemeta::jsonbinpack::load(schema)};
sourcemeta::blaze::binpack_compile(schema, sourcemeta::core::schema_walker,
custom_resolver);
const auto encoding{sourcemeta::blaze::binpack_load(schema)};

auto input_stream{sourcemeta::core::read_file(options.positional().front())};

const std::filesystem::path output{options.positional().at(1)};
std::ofstream output_stream(sourcemeta::core::weakly_canonical(output),
std::ios::binary);
output_stream.exceptions(std::ios_base::badbit);
sourcemeta::jsonbinpack::Decoder decoder{input_stream};
sourcemeta::blaze::BinPackDecoder decoder{input_stream};

try {
if (output.extension() == ".jsonl") {
Expand Down
13 changes: 6 additions & 7 deletions src/command_encode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
#include <sourcemeta/core/jsonschema.h>
#include <sourcemeta/core/yaml.h>

#include <sourcemeta/jsonbinpack/compiler.h>
#include <sourcemeta/jsonbinpack/runtime.h>
#include <sourcemeta/blaze/binpack.h>

#include <filesystem> // std::filesystem
#include <fstream> // std::ofstream
Expand Down Expand Up @@ -41,9 +40,9 @@ auto sourcemeta::jsonschema::encode(const sourcemeta::core::Options &options)
const auto &custom_resolver{
resolver(options, options.contains("http"), dialect, configuration)};

sourcemeta::jsonbinpack::compile(schema, sourcemeta::core::schema_walker,
custom_resolver);
const auto encoding{sourcemeta::jsonbinpack::load(schema)};
sourcemeta::blaze::binpack_compile(schema, sourcemeta::core::schema_walker,
custom_resolver);
const auto encoding{sourcemeta::blaze::binpack_load(schema)};

const std::filesystem::path document{options.positional().front()};
const auto original_size{std::filesystem::file_size(document)};
Expand All @@ -60,7 +59,7 @@ auto sourcemeta::jsonschema::encode(const sourcemeta::core::Options &options)
sourcemeta::core::weakly_canonical(options.positional().at(1)),
std::ios::binary);
output_stream.exceptions(std::ios_base::badbit);
sourcemeta::jsonbinpack::Encoder encoder{output_stream};
sourcemeta::blaze::BinPackEncoder encoder{output_stream};
std::size_t count{0};
for (const auto &entry : sourcemeta::core::JSONL{stream}) {
LOG_VERBOSE(options) << "Encoding entry #" << count << "\n";
Expand All @@ -87,7 +86,7 @@ auto sourcemeta::jsonschema::encode(const sourcemeta::core::Options &options)
sourcemeta::core::weakly_canonical(options.positional().at(1)),
std::ios::binary);
output_stream.exceptions(std::ios_base::badbit);
sourcemeta::jsonbinpack::Encoder encoder{output_stream};
sourcemeta::blaze::BinPackEncoder encoder{output_stream};
encoder.write(entry, encoding);
output_stream.flush();
const auto total_size{static_cast<std::uint64_t>(output_stream.tellp())};
Expand Down
4 changes: 4 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ add_jsonschema_test(validate/pass_entrypoint_pointer)
add_jsonschema_test(validate/pass_entrypoint_pointer_fragment)
add_jsonschema_test(validate/pass_entrypoint_pointer_space)
add_jsonschema_test(validate/pass_entrypoint_pointer_fragment_space)
add_jsonschema_test(validate/pass_entrypoint_pointer_escaped)
add_jsonschema_test(validate/pass_entrypoint_pointer_fragment_escaped)
add_jsonschema_test(validate/pass_entrypoint_uri)
add_jsonschema_test(validate/fail_entrypoint_invalid_pointer)
add_jsonschema_test(validate/fail_entrypoint_invalid_pointer_escape)
Expand Down Expand Up @@ -997,6 +999,8 @@ add_jsonschema_test(compile/pass_entrypoint_pointer)
add_jsonschema_test(compile/pass_entrypoint_pointer_fragment)
add_jsonschema_test(compile/pass_entrypoint_pointer_space)
add_jsonschema_test(compile/pass_entrypoint_pointer_fragment_space)
add_jsonschema_test(compile/pass_entrypoint_pointer_escaped)
add_jsonschema_test(compile/pass_entrypoint_pointer_fragment_escaped)
add_jsonschema_test(compile/pass_entrypoint_uri)
add_jsonschema_test(compile/fail_entrypoint_invalid_pointer)
add_jsonschema_test(compile/fail_entrypoint_invalid_pointer_escape)
Expand Down
49 changes: 49 additions & 0 deletions test/compile/pass_entrypoint_pointer_escaped.clitest
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
WRITE schema.json UNTIL EOF
{
"$id": "https://example.com/schema",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"$defs": {
"My:Name": {
"type": "string",
"minLength": 1
}
}
}
EOF

RUN compile schema.json --entrypoint '/$$defs/My%3AName' STDIN /dev/null IN . INTO result.txt EXPECTING 0

WRITE expected.txt UNTIL EOF
1> [
1> 9,
1> false,
1> true,
1> [
1> [
1> [
1> 22,
1> [ "minLength" ],
1> [],
1> "https://example.com/schema#/$defs/My:Name/minLength",
1> 2,
1> 1,
1> [ 10, 0 ]
1> ],
1> [
1> 11,
1> [ "type" ],
1> [],
1> "https://example.com/schema#/$defs/My:Name/type",
1> 2,
1> 1,
1> [ 8, 4 ]
1> ]
1> ]
1> ],
1> [],
1> [ "https://json-schema.org/draft/2020-12/vocab/validation" ]
1> ]
EOF

COMPARE result.txt AGAINST expected.txt
49 changes: 49 additions & 0 deletions test/compile/pass_entrypoint_pointer_fragment_escaped.clitest
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
WRITE schema.json UNTIL EOF
{
"$id": "https://example.com/schema",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"$defs": {
"My:Name": {
"type": "string",
"minLength": 1
}
}
}
EOF

RUN compile schema.json --entrypoint '#/$$defs/My%3AName' STDIN /dev/null IN . INTO result.txt EXPECTING 0

WRITE expected.txt UNTIL EOF
1> [
1> 9,
1> false,
1> true,
1> [
1> [
1> [
1> 22,
1> [ "minLength" ],
1> [],
1> "https://example.com/schema#/$defs/My:Name/minLength",
1> 2,
1> 1,
1> [ 10, 0 ]
1> ],
1> [
1> 11,
1> [ "type" ],
1> [],
1> "https://example.com/schema#/$defs/My:Name/type",
1> 2,
1> 1,
1> [ 8, 4 ]
1> ]
1> ]
1> ],
1> [],
1> [ "https://json-schema.org/draft/2020-12/vocab/validation" ]
1> ]
EOF

COMPARE result.txt AGAINST expected.txt
26 changes: 26 additions & 0 deletions test/validate/pass_entrypoint_pointer_escaped.clitest
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
WRITE schema.json UNTIL EOF
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"$defs": {
"My:Name": {
"type": "integer",
"minimum": 1
}
}
}
EOF

WRITE instance.json UNTIL EOF
42
EOF

RUN validate schema.json instance.json --entrypoint '/$$defs/My%3AName' --verbose STDIN /dev/null IN . INTO result.txt EXPECTING 0

WRITE expected.txt UNTIL EOF
2> ok: instance.json
2>
2> 1 validated, 1 passed, 0 failed
EOF

COMPARE result.txt AGAINST expected.txt
26 changes: 26 additions & 0 deletions test/validate/pass_entrypoint_pointer_fragment_escaped.clitest
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
WRITE schema.json UNTIL EOF
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"$defs": {
"My:Name": {
"type": "integer",
"minimum": 1
}
}
}
EOF

WRITE instance.json UNTIL EOF
42
EOF

RUN validate schema.json instance.json --entrypoint '#/$$defs/My%3AName' --verbose STDIN /dev/null IN . INTO result.txt EXPECTING 0

WRITE expected.txt UNTIL EOF
2> ok: instance.json
2>
2> 1 validated, 1 passed, 0 failed
EOF

COMPARE result.txt AGAINST expected.txt
2 changes: 1 addition & 1 deletion vendor/blaze/DEPENDENCIES

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 54 additions & 22 deletions vendor/core/src/core/jsonpointer/jsonpointer.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading