├── VERSION ├── .ackrc ├── vendor ├── hydra │ ├── vendor │ │ ├── libpsl │ │ │ └── version.txt │ │ ├── cpr │ │ │ ├── cpr │ │ │ │ ├── payload.cpp │ │ │ │ ├── parameters.cpp │ │ │ │ ├── async.cpp │ │ │ │ ├── unix_socket.cpp │ │ │ │ ├── curlmultiholder.cpp │ │ │ │ ├── multipart.cpp │ │ │ │ ├── cprtypes.cpp │ │ │ │ ├── callback.cpp │ │ │ │ ├── auth.cpp │ │ │ │ └── proxies.cpp │ │ │ ├── include │ │ │ │ └── cpr │ │ │ │ │ ├── reserve_size.h │ │ │ │ │ ├── curlmultiholder.h │ │ │ │ │ ├── limit_rate.h │ │ │ │ │ ├── verbose.h │ │ │ │ │ ├── parameters.h │ │ │ │ │ ├── local_port.h │ │ │ │ │ ├── unix_socket.h │ │ │ │ │ ├── local_port_range.h │ │ │ │ │ ├── payload.h │ │ │ │ │ ├── connect_timeout.h │ │ │ │ │ ├── proxies.h │ │ │ │ │ ├── auth.h │ │ │ │ │ ├── resolve.h │ │ │ │ │ ├── low_speed.h │ │ │ │ │ ├── ssl_ctx.h │ │ │ │ │ └── filesystem.h │ │ │ └── cmake │ │ │ │ └── cprver.h.in │ │ ├── zlib │ │ │ ├── inffast.h │ │ │ └── gzclose.c │ │ ├── mbedtls │ │ │ ├── include │ │ │ │ ├── mbedtls │ │ │ │ │ └── private_access.h │ │ │ │ └── psa │ │ │ │ │ └── build_info.h │ │ │ └── library │ │ │ │ ├── psa_crypto_client.c │ │ │ │ ├── ssl_client.h │ │ │ │ ├── ssl_tls13_invasive.h │ │ │ │ ├── md_psa.h │ │ │ │ └── version.c │ │ └── c-ares │ │ │ └── src │ │ │ └── lib │ │ │ └── windows_port.c │ ├── DEPENDENCIES │ └── LICENSE ├── core │ ├── cmake │ │ ├── common │ │ │ ├── targets │ │ │ │ ├── clang-format.json │ │ │ │ └── googletest.cmake │ │ │ ├── shim.cmake │ │ │ ├── clang-tidy.json │ │ │ ├── commands │ │ │ │ └── copy-file.cmake │ │ │ └── variables.cmake │ │ ├── FindGoogleBenchmark.cmake │ │ └── FindGoogleTest.cmake │ ├── vendor │ │ ├── googlebenchmark │ │ │ ├── cmake │ │ │ │ ├── split_list.cmake │ │ │ │ ├── thread_safety_attributes.cpp │ │ │ │ ├── steady_clock.cpp │ │ │ │ ├── benchmark_main.pc.in │ │ │ │ ├── Config.cmake.in │ │ │ │ ├── std_regex.cpp │ │ │ │ ├── llvm-toolchain.cmake │ │ │ │ ├── gnu_posix_regex.cpp │ │ │ │ ├── posix_regex.cpp │ │ │ │ ├── benchmark.pc.in │ │ │ │ ├── Modules │ │ │ │ │ ├── FindLLVMRanLib.cmake │ │ │ │ │ ├── FindLLVMAr.cmake │ │ │ │ │ └── FindLLVMNm.cmake │ │ │ │ └── pthread_affinity.cpp │ │ │ └── src │ │ │ │ ├── check.cc │ │ │ │ ├── benchmark_main.cc │ │ │ │ └── colorprint.h │ │ ├── pcre2 │ │ │ └── src │ │ │ │ └── libpcre2-posix.sym │ │ ├── googletest │ │ │ ├── googletest │ │ │ │ └── cmake │ │ │ │ │ ├── gtest.pc.in │ │ │ │ │ ├── gtest_main.pc.in │ │ │ │ │ ├── Config.cmake.in │ │ │ │ │ └── libgtest.la.in │ │ │ └── googlemock │ │ │ │ ├── include │ │ │ │ └── gmock │ │ │ │ │ └── internal │ │ │ │ │ └── custom │ │ │ │ │ ├── gmock-generated-actions.h │ │ │ │ │ └── README.md │ │ │ │ └── cmake │ │ │ │ ├── gmock.pc.in │ │ │ │ └── gmock_main.pc.in │ │ ├── jsonschema-2019-09 │ │ │ └── meta │ │ │ │ ├── format.json │ │ │ │ ├── content.json │ │ │ │ └── hyper-schema.json │ │ ├── jsonschema-2020-12 │ │ │ └── meta │ │ │ │ ├── format-assertion.json │ │ │ │ ├── format-annotation.json │ │ │ │ ├── unevaluated.json │ │ │ │ ├── content.json │ │ │ │ └── hyper-schema.json │ │ ├── jsonschema-draft0 │ │ │ ├── json-ref.json │ │ │ └── links.json │ │ ├── jsonschema-draft1 │ │ │ ├── json-ref.json │ │ │ └── links.json │ │ ├── jsonschema-draft2 │ │ │ ├── json-ref.json │ │ │ └── links.json │ │ ├── jsonschema-draft3 │ │ │ ├── json-ref.json │ │ │ └── links.json │ │ └── jsonschema-draft4 │ │ │ └── links.json │ ├── src │ │ ├── lang │ │ │ ├── io │ │ │ │ └── CMakeLists.txt │ │ │ ├── process │ │ │ │ └── CMakeLists.txt │ │ │ ├── parallel │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── include │ │ │ │ │ └── sourcemeta │ │ │ │ │ └── core │ │ │ │ │ └── parallel.h │ │ │ └── numeric │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── include │ │ │ │ └── sourcemeta │ │ │ │ │ └── core │ │ │ │ │ ├── numeric.h │ │ │ │ │ └── numeric_parse.h │ │ │ │ └── parse.cc │ │ ├── core │ │ │ ├── md5 │ │ │ │ └── CMakeLists.txt │ │ │ ├── time │ │ │ │ └── CMakeLists.txt │ │ │ ├── uuid │ │ │ │ └── CMakeLists.txt │ │ │ ├── punycode │ │ │ │ └── CMakeLists.txt │ │ │ ├── regex │ │ │ │ └── CMakeLists.txt │ │ │ ├── jsonl │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── jsonl.cc │ │ │ │ └── grammar.h │ │ │ ├── uri │ │ │ │ └── CMakeLists.txt │ │ │ ├── yaml │ │ │ │ └── CMakeLists.txt │ │ │ ├── json │ │ │ │ └── CMakeLists.txt │ │ │ └── jsonpointer │ │ │ │ └── CMakeLists.txt │ │ └── extension │ │ │ ├── options │ │ │ └── CMakeLists.txt │ │ │ ├── editorschema │ │ │ └── CMakeLists.txt │ │ │ ├── build │ │ │ └── CMakeLists.txt │ │ │ └── schemaconfig │ │ │ └── CMakeLists.txt │ └── LICENSE ├── blaze │ ├── src │ │ ├── output │ │ │ ├── include │ │ │ │ └── sourcemeta │ │ │ │ │ └── blaze │ │ │ │ │ └── output.h │ │ │ └── CMakeLists.txt │ │ └── linter │ │ │ └── CMakeLists.txt │ └── LICENSE └── jsonbinpack │ ├── src │ ├── numeric │ │ ├── CMakeLists.txt │ │ └── include │ │ │ └── sourcemeta │ │ │ └── jsonbinpack │ │ │ ├── numeric.h │ │ │ └── numeric_zigzag.h │ └── runtime │ │ ├── loader_v1_number.h │ │ ├── unreachable.h │ │ ├── decoder_number.cc │ │ └── encoder_number.cc │ └── LICENSE ├── .gitattributes ├── Brewfile ├── assets ├── banner.png └── example.png ├── .npmignore ├── cmake ├── FindBlaze.cmake ├── FindHydra.cmake ├── FindJSONBinPack.cmake └── FindCore.cmake ├── test ├── docker │ └── help.sh ├── metaschema │ ├── pass_draft7_without_fragment.sh │ ├── pass_2020_12.sh │ ├── pass_2020_12_with_fragment.sh │ ├── pass_2020_12_default_dialect.sh │ ├── pass_single.sh │ ├── fail_directory_non_resolved.sh │ ├── pass_cwd.sh │ ├── pass_2020_12_default_dialect_config.sh │ ├── pass_2020_12_default_dialect_config_relative.sh │ └── pass_config_path.sh ├── lint │ ├── pass_lint_default_nested_with_id.sh │ ├── pass_lint_examples_nested_with_id.sh │ ├── pass_lint_list_only_one.sh │ ├── pass_bigint.sh │ ├── pass_lint_json.sh │ ├── pass_lint_list_only_many.sh │ ├── pass_lint_anonymous_default_with_ref.sh │ ├── pass_lint_anonymous_nested_default_with_ref.sh │ ├── pass_lint_fix.sh │ ├── fail_lint_only_unknown.sh │ ├── pass_lint_fix_strict.sh │ ├── pass_lint_fix_no_reformat.sh │ ├── pass_lint_no_fix.sh │ ├── pass_lint_fix_indentation.sh │ ├── fail_lint_only_with_exclude.sh │ ├── pass_lint_embedded_resource.sh │ ├── pass_lint_fix_keep_ordering.sh │ ├── fail_lint_only_unknown_verbose.sh │ ├── pass_lint_ignore_short.sh │ ├── pass_lint_ignore_long.sh │ ├── fail_lint_with_id.sh │ ├── fail_lint_non_schema.sh │ ├── pass_lint_fix_json.sh │ ├── fail_lint_non_schema_fix.sh │ ├── pass_lint_default_fix.sh │ ├── pass_lint_examples_fix.sh │ ├── pass_lint_default_no_fix.sh │ ├── fail_lint_disable_many.sh │ ├── pass_lint_examples_no_fix.sh │ ├── pass_lint_direct_custom_extension.sh │ ├── fail_lint_default.sh │ └── fail_lint_yaml.sh ├── help_command.sh ├── help_option_short.sh ├── help_option_long.sh ├── format │ ├── fail_invalid_path.sh │ ├── pass_check_single_json.sh │ ├── pass_check_yaml.sh │ ├── fail_check_single_invalid.sh │ ├── pass_check_single.sh │ ├── pass_bignum_real.sh │ ├── pass_check_single_keep_ordering.sh │ ├── pass_check_single_indentation.sh │ ├── pass_yaml.sh │ ├── pass_check_single_verbose.sh │ ├── pass_single_keep_ordering.sh │ ├── fail_check_single_json.sh │ ├── pass_default_dialect.sh │ ├── fail_check_single.sh │ ├── fail_check_single_json_indentation.sh │ ├── fail_check_single_indentation.sh │ ├── pass_single.sh │ └── pass_single_indentation.sh ├── decode │ ├── pass_schema_less.sh │ ├── pass_schema_less_jsonl.sh │ └── fail_no_document.sh ├── validate │ ├── pass_draft4.sh │ ├── pass_draft6.sh │ ├── pass_draft7.sh │ ├── pass_2019_09.sh │ ├── pass_2020_12.sh │ ├── pass_2020_12_fast.sh │ ├── pass_2020_12_default_dialect.sh │ ├── pass_process_substitution.sh │ ├── pass_2020_12_with_template.sh │ ├── pass_jsonl_bigint.sh │ ├── pass_2020_12_fast_with_template.sh │ ├── pass_jsonl_empty.sh │ ├── pass_json_ref_yaml.sh │ ├── pass_no_identifier_ref.sh │ ├── pass_jsonl.sh │ ├── pass_yaml_multi.sh │ ├── pass_jsonl_empty_verbose.sh │ ├── pass_json_fast.sh │ ├── pass_benchmark_loop_jsonl.sh │ ├── pass_benchmark.sh │ ├── pass_benchmark_loop.sh │ ├── pass_no_identifier_half_ref.sh │ ├── pass_jsonl_json.sh │ ├── pass_yaml_multi_json.sh │ ├── fail_benchmark_zero.sh │ ├── fail_2020_12_fast.sh │ ├── fail_invalid_config.sh │ ├── pass_verbose.sh │ ├── pass_directory_ignore.sh │ ├── pass_with_invalid_template.sh │ ├── fail_benchmark.sh │ ├── pass_many.sh │ ├── pass_directory.sh │ ├── pass_directory_fast.sh │ ├── pass_jsonl_json_verbose.sh │ ├── pass_directory_and_file.sh │ ├── pass_directory_extension.sh │ ├── pass_directory_ignore_jsonl.sh │ ├── fail_jsonl_all.sh │ └── fail_no_schema.sh ├── compile │ ├── pass_patternproperties.sh │ ├── pass_minify.sh │ ├── fail_no_schema.sh │ ├── pass_fast.sh │ └── pass_yaml.sh ├── version_command.sh ├── version_option_short.sh ├── version_option_long.sh ├── ci │ ├── fail_bundle_http_non_200.sh │ ├── pass_validate_http.sh │ ├── fail_bundle_http_non_200_verbose.sh │ ├── fail_validate_http_non_200.sh │ ├── fail_validate_http_non_200_verbose.sh │ ├── pass_validate_json_ref_yaml_http.sh │ ├── pass_validate_http_verbose.sh │ ├── precommit_lint.sh │ └── fail_bundle_http_non_schema.sh ├── test │ ├── pass_empty.sh │ ├── fail_no_tests.sh │ ├── fail_tests_non_array.sh │ ├── pass_file_target_without_resolve.sh │ ├── pass_file_target_with_resolve.sh │ ├── fail_test_case_non_object.sh │ ├── fail_schema_non_string.sh │ ├── fail_test_case_non_string_data_path.sh │ ├── fail_additional_properties.sh │ ├── fail_test_case_no_valid.sh │ ├── pass_single_resolve.sh │ ├── fail_not_object.sh │ ├── fail_test_case_data_and_data_path.sh │ └── fail_test_case_non_boolean_valid.sh ├── encode │ ├── pass_schema_less.sh │ ├── pass_schema_less_jsonl.sh │ └── fail_no_document.sh ├── unknown_option.sh ├── flag_with_value.sh ├── bundle │ ├── fail_no_schema.sh │ └── pass_without_remote.sh ├── inspect │ └── fail_no_schema.sh ├── option_without_value.sh └── unknown_command.sh ├── .pre-commit-hooks.yaml ├── bin └── jsonschema ├── .gitignore ├── src ├── configure.h.in ├── logger.h └── command.h ├── npm ├── cli.js └── cjs.test.js ├── .editorconfig ├── DEPENDENCIES ├── eslint.config.mjs ├── docs └── version.markdown ├── vendorpull.mask ├── action.yml ├── snapcraft.yaml └── Dockerfile /VERSION: -------------------------------------------------------------------------------- 1 | 12.10.1 2 | -------------------------------------------------------------------------------- /.ackrc: -------------------------------------------------------------------------------- 1 | --ignore-dir=build 2 | --ignore-dir=vendor 3 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/libpsl/version.txt: -------------------------------------------------------------------------------- 1 | 0.21.5 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * -text 2 | /vendor/** linguist-generated=true 3 | -------------------------------------------------------------------------------- /Brewfile: -------------------------------------------------------------------------------- 1 | brew "cmake" 2 | brew "shellcheck" 3 | brew "python-setuptools" 4 | brew "twine" 5 | -------------------------------------------------------------------------------- /assets/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourcemeta/jsonschema/HEAD/assets/banner.png -------------------------------------------------------------------------------- /assets/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourcemeta/jsonschema/HEAD/assets/example.png -------------------------------------------------------------------------------- /vendor/core/cmake/common/targets/clang-format.json: -------------------------------------------------------------------------------- 1 | { 2 | "BasedOnStyle": "LLVM", 3 | "IndentCaseLabels": true 4 | } 5 | -------------------------------------------------------------------------------- /vendor/core/vendor/googlebenchmark/cmake/split_list.cmake: -------------------------------------------------------------------------------- 1 | macro(split_list listname) 2 | string(REPLACE ";" " " ${listname} "${${listname}}") 3 | endmacro() 4 | -------------------------------------------------------------------------------- /vendor/core/vendor/googlebenchmark/cmake/thread_safety_attributes.cpp: -------------------------------------------------------------------------------- 1 | #define HAVE_THREAD_SAFETY_ATTRIBUTES 2 | #include "../src/mutex.h" 3 | 4 | int main() {} 5 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/cpr/payload.cpp: -------------------------------------------------------------------------------- 1 | // NOLINTNEXTLINE(misc-include-cleaner) Ignored since it's for the future 2 | #include "cpr/payload.h" 3 | 4 | namespace cpr {} // namespace cpr 5 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/cpr/parameters.cpp: -------------------------------------------------------------------------------- 1 | // NOLINTNEXTLINE(misc-include-cleaner) Ignored since it's for the future 2 | #include "cpr/parameters.h" 3 | 4 | namespace cpr {} // namespace cpr 5 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | * 2 | !LICENSE 3 | !README.markdown 4 | !package.json 5 | !package-lock.json 6 | !*.js 7 | !*.mjs 8 | !npm/* 9 | npm/*.test.js 10 | npm/*.test.mjs 11 | !build/github-releases/* 12 | -------------------------------------------------------------------------------- /cmake/FindBlaze.cmake: -------------------------------------------------------------------------------- 1 | if(NOT Blaze_FOUND) 2 | set(BLAZE_INSTALL OFF CACHE BOOL "disable installation") 3 | add_subdirectory("${PROJECT_SOURCE_DIR}/vendor/blaze") 4 | set(Blaze_FOUND ON) 5 | endif() 6 | -------------------------------------------------------------------------------- /cmake/FindHydra.cmake: -------------------------------------------------------------------------------- 1 | if(NOT Hydra_FOUND) 2 | set(SOURCEMETA_HYDRA_INSTALL OFF CACHE BOOL "disable installation") 3 | add_subdirectory("${PROJECT_SOURCE_DIR}/vendor/hydra") 4 | set(Hydra_FOUND ON) 5 | endif() 6 | -------------------------------------------------------------------------------- /vendor/core/vendor/googlebenchmark/cmake/steady_clock.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | typedef std::chrono::steady_clock Clock; 5 | Clock::time_point tp = Clock::now(); 6 | ((void)tp); 7 | } 8 | -------------------------------------------------------------------------------- /cmake/FindJSONBinPack.cmake: -------------------------------------------------------------------------------- 1 | if(NOT JSONBinPack_FOUND) 2 | set(JSONBINPACK_INSTALL OFF CACHE BOOL "disable installation") 3 | add_subdirectory("${PROJECT_SOURCE_DIR}/vendor/jsonbinpack") 4 | set(JSONBinPack_FOUND ON) 5 | endif() 6 | -------------------------------------------------------------------------------- /test/docker/help.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | docker run --interactive --volume "$TMP:/workspace" jsonschema 11 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/cpr/async.cpp: -------------------------------------------------------------------------------- 1 | #include "cpr/async.h" 2 | 3 | namespace cpr { 4 | 5 | // NOLINTNEXTLINE (cppcoreguidelines-avoid-non-const-global-variables) 6 | CPR_SINGLETON_IMPL(GlobalThreadPool) 7 | 8 | } // namespace cpr 9 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/cpr/unix_socket.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "cpr/unix_socket.h" 3 | 4 | namespace cpr { 5 | const char* UnixSocket::GetUnixSocketString() const noexcept { 6 | return unix_socket_.data(); 7 | } 8 | } // namespace cpr 9 | -------------------------------------------------------------------------------- /vendor/core/src/lang/io/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME io SOURCES io.cc) 2 | 3 | if(SOURCEMETA_CORE_INSTALL) 4 | sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME io) 5 | endif() 6 | -------------------------------------------------------------------------------- /vendor/core/src/core/md5/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME md5 SOURCES md5.cc) 2 | 3 | if(SOURCEMETA_CORE_INSTALL) 4 | sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME md5) 5 | endif() 6 | -------------------------------------------------------------------------------- /vendor/core/src/core/time/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME time SOURCES gmt.cc) 2 | 3 | if(SOURCEMETA_CORE_INSTALL) 4 | sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME time) 5 | endif() 6 | -------------------------------------------------------------------------------- /vendor/core/src/core/uuid/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME uuid SOURCES uuid.cc) 2 | 3 | if(SOURCEMETA_CORE_INSTALL) 4 | sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME uuid) 5 | endif() 6 | -------------------------------------------------------------------------------- /.pre-commit-hooks.yaml: -------------------------------------------------------------------------------- 1 | - id: sourcemeta-jsonschema-lint 2 | name: sourcemeta-jsonschema-lint 3 | description: Lint schema files 4 | entry: jsonschema lint 5 | language: system 6 | types_or: [ json, yaml ] 7 | minimum_pre_commit_version: 2.9.0 8 | -------------------------------------------------------------------------------- /bin/jsonschema: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | CWD="$PWD" 7 | CDPATH='' cd -- "$(dirname -- "$0")" 8 | SCRIPT_DIRECTORY="$(pwd -P)" 9 | cd "$CWD" 10 | exec "$(dirname "$SCRIPT_DIRECTORY")/build/dist/bin/jsonschema" "$@" 11 | -------------------------------------------------------------------------------- /vendor/core/cmake/common/shim.cmake: -------------------------------------------------------------------------------- 1 | # The PROJECT_IS_TOP_LEVEL handy variable is only 2 | # available on CMake >=3.21. 3 | if(NOT DEFINED PROJECT_IS_TOP_LEVEL AND "${CMAKE_PROJECT_NAME}" STREQUAL "${PROJECT_NAME}") 4 | set(PROJECT_IS_TOP_LEVEL YES) 5 | endif() 6 | -------------------------------------------------------------------------------- /vendor/core/cmake/FindGoogleBenchmark.cmake: -------------------------------------------------------------------------------- 1 | if(NOT Benchmark_FOUND) 2 | set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "enable testing of the benchmark library") 3 | add_subdirectory("${PROJECT_SOURCE_DIR}/vendor/googlebenchmark") 4 | set(Benchmark_FOUND ON) 5 | endif() 6 | -------------------------------------------------------------------------------- /vendor/core/vendor/googlebenchmark/cmake/benchmark_main.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | 3 | Name: @PROJECT_NAME@ 4 | Description: Google microbenchmark framework (with main() function) 5 | Version: @VERSION@ 6 | Requires: benchmark 7 | Libs: -L${libdir} -lbenchmark_main 8 | -------------------------------------------------------------------------------- /vendor/core/cmake/FindGoogleTest.cmake: -------------------------------------------------------------------------------- 1 | if(NOT GoogleTest_FOUND) 2 | set(BUILD_GMOCK ON CACHE BOOL "enable googlemock") 3 | set(INSTALL_GTEST OFF CACHE BOOL "disable installation") 4 | add_subdirectory("${PROJECT_SOURCE_DIR}/vendor/googletest") 5 | set(GoogleTest_FOUND ON) 6 | endif() 7 | -------------------------------------------------------------------------------- /vendor/core/src/extension/options/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME options 2 | PRIVATE_HEADERS error.h SOURCES options.cc) 3 | 4 | if(SOURCEMETA_CORE_INSTALL) 5 | sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME options) 6 | endif() 7 | -------------------------------------------------------------------------------- /vendor/core/src/lang/process/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME process 2 | PRIVATE_HEADERS error.h 3 | SOURCES spawn.cc) 4 | 5 | if(SOURCEMETA_CORE_INSTALL) 6 | sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME process) 7 | endif() 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | CMakeLists.txt.user 2 | CMakeCache.txt 3 | CMakeFiles 4 | CMakeScripts 5 | Testing 6 | cmake_install.cmake 7 | install_manifest.txt 8 | compile_commands.json 9 | CTestTestfile.cmake 10 | _deps 11 | /build 12 | Brewfile.lock.json 13 | .DS_Store 14 | *.snap 15 | /node_modules 16 | -------------------------------------------------------------------------------- /vendor/blaze/src/output/include/sourcemeta/blaze/output.h: -------------------------------------------------------------------------------- 1 | #ifndef SOURCEMETA_BLAZE_OUTPUT_H_ 2 | #define SOURCEMETA_BLAZE_OUTPUT_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /vendor/core/src/core/punycode/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME punycode 2 | PRIVATE_HEADERS error.h 3 | SOURCES punycode.cc utf8.h) 4 | 5 | if(SOURCEMETA_CORE_INSTALL) 6 | sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME punycode) 7 | endif() 8 | -------------------------------------------------------------------------------- /src/configure.h.in: -------------------------------------------------------------------------------- 1 | #ifndef SOURCEMETA_JSONSCHEMA_CLI_CONFIGURE_H_ 2 | #define SOURCEMETA_JSONSCHEMA_CLI_CONFIGURE_H_ 3 | 4 | #include // std::string_view 5 | 6 | namespace sourcemeta::jsonschema { 7 | constexpr std::string_view PROJECT_VERSION{"@PROJECT_VERSION@"}; 8 | } 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /vendor/core/vendor/googlebenchmark/cmake/Config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include (CMakeFindDependencyMacro) 4 | 5 | find_dependency (Threads) 6 | 7 | if (@BENCHMARK_ENABLE_LIBPFM@) 8 | find_dependency (PFM) 9 | endif() 10 | 11 | include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") 12 | -------------------------------------------------------------------------------- /npm/cli.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const { spawn } = require('./main.js'); 4 | 5 | spawn(process.argv.slice(2), { stdio: 'inherit' }) 6 | .then((result) => { 7 | process.exit(result.code); 8 | }) 9 | .catch((error) => { 10 | console.error(error.message); 11 | process.exit(1); 12 | }); 13 | -------------------------------------------------------------------------------- /vendor/core/vendor/googlebenchmark/src/check.cc: -------------------------------------------------------------------------------- 1 | #include "check.h" 2 | 3 | namespace benchmark { 4 | namespace internal { 5 | 6 | static AbortHandlerT* handler = &std::abort; 7 | 8 | BENCHMARK_EXPORT AbortHandlerT*& GetAbortHandler() { return handler; } 9 | 10 | } // namespace internal 11 | } // namespace benchmark 12 | -------------------------------------------------------------------------------- /vendor/jsonbinpack/src/numeric/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | sourcemeta_library(NAMESPACE sourcemeta PROJECT jsonbinpack NAME numeric 2 | FOLDER "JSON BinPack/Numeric" 3 | PRIVATE_HEADERS integral.h real.h zigzag.h) 4 | 5 | if(JSONBINPACK_INSTALL) 6 | sourcemeta_library_install(NAMESPACE sourcemeta PROJECT jsonbinpack NAME numeric) 7 | endif() 8 | -------------------------------------------------------------------------------- /vendor/core/vendor/pcre2/src/libpcre2-posix.sym: -------------------------------------------------------------------------------- 1 | # First version of PCRE2 in which symbols were assigned versions. 2 | PCRE2_10.47 { 3 | global: 4 | pcre2_regcomp; 5 | pcre2_regerror; 6 | pcre2_regexec; 7 | pcre2_regfree; 8 | local: 9 | _fini; 10 | _init; 11 | }; 12 | 13 | # PCRE2_10.48 {} PCRE2_10.47; 14 | -------------------------------------------------------------------------------- /vendor/core/src/core/regex/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME regex 2 | SOURCES regex.cc preprocess.h) 3 | 4 | if(SOURCEMETA_CORE_INSTALL) 5 | sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME regex) 6 | endif() 7 | 8 | target_link_libraries(sourcemeta_core_regex PRIVATE PCRE2::pcre2) 9 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [Makefile] 13 | indent_style = tab 14 | 15 | [*.mk] 16 | indent_style = tab 17 | 18 | [*.uk] 19 | indent_style = tab 20 | -------------------------------------------------------------------------------- /vendor/core/src/lang/parallel/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME parallel 2 | PRIVATE_HEADERS for_each.h) 3 | 4 | if(SOURCEMETA_CORE_INSTALL) 5 | sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME parallel) 6 | endif() 7 | 8 | target_link_libraries(sourcemeta_core_parallel INTERFACE Threads::Threads) 9 | -------------------------------------------------------------------------------- /vendor/core/vendor/googlebenchmark/cmake/std_regex.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() { 4 | const std::string str = "test0159"; 5 | std::regex re; 6 | re = std::regex("^[a-z]+[0-9]+$", 7 | std::regex_constants::extended | std::regex_constants::nosubs); 8 | return std::regex_search(str, re) ? 0 : -1; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/include/cpr/reserve_size.h: -------------------------------------------------------------------------------- 1 | #ifndef CPR_RESERVE_SIZE_H 2 | #define CPR_RESERVE_SIZE_H 3 | 4 | #include 5 | 6 | namespace cpr { 7 | 8 | class ReserveSize { 9 | public: 10 | ReserveSize(const size_t _size) : size(_size) {} 11 | 12 | size_t size = 0; 13 | }; 14 | 15 | } // namespace cpr 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /vendor/core/vendor/googlebenchmark/cmake/llvm-toolchain.cmake: -------------------------------------------------------------------------------- 1 | find_package(LLVMAr REQUIRED) 2 | set(CMAKE_AR "${LLVMAR_EXECUTABLE}" CACHE FILEPATH "" FORCE) 3 | 4 | find_package(LLVMNm REQUIRED) 5 | set(CMAKE_NM "${LLVMNM_EXECUTABLE}" CACHE FILEPATH "" FORCE) 6 | 7 | find_package(LLVMRanLib REQUIRED) 8 | set(CMAKE_RANLIB "${LLVMRANLIB_EXECUTABLE}" CACHE FILEPATH "" FORCE) 9 | -------------------------------------------------------------------------------- /vendor/core/vendor/googlebenchmark/cmake/gnu_posix_regex.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() { 4 | std::string str = "test0159"; 5 | regex_t re; 6 | int ec = regcomp(&re, "^[a-z]+[0-9]+$", REG_EXTENDED | REG_NOSUB); 7 | if (ec != 0) { 8 | return ec; 9 | } 10 | return regexec(&re, str.c_str(), 0, nullptr, 0) ? -1 : 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/include/cpr/curlmultiholder.h: -------------------------------------------------------------------------------- 1 | #ifndef CPR_CURLMULTIHOLDER_H 2 | #define CPR_CURLMULTIHOLDER_H 3 | 4 | #include 5 | 6 | namespace cpr { 7 | 8 | class CurlMultiHolder { 9 | public: 10 | CurlMultiHolder(); 11 | ~CurlMultiHolder(); 12 | 13 | CURLM* handle{nullptr}; 14 | }; 15 | 16 | } // namespace cpr 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /test/metaschema/pass_draft7_without_fragment.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-07/schema", 13 | "type": "string" 14 | } 15 | EOF 16 | 17 | "$1" metaschema "$TMP/schema.json" 18 | -------------------------------------------------------------------------------- /vendor/core/src/extension/editorschema/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME editorschema 2 | SOURCES editorschema.cc) 3 | 4 | if(SOURCEMETA_CORE_INSTALL) 5 | sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME editorschema) 6 | endif() 7 | 8 | target_link_libraries(sourcemeta_core_editorschema PUBLIC sourcemeta::core::jsonschema) 9 | -------------------------------------------------------------------------------- /vendor/core/cmake/common/clang-tidy.json: -------------------------------------------------------------------------------- 1 | { 2 | "Checks": "-*, bugprone-*, -bugprone-easily-swappable-parameters,-bugprone-unchecked-optional-access, concurrency-*,cppcoreguidelines-missing-std-forward, 3 | cppcoreguidelines-avoid-const-or-ref-data-members, modernize-*, performance-*, portability-*", 4 | "WarningsAsErrors": "*", 5 | "FormatStyle": "none", 6 | "UseColor": true 7 | } 8 | -------------------------------------------------------------------------------- /vendor/core/src/lang/numeric/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME numeric 2 | PRIVATE_HEADERS error.h decimal.h parse.h SOURCES decimal.cc parse.cc) 3 | 4 | if(SOURCEMETA_CORE_INSTALL) 5 | sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME numeric) 6 | endif() 7 | 8 | target_link_libraries(sourcemeta_core_numeric PRIVATE mpdecimal) 9 | -------------------------------------------------------------------------------- /vendor/core/src/lang/numeric/include/sourcemeta/core/numeric.h: -------------------------------------------------------------------------------- 1 | #ifndef SOURCEMETA_CORE_NUMERIC_H_ 2 | #define SOURCEMETA_CORE_NUMERIC_H_ 3 | 4 | // NOLINTBEGIN(misc-include-cleaner) 5 | #include 6 | #include 7 | #include 8 | // NOLINTEND(misc-include-cleaner) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/cpr/curlmultiholder.cpp: -------------------------------------------------------------------------------- 1 | #include "cpr/curlmultiholder.h" 2 | #include 3 | #include 4 | 5 | namespace cpr { 6 | 7 | CurlMultiHolder::CurlMultiHolder() : handle{curl_multi_init()} { 8 | assert(handle); 9 | } 10 | 11 | CurlMultiHolder::~CurlMultiHolder() { 12 | curl_multi_cleanup(handle); 13 | } 14 | 15 | } // namespace cpr 16 | -------------------------------------------------------------------------------- /vendor/core/src/extension/build/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME build 2 | PRIVATE_HEADERS types.h adapter_filesystem.h SOURCES adapter_filesystem.cc) 3 | 4 | if(SOURCEMETA_CORE_INSTALL) 5 | sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME build) 6 | endif() 7 | 8 | target_link_libraries(sourcemeta_core_build PRIVATE sourcemeta::core::io) 9 | -------------------------------------------------------------------------------- /vendor/core/src/core/jsonl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME jsonl 2 | PRIVATE_HEADERS iterator.h 3 | SOURCES jsonl.cc iterator.cc grammar.h) 4 | 5 | if(SOURCEMETA_CORE_INSTALL) 6 | sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME jsonl) 7 | endif() 8 | 9 | target_link_libraries(sourcemeta_core_jsonl PUBLIC 10 | sourcemeta::core::json) 11 | -------------------------------------------------------------------------------- /vendor/core/vendor/googletest/googletest/cmake/gtest.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: gtest 5 | Description: GoogleTest (without main() function) 6 | Version: @PROJECT_VERSION@ 7 | URL: https://github.com/google/googletest 8 | Libs: -L${libdir} -lgtest @CMAKE_THREAD_LIBS_INIT@ 9 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ 10 | -------------------------------------------------------------------------------- /vendor/core/src/core/uri/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME uri 2 | PRIVATE_HEADERS error.h 3 | SOURCES uri.cc parse.cc accessors.cc setters.cc recompose.cc canonicalize.cc 4 | resolution.cc filesystem.cc escaping.h normalize.h grammar.h) 5 | 6 | if(SOURCEMETA_CORE_INSTALL) 7 | sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME uri) 8 | endif() 9 | -------------------------------------------------------------------------------- /vendor/core/vendor/googlebenchmark/cmake/posix_regex.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() { 4 | std::string str = "test0159"; 5 | regex_t re; 6 | int ec = regcomp(&re, "^[a-z]+[0-9]+$", REG_EXTENDED | REG_NOSUB); 7 | if (ec != 0) { 8 | return ec; 9 | } 10 | int ret = regexec(&re, str.c_str(), 0, nullptr, 0) ? -1 : 0; 11 | regfree(&re); 12 | return ret; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/cpr/multipart.cpp: -------------------------------------------------------------------------------- 1 | #include "cpr/multipart.h" 2 | #include 3 | #include 4 | 5 | namespace cpr { 6 | Multipart::Multipart(const std::initializer_list& p_parts) : parts{p_parts} {} 7 | Multipart::Multipart(const std::vector& p_parts) : parts{p_parts} {} 8 | Multipart::Multipart(const std::vector&& p_parts) : parts{p_parts} {} 9 | } // namespace cpr 10 | -------------------------------------------------------------------------------- /vendor/core/vendor/googletest/googlemock/include/gmock/internal/custom/gmock-generated-actions.h: -------------------------------------------------------------------------------- 1 | // IWYU pragma: private, include "gmock/gmock.h" 2 | // IWYU pragma: friend gmock/.* 3 | 4 | #ifndef GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ 5 | #define GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ 6 | 7 | #endif // GOOGLEMOCK_INCLUDE_GMOCK_INTERNAL_CUSTOM_GMOCK_GENERATED_ACTIONS_H_ 8 | -------------------------------------------------------------------------------- /vendor/core/vendor/googlebenchmark/cmake/benchmark.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 4 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 5 | 6 | Name: @PROJECT_NAME@ 7 | Description: Google microbenchmark framework 8 | Version: @VERSION@ 9 | 10 | Libs: -L${libdir} -lbenchmark 11 | Libs.private: -lpthread @BENCHMARK_PRIVATE_LINK_LIBRARIES@ 12 | Cflags: -I${includedir} 13 | -------------------------------------------------------------------------------- /vendor/core/vendor/googletest/googlemock/cmake/gmock.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: gmock 5 | Description: GoogleMock (without main() function) 6 | Version: @PROJECT_VERSION@ 7 | URL: https://github.com/google/googletest 8 | Requires: gtest = @PROJECT_VERSION@ 9 | Libs: -L${libdir} -lgmock @CMAKE_THREAD_LIBS_INIT@ 10 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ 11 | -------------------------------------------------------------------------------- /DEPENDENCIES: -------------------------------------------------------------------------------- 1 | vendorpull https://github.com/sourcemeta/vendorpull 1dcbac42809cf87cb5b045106b863e17ad84ba02 2 | core https://github.com/sourcemeta/core 0836d83873a0328b5a1a25848f29bdb8253734c0 3 | jsonbinpack https://github.com/sourcemeta/jsonbinpack 071c0c08eeabaf303202743dd5961b8ce2d49d20 4 | blaze https://github.com/sourcemeta/blaze df4844c065a6c82382d5f7717773852f4181dc9f 5 | hydra https://github.com/sourcemeta/hydra af9f2c54709d620872ead0c3f8f683c15a0fa702 6 | -------------------------------------------------------------------------------- /vendor/core/vendor/googletest/googlemock/cmake/gmock_main.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: gmock_main 5 | Description: GoogleMock (with main() function) 6 | Version: @PROJECT_VERSION@ 7 | URL: https://github.com/google/googletest 8 | Requires: gmock = @PROJECT_VERSION@ 9 | Libs: -L${libdir} -lgmock_main @CMAKE_THREAD_LIBS_INIT@ 10 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ 11 | -------------------------------------------------------------------------------- /vendor/core/vendor/googletest/googletest/cmake/gtest_main.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: gtest_main 5 | Description: GoogleTest (with main() function) 6 | Version: @PROJECT_VERSION@ 7 | URL: https://github.com/google/googletest 8 | Requires: gtest = @PROJECT_VERSION@ 9 | Libs: -L${libdir} -lgtest_main @CMAKE_THREAD_LIBS_INIT@ 10 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ 11 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/include/cpr/limit_rate.h: -------------------------------------------------------------------------------- 1 | #ifndef CPR_SPEED_LIMIT_H 2 | #define CPR_SPEED_LIMIT_H 3 | 4 | #include 5 | 6 | namespace cpr { 7 | 8 | class LimitRate { 9 | public: 10 | LimitRate(const std::int64_t p_downrate, const std::int64_t p_uprate) : downrate(p_downrate), uprate(p_uprate) {} 11 | 12 | std::int64_t downrate = 0; 13 | std::int64_t uprate = 0; 14 | }; 15 | 16 | } // namespace cpr 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/include/cpr/verbose.h: -------------------------------------------------------------------------------- 1 | #ifndef CPR_VERBOSE_H_ 2 | #define CPR_VERBOSE_H_ 3 | 4 | namespace cpr { 5 | 6 | class Verbose { 7 | public: 8 | Verbose() = default; 9 | // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) 10 | Verbose(const bool p_verbose) : verbose{p_verbose} {} 11 | 12 | bool verbose = true; 13 | }; 14 | 15 | } // namespace cpr 16 | 17 | 18 | #endif /* CPR_VERBOSE_H_ */ 19 | -------------------------------------------------------------------------------- /test/lint/pass_lint_default_nested_with_id.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "$id": "https://example.com", 14 | "items": { 15 | "default": "Sourcemeta" 16 | } 17 | } 18 | EOF 19 | 20 | "$1" lint --verbose "$TMP/schema.json" 21 | -------------------------------------------------------------------------------- /test/lint/pass_lint_examples_nested_with_id.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "$id": "https://example.com", 14 | "items": { 15 | "examples": [ 1, 2, 3 ] 16 | } 17 | } 18 | EOF 19 | 20 | "$1" lint --verbose "$TMP/schema.json" 21 | -------------------------------------------------------------------------------- /eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "eslint/config"; 2 | import globals from "globals"; 3 | import js from "@eslint/js"; 4 | 5 | export default defineConfig([ 6 | { files: ["**/*.{js,mjs,cjs}"] }, 7 | { files: ["**/*.js"], languageOptions: { sourceType: "commonjs" } }, 8 | { files: ["**/*.{js,mjs,cjs}"], languageOptions: { globals: globals.node } }, 9 | { files: ["**/*.{js,mjs,cjs}"], plugins: { js }, extends: ["js/recommended"] }, 10 | ]); 11 | -------------------------------------------------------------------------------- /test/metaschema/pass_2020_12.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "type": "string", 14 | "$defs": { 15 | "foo": { 16 | "type": [ "string", "null" ] 17 | } 18 | } 19 | } 20 | EOF 21 | 22 | "$1" metaschema "$TMP/schema.json" 23 | -------------------------------------------------------------------------------- /vendor/hydra/DEPENDENCIES: -------------------------------------------------------------------------------- 1 | vendorpull https://github.com/sourcemeta/vendorpull 1dcbac42809cf87cb5b045106b863e17ad84ba02 2 | mbedtls https://github.com/Mbed-TLS/mbedtls v3.6.5 3 | zlib https://github.com/madler/zlib v1.3.1 4 | curl https://github.com/curl/curl curl-8_17_0 5 | nghttp2 https://github.com/nghttp2/nghttp2 v1.67.1 6 | cpr https://github.com/libcpr/cpr 1.13.0 7 | c-ares https://github.com/c-ares/c-ares v1.34.5 8 | libpsl https://github.com/rockdaboot/libpsl 0.21.5 9 | -------------------------------------------------------------------------------- /vendor/core/vendor/googlebenchmark/cmake/Modules/FindLLVMRanLib.cmake: -------------------------------------------------------------------------------- 1 | include(FeatureSummary) 2 | 3 | find_program(LLVMRANLIB_EXECUTABLE 4 | NAMES llvm-ranlib 5 | DOC "The llvm-ranlib executable" 6 | ) 7 | 8 | include(FindPackageHandleStandardArgs) 9 | find_package_handle_standard_args(LLVMRanLib 10 | DEFAULT_MSG 11 | LLVMRANLIB_EXECUTABLE) 12 | 13 | SET_PACKAGE_PROPERTIES(LLVMRanLib PROPERTIES 14 | DESCRIPTION "generate index for LLVM archive" 15 | ) 16 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/cpr/cprtypes.cpp: -------------------------------------------------------------------------------- 1 | #include "cpr/cprtypes.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace cpr { 8 | bool CaseInsensitiveCompare::operator()(const std::string& a, const std::string& b) const noexcept { 9 | return std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end(), [](unsigned char ac, unsigned char bc) { return std::tolower(ac) < std::tolower(bc); }); 10 | } 11 | } // namespace cpr 12 | -------------------------------------------------------------------------------- /test/help_command.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | "$1" help 1> "$TMP/stdout" 2> "$TMP/stderr" 11 | 12 | if ! [ -s "$TMP/stdout" ] 13 | then 14 | echo "FAIL: Did not produce output to stdout" 1>&2 15 | exit 1 16 | fi 17 | 18 | if [ -s "$TMP/stderr" ] 19 | then 20 | echo "FAIL: Produced output to stderr" 1>&2 21 | exit 1 22 | fi 23 | 24 | echo "PASS" 1>&2 25 | -------------------------------------------------------------------------------- /test/metaschema/pass_2020_12_with_fragment.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema#", 13 | "type": "string", 14 | "$defs": { 15 | "foo": { 16 | "type": [ "string", "null" ] 17 | } 18 | } 19 | } 20 | EOF 21 | 22 | "$1" metaschema "$TMP/schema.json" 23 | -------------------------------------------------------------------------------- /vendor/core/vendor/googletest/googletest/cmake/Config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | include(CMakeFindDependencyMacro) 3 | if (@GTEST_HAS_PTHREAD@) 4 | set(THREADS_PREFER_PTHREAD_FLAG @THREADS_PREFER_PTHREAD_FLAG@) 5 | find_dependency(Threads) 6 | endif() 7 | if (@GTEST_HAS_ABSL@) 8 | find_dependency(absl) 9 | find_dependency(re2) 10 | endif() 11 | 12 | include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") 13 | check_required_components("@project_name@") 14 | -------------------------------------------------------------------------------- /test/help_option_short.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | "$1" -h 1> "$TMP/stdout" 2> "$TMP/stderr" 11 | 12 | if ! [ -s "$TMP/stdout" ] 13 | then 14 | echo "FAIL: Did not produce output to stdout" 1>&2 15 | exit 1 16 | fi 17 | 18 | if [ -s "$TMP/stderr" ] 19 | then 20 | echo "FAIL: Produced output to stderr" 1>&2 21 | exit 1 22 | fi 23 | 24 | echo "PASS" 1>&2 25 | -------------------------------------------------------------------------------- /test/lint/pass_lint_list_only_one.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | "$1" lint --list --only definitions_to_defs > "$TMP/output.txt" 11 | 12 | cat << 'EOF' > "$TMP/expected.txt" 13 | definitions_to_defs 14 | `definitions` was superseded by `$defs` in 2019-09 and later versions 15 | 16 | Number of rules: 1 17 | EOF 18 | 19 | diff "$TMP/output.txt" "$TMP/expected.txt" 20 | -------------------------------------------------------------------------------- /test/help_option_long.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | "$1" --help 1> "$TMP/stdout" 2> "$TMP/stderr" 11 | 12 | if ! [ -s "$TMP/stdout" ] 13 | then 14 | echo "FAIL: Did not produce output to stdout" 1>&2 15 | exit 1 16 | fi 17 | 18 | if [ -s "$TMP/stderr" ] 19 | then 20 | echo "FAIL: Produced output to stderr" 1>&2 21 | exit 1 22 | fi 23 | 24 | echo "PASS" 1>&2 25 | -------------------------------------------------------------------------------- /test/metaschema/pass_2020_12_default_dialect.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "type": "string", 13 | "$defs": { 14 | "foo": { 15 | "type": [ "string", "null" ] 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | "$1" metaschema --default-dialect "https://json-schema.org/draft/2020-12/schema" \ 22 | "$TMP/schema.json" 23 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/include/cpr/parameters.h: -------------------------------------------------------------------------------- 1 | #ifndef CPR_PARAMETERS_H 2 | #define CPR_PARAMETERS_H 3 | 4 | #include 5 | 6 | #include "cpr/curl_container.h" 7 | 8 | namespace cpr { 9 | 10 | class Parameters : public CurlContainer { 11 | public: 12 | Parameters() = default; 13 | Parameters(const std::initializer_list& parameters) : CurlContainer(parameters) {} 14 | }; 15 | 16 | } // namespace cpr 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /test/metaschema/pass_single.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": "string" 14 | } 15 | EOF 16 | 17 | "$1" metaschema "$TMP/schema.json" > "$TMP/output.txt" 2>&1 18 | 19 | cat << EOF > "$TMP/expected.txt" 20 | EOF 21 | 22 | diff "$TMP/output.txt" "$TMP/expected.txt" 23 | -------------------------------------------------------------------------------- /test/format/fail_invalid_path.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | "$1" fmt "$TMP/does_not_exist.json" >"$TMP/output.txt" 2>&1 && CODE="$?" || CODE="$?" 11 | test "$CODE" = "1" || exit 1 12 | 13 | cat << EOF > "$TMP/expected.txt" 14 | error: No such file or directory 15 | at file path $(realpath "$TMP")/does_not_exist.json 16 | EOF 17 | 18 | diff "$TMP/output.txt" "$TMP/expected.txt" 19 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/zlib/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start); 12 | -------------------------------------------------------------------------------- /vendor/core/src/core/yaml/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME yaml 2 | PRIVATE_HEADERS error.h 3 | SOURCES yaml.cc) 4 | 5 | if(SOURCEMETA_CORE_INSTALL) 6 | sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME yaml) 7 | endif() 8 | 9 | target_link_libraries(sourcemeta_core_yaml PRIVATE yaml) 10 | target_link_libraries(sourcemeta_core_yaml PUBLIC sourcemeta::core::json) 11 | target_link_libraries(sourcemeta_core_yaml PRIVATE sourcemeta::core::io) 12 | -------------------------------------------------------------------------------- /test/decode/pass_schema_less.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/document.json" 11 | { "version": 2.0 } 12 | EOF 13 | 14 | "$1" encode "$TMP/document.json" "$TMP/output.binpack" 15 | "$1" decode "$TMP/output.binpack" "$TMP/decode.json" 16 | 17 | cat << 'EOF' > "$TMP/expected.json" 18 | { 19 | "version": 2.0 20 | } 21 | EOF 22 | 23 | diff "$TMP/decode.json" "$TMP/expected.json" 24 | -------------------------------------------------------------------------------- /vendor/core/vendor/googlebenchmark/cmake/Modules/FindLLVMAr.cmake: -------------------------------------------------------------------------------- 1 | include(FeatureSummary) 2 | 3 | find_program(LLVMAR_EXECUTABLE 4 | NAMES llvm-ar 5 | DOC "The llvm-ar executable" 6 | ) 7 | 8 | include(FindPackageHandleStandardArgs) 9 | find_package_handle_standard_args(LLVMAr 10 | DEFAULT_MSG 11 | LLVMAR_EXECUTABLE) 12 | 13 | SET_PACKAGE_PROPERTIES(LLVMAr PROPERTIES 14 | URL https://llvm.org/docs/CommandGuide/llvm-ar.html 15 | DESCRIPTION "create, modify, and extract from archives" 16 | ) 17 | -------------------------------------------------------------------------------- /vendor/core/vendor/jsonschema-2019-09/meta/format.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$id": "https://json-schema.org/draft/2019-09/meta/format", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2019-09/vocab/format": true 6 | }, 7 | "$recursiveAnchor": true, 8 | 9 | "title": "Format vocabulary meta-schema", 10 | "type": ["object", "boolean"], 11 | "properties": { 12 | "format": { "type": "string" } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/lint/pass_bigint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": "integer", 14 | "maximum": 9223372036854776000 15 | } 16 | EOF 17 | 18 | "$1" lint "$TMP/schema.json" > "$TMP/result.txt" 2>&1 19 | 20 | cat << 'EOF' > "$TMP/output.txt" 21 | EOF 22 | 23 | diff "$TMP/result.txt" "$TMP/output.txt" 24 | -------------------------------------------------------------------------------- /vendor/core/vendor/googlebenchmark/cmake/Modules/FindLLVMNm.cmake: -------------------------------------------------------------------------------- 1 | include(FeatureSummary) 2 | 3 | find_program(LLVMNM_EXECUTABLE 4 | NAMES llvm-nm 5 | DOC "The llvm-nm executable" 6 | ) 7 | 8 | include(FindPackageHandleStandardArgs) 9 | find_package_handle_standard_args(LLVMNm 10 | DEFAULT_MSG 11 | LLVMNM_EXECUTABLE) 12 | 13 | SET_PACKAGE_PROPERTIES(LLVMNm PROPERTIES 14 | URL https://llvm.org/docs/CommandGuide/llvm-nm.html 15 | DESCRIPTION "list LLVM bitcode and object file’s symbol table" 16 | ) 17 | -------------------------------------------------------------------------------- /vendor/core/vendor/googlebenchmark/cmake/pthread_affinity.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int main() { 3 | cpu_set_t set; 4 | CPU_ZERO(&set); 5 | for (int i = 0; i < CPU_SETSIZE; ++i) { 6 | CPU_SET(i, &set); 7 | CPU_CLR(i, &set); 8 | } 9 | pthread_t self = pthread_self(); 10 | int ret; 11 | ret = pthread_getaffinity_np(self, sizeof(set), &set); 12 | if (ret != 0) return ret; 13 | ret = pthread_setaffinity_np(self, sizeof(set), &set); 14 | if (ret != 0) return ret; 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /test/validate/pass_draft4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "properties": { 14 | "foo": { 15 | "type": "string" 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | cat << 'EOF' > "$TMP/instance.json" 22 | { "foo": "bar" } 23 | EOF 24 | 25 | "$1" validate "$TMP/schema.json" "$TMP/instance.json" 26 | -------------------------------------------------------------------------------- /test/validate/pass_draft6.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-06/schema#", 13 | "properties": { 14 | "foo": { 15 | "type": "string" 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | cat << 'EOF' > "$TMP/instance.json" 22 | { "foo": "bar" } 23 | EOF 24 | 25 | "$1" validate "$TMP/schema.json" "$TMP/instance.json" 26 | -------------------------------------------------------------------------------- /test/validate/pass_draft7.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-07/schema#", 13 | "properties": { 14 | "foo": { 15 | "type": "string" 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | cat << 'EOF' > "$TMP/instance.json" 22 | { "foo": "bar" } 23 | EOF 24 | 25 | "$1" validate "$TMP/schema.json" "$TMP/instance.json" 26 | -------------------------------------------------------------------------------- /cmake/FindCore.cmake: -------------------------------------------------------------------------------- 1 | if(NOT Core_FOUND) 2 | set(SOURCEMETA_CORE_INSTALL OFF CACHE BOOL "disable installation") 3 | set(SOURCEMETA_CORE_CONTRIB_GOOGLETEST OFF CACHE BOOL "GoogleTest") 4 | set(SOURCEMETA_CORE_CONTRIB_GOOGLEBENCHMARK OFF CACHE BOOL "GoogleBenchmark") 5 | set(SOURCEMETA_CORE_EXTENSION_BUILD OFF CACHE BOOL "Build") 6 | set(SOURCEMETA_CORE_LANG_PARALLEL OFF CACHE BOOL "Parallel") 7 | add_subdirectory("${PROJECT_SOURCE_DIR}/vendor/core") 8 | include(Sourcemeta) 9 | set(Core_FOUND ON) 10 | endif() 11 | -------------------------------------------------------------------------------- /test/validate/pass_2019_09.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2019-09/schema", 13 | "properties": { 14 | "foo": { 15 | "type": "string" 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | cat << 'EOF' > "$TMP/instance.json" 22 | { "foo": "bar" } 23 | EOF 24 | 25 | "$1" validate "$TMP/schema.json" "$TMP/instance.json" 26 | -------------------------------------------------------------------------------- /test/validate/pass_2020_12.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "properties": { 14 | "foo": { 15 | "type": "string" 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | cat << 'EOF' > "$TMP/instance.json" 22 | { "foo": "bar" } 23 | EOF 24 | 25 | "$1" validate "$TMP/schema.json" "$TMP/instance.json" 26 | -------------------------------------------------------------------------------- /vendor/core/src/core/json/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME json 2 | PRIVATE_HEADERS array.h error.h object.h value.h hash.h auto.h 3 | SOURCES grammar.h parser.h stringify.h json.cc json_value.cc) 4 | 5 | if(SOURCEMETA_CORE_INSTALL) 6 | sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME json) 7 | endif() 8 | 9 | target_link_libraries(sourcemeta_core_json PRIVATE sourcemeta::core::io) 10 | target_link_libraries(sourcemeta_core_json PUBLIC sourcemeta::core::numeric) 11 | -------------------------------------------------------------------------------- /test/validate/pass_2020_12_fast.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "properties": { 14 | "foo": { 15 | "type": "string" 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | cat << 'EOF' > "$TMP/instance.json" 22 | { "foo": "bar" } 23 | EOF 24 | 25 | "$1" validate "$TMP/schema.json" "$TMP/instance.json" --fast 26 | -------------------------------------------------------------------------------- /vendor/jsonbinpack/src/runtime/loader_v1_number.h: -------------------------------------------------------------------------------- 1 | #ifndef SOURCEMETA_JSONBINPACK_RUNTIME_LOADER_V1_NUMBER_H_ 2 | #define SOURCEMETA_JSONBINPACK_RUNTIME_LOADER_V1_NUMBER_H_ 3 | 4 | #include 5 | 6 | #include 7 | 8 | namespace sourcemeta::jsonbinpack::v1 { 9 | 10 | auto DOUBLE_VARINT_TUPLE(const sourcemeta::core::JSON &) -> Encoding { 11 | return sourcemeta::jsonbinpack::DOUBLE_VARINT_TUPLE{}; 12 | } 13 | 14 | } // namespace sourcemeta::jsonbinpack::v1 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /test/format/pass_check_single_json.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": 1 14 | } 15 | EOF 16 | 17 | "$1" fmt "$TMP/schema.json" --check --json >"$TMP/output.json" 2>&1 18 | 19 | cat << 'EOF' > "$TMP/expected.json" 20 | { 21 | "valid": true 22 | } 23 | EOF 24 | 25 | diff "$TMP/output.json" "$TMP/expected.json" 26 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/include/cpr/local_port.h: -------------------------------------------------------------------------------- 1 | #ifndef CPR_LOCAL_PORT_H 2 | #define CPR_LOCAL_PORT_H 3 | 4 | #include 5 | 6 | namespace cpr { 7 | 8 | class LocalPort { 9 | public: 10 | // NOLINTNEXTLINE(google-explicit-constructor) 11 | LocalPort(const std::uint16_t p_localport) : localport_(p_localport) {} 12 | 13 | operator std::uint16_t() const { 14 | return localport_; 15 | } 16 | 17 | private: 18 | std::uint16_t localport_ = 0; 19 | }; 20 | 21 | } // namespace cpr 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /vendor/jsonbinpack/src/runtime/unreachable.h: -------------------------------------------------------------------------------- 1 | #ifndef SOURCEMETA_JSONBINPACK_RUNTIME_UNREACHABLE_H_ 2 | #define SOURCEMETA_JSONBINPACK_RUNTIME_UNREACHABLE_H_ 3 | 4 | #include // assert 5 | 6 | // Until we are on C++23 and can use std::unreachable 7 | // See https://en.cppreference.com/w/cpp/utility/unreachable 8 | [[noreturn]] inline void unreachable() { 9 | assert(false); 10 | #if defined(_MSC_VER) && !defined(__clang__) 11 | __assume(false); 12 | #else 13 | __builtin_unreachable(); 14 | #endif 15 | } 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /test/validate/pass_2020_12_default_dialect.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "properties": { 13 | "foo": { 14 | "type": "string" 15 | } 16 | } 17 | } 18 | EOF 19 | 20 | cat << 'EOF' > "$TMP/instance.json" 21 | { "foo": "bar" } 22 | EOF 23 | 24 | "$1" validate --default-dialect "https://json-schema.org/draft/2020-12/schema" \ 25 | "$TMP/schema.json" "$TMP/instance.json" 26 | -------------------------------------------------------------------------------- /vendor/core/src/lang/parallel/include/sourcemeta/core/parallel.h: -------------------------------------------------------------------------------- 1 | #ifndef SOURCEMETA_CORE_PARALLEL_H_ 2 | #define SOURCEMETA_CORE_PARALLEL_H_ 3 | 4 | // NOLINTBEGIN(misc-include-cleaner) 5 | #include 6 | // NOLINTEND(misc-include-cleaner) 7 | 8 | /// @defgroup parallel Parallel 9 | /// @brief Growing collection of utilities for parallel computing 10 | /// 11 | /// This functionality is included as follows: 12 | /// 13 | /// ```cpp 14 | /// #include 15 | /// ``` 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/include/cpr/unix_socket.h: -------------------------------------------------------------------------------- 1 | #ifndef CPR_UNIX_SOCKET_H 2 | #define CPR_UNIX_SOCKET_H 3 | 4 | #include 5 | 6 | namespace cpr { 7 | 8 | class UnixSocket { 9 | public: 10 | // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) 11 | UnixSocket(std::string unix_socket) : unix_socket_(std::move(unix_socket)) {} 12 | 13 | const char* GetUnixSocketString() const noexcept; 14 | 15 | private: 16 | const std::string unix_socket_; 17 | }; 18 | 19 | } // namespace cpr 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /test/validate/pass_process_substitution.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "type": "object", 14 | "properties": { 15 | "name": { 16 | "type": "string" 17 | } 18 | }, 19 | "required": ["name"] 20 | } 21 | EOF 22 | 23 | INSTANCE="{\"name\":\"demo\"}" 24 | 25 | "$1" validate --verbose "$TMP/schema.json" <(echo "$INSTANCE") 26 | -------------------------------------------------------------------------------- /vendor/core/vendor/jsonschema-2020-12/meta/format-assertion.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$id": "https://json-schema.org/draft/2020-12/meta/format-assertion", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2020-12/vocab/format-assertion": true 6 | }, 7 | "$dynamicAnchor": "meta", 8 | 9 | "title": "Format vocabulary meta-schema for assertion results", 10 | "type": ["object", "boolean"], 11 | "properties": { 12 | "format": { "type": "string" } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/lint/pass_lint_json.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "enum": [ "foo" ] 14 | } 15 | EOF 16 | 17 | "$1" lint "$TMP/schema.json" --json >"$TMP/output.json" 2>&1 18 | 19 | cat << EOF > "$TMP/expected.json" 20 | { 21 | "valid": true, 22 | "health": 100, 23 | "errors": [] 24 | } 25 | EOF 26 | 27 | diff "$TMP/output.json" "$TMP/expected.json" 28 | -------------------------------------------------------------------------------- /vendor/core/vendor/jsonschema-2020-12/meta/format-annotation.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$id": "https://json-schema.org/draft/2020-12/meta/format-annotation", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2020-12/vocab/format-annotation": true 6 | }, 7 | "$dynamicAnchor": "meta", 8 | 9 | "title": "Format vocabulary meta-schema for annotation results", 10 | "type": ["object", "boolean"], 11 | "properties": { 12 | "format": { "type": "string" } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /vendor/core/vendor/jsonschema-draft0/json-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema" : "http://json-schema.org/draft-00/hyper-schema#", 3 | "id" : "http://json-schema.org/draft-00/json-ref#", 4 | 5 | "items" : {"$ref" : "#"}, 6 | "additionalProperties" : {"$ref" : "#"}, 7 | 8 | "links" : [ 9 | { 10 | "href" : "{$ref}", 11 | "rel" : "full" 12 | }, 13 | 14 | { 15 | "href" : "{$schema}", 16 | "rel" : "describedby" 17 | }, 18 | 19 | { 20 | "href" : "{id}", 21 | "rel" : "self" 22 | } 23 | ], 24 | 25 | "fragmentResolution" : "dot-delimited" 26 | } -------------------------------------------------------------------------------- /vendor/core/vendor/jsonschema-draft1/json-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema" : "http://json-schema.org/draft-01/hyper-schema#", 3 | "id" : "http://json-schema.org/draft-01/json-ref#", 4 | 5 | "items" : {"$ref" : "#"}, 6 | "additionalProperties" : {"$ref" : "#"}, 7 | 8 | "links" : [ 9 | { 10 | "href" : "{$ref}", 11 | "rel" : "full" 12 | }, 13 | 14 | { 15 | "href" : "{$schema}", 16 | "rel" : "describedby" 17 | }, 18 | 19 | { 20 | "href" : "{id}", 21 | "rel" : "self" 22 | } 23 | ], 24 | 25 | "fragmentResolution" : "dot-delimited" 26 | } -------------------------------------------------------------------------------- /vendor/core/vendor/jsonschema-draft2/json-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema" : "http://json-schema.org/draft-02/hyper-schema#", 3 | "id" : "http://json-schema.org/draft-02/json-ref#", 4 | 5 | "items" : {"$ref" : "#"}, 6 | "additionalProperties" : {"$ref" : "#"}, 7 | 8 | "links" : [ 9 | { 10 | "href" : "{$ref}", 11 | "rel" : "full" 12 | }, 13 | 14 | { 15 | "href" : "{$schema}", 16 | "rel" : "describedby" 17 | }, 18 | 19 | { 20 | "href" : "{id}", 21 | "rel" : "self" 22 | } 23 | ], 24 | 25 | "fragmentResolution" : "dot-delimited" 26 | } -------------------------------------------------------------------------------- /docs/version.markdown: -------------------------------------------------------------------------------- 1 | Version 2 | ======= 3 | 4 | ```sh 5 | jsonschema version 6 | jsonschema --version 7 | jsonschema -v 8 | ``` 9 | 10 | Print the current version of the JSON Schema CLI to standard output, without 11 | the `v` prefix. 12 | 13 | Examples 14 | -------- 15 | 16 | ### Print the current version 17 | 18 | ```sh 19 | jsonschema version 20 | ``` 21 | 22 | ### Print the current version using the long flag 23 | 24 | ```sh 25 | jsonschema --version 26 | ``` 27 | 28 | ### Print the current version using the short flag 29 | 30 | ```sh 31 | jsonschema -v 32 | ``` 33 | -------------------------------------------------------------------------------- /vendor/core/vendor/jsonschema-draft3/json-ref.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema" : "http://json-schema.org/draft-03/hyper-schema#", 3 | "id" : "http://json-schema.org/draft-03/json-ref#", 4 | 5 | "additionalItems" : {"$ref" : "#"}, 6 | "additionalProperties" : {"$ref" : "#"}, 7 | 8 | "links" : [ 9 | { 10 | "href" : "{id}", 11 | "rel" : "self" 12 | }, 13 | 14 | { 15 | "href" : "{$ref}", 16 | "rel" : "full" 17 | }, 18 | 19 | { 20 | "href" : "{$schema}", 21 | "rel" : "describedby" 22 | } 23 | ], 24 | 25 | "fragmentResolution" : "dot-delimited" 26 | } -------------------------------------------------------------------------------- /vendor/hydra/vendor/mbedtls/include/mbedtls/private_access.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file private_access.h 3 | * 4 | * \brief Macro wrapper for struct's members. 5 | */ 6 | /* 7 | * Copyright The Mbed TLS Contributors 8 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 9 | */ 10 | 11 | #ifndef MBEDTLS_PRIVATE_ACCESS_H 12 | #define MBEDTLS_PRIVATE_ACCESS_H 13 | 14 | #ifndef MBEDTLS_ALLOW_PRIVATE_ACCESS 15 | #define MBEDTLS_PRIVATE(member) private_##member 16 | #else 17 | #define MBEDTLS_PRIVATE(member) member 18 | #endif 19 | 20 | #endif /* MBEDTLS_PRIVATE_ACCESS_H */ 21 | -------------------------------------------------------------------------------- /npm/cjs.test.js: -------------------------------------------------------------------------------- 1 | const test = require('node:test'); 2 | const assert = require('node:assert'); 3 | const { spawn } = require('./main.js'); 4 | const packageJson = require('../package.json'); 5 | 6 | // This file is just to do a basic pass and ensure that CommonJS 7 | // imports work. Please put actual tests in the other ESM file. 8 | 9 | test('commonjs: spawn returns version with --version flag', async () => { 10 | const result = await spawn(['--version']); 11 | assert.strictEqual(result.code, 0); 12 | assert.strictEqual(result.stdout.trim(), packageJson.version); 13 | }); 14 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/mbedtls/library/psa_crypto_client.c: -------------------------------------------------------------------------------- 1 | /* 2 | * PSA crypto client code 3 | */ 4 | /* 5 | * Copyright The Mbed TLS Contributors 6 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 7 | */ 8 | 9 | #include "common.h" 10 | #include "psa/crypto.h" 11 | 12 | #if defined(MBEDTLS_PSA_CRYPTO_CLIENT) 13 | 14 | #include 15 | #include "mbedtls/platform.h" 16 | 17 | void psa_reset_key_attributes(psa_key_attributes_t *attributes) 18 | { 19 | memset(attributes, 0, sizeof(*attributes)); 20 | } 21 | 22 | #endif /* MBEDTLS_PSA_CRYPTO_CLIENT */ 23 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/mbedtls/library/ssl_client.h: -------------------------------------------------------------------------------- 1 | /** 2 | * TLS 1.2 and 1.3 client-side functions 3 | * 4 | * Copyright The Mbed TLS Contributors 5 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 6 | */ 7 | 8 | #ifndef MBEDTLS_SSL_CLIENT_H 9 | #define MBEDTLS_SSL_CLIENT_H 10 | 11 | #include "common.h" 12 | 13 | #if defined(MBEDTLS_SSL_TLS_C) 14 | #include "ssl_misc.h" 15 | #endif 16 | 17 | #include 18 | 19 | MBEDTLS_CHECK_RETURN_CRITICAL 20 | int mbedtls_ssl_write_client_hello(mbedtls_ssl_context *ssl); 21 | 22 | #endif /* MBEDTLS_SSL_CLIENT_H */ 23 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/include/cpr/local_port_range.h: -------------------------------------------------------------------------------- 1 | #ifndef CPR_LOCAL_PORT_RANGE_H 2 | #define CPR_LOCAL_PORT_RANGE_H 3 | 4 | #include 5 | 6 | namespace cpr { 7 | 8 | class LocalPortRange { 9 | public: 10 | // NOLINTNEXTLINE(google-explicit-constructor) 11 | LocalPortRange(const std::uint16_t p_localportrange) : localportrange_(p_localportrange) {} 12 | 13 | operator std::uint16_t() const { 14 | return localportrange_; 15 | } 16 | 17 | private: 18 | std::uint16_t localportrange_ = 0; 19 | }; 20 | 21 | } // namespace cpr 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/include/cpr/payload.h: -------------------------------------------------------------------------------- 1 | #ifndef CPR_PAYLOAD_H 2 | #define CPR_PAYLOAD_H 3 | 4 | #include 5 | 6 | #include "cpr/curl_container.h" 7 | 8 | 9 | namespace cpr { 10 | class Payload : public CurlContainer { 11 | public: 12 | template 13 | Payload(const It begin, const It end) { 14 | for (It pair = begin; pair != end; ++pair) { 15 | Add(*pair); 16 | } 17 | } 18 | Payload(const std::initializer_list& pairs) : CurlContainer(pairs) {} 19 | }; 20 | 21 | } // namespace cpr 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /vendor/jsonbinpack/src/numeric/include/sourcemeta/jsonbinpack/numeric.h: -------------------------------------------------------------------------------- 1 | #ifndef SOURCEMETA_JSONBINPACK_NUMERIC_H_ 2 | #define SOURCEMETA_JSONBINPACK_NUMERIC_H_ 3 | 4 | /// @defgroup numeric Numeric 5 | /// @brief A comprehensive numeric library for JSON BinPack 6 | /// 7 | /// This functionality is included as follows: 8 | /// 9 | /// ```cpp 10 | /// #include 11 | /// ``` 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /test/lint/pass_lint_list_only_many.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | "$1" lint --list --only then_empty --only then_without_if > "$TMP/output.txt" 11 | 12 | cat << 'EOF' > "$TMP/expected.txt" 13 | then_empty 14 | Setting the `then` keyword to the empty schema does not add any further constraint 15 | 16 | then_without_if 17 | The `then` keyword is meaningless without the presence of the `if` keyword 18 | 19 | Number of rules: 2 20 | EOF 21 | 22 | diff "$TMP/output.txt" "$TMP/expected.txt" 23 | -------------------------------------------------------------------------------- /test/compile/pass_patternproperties.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-07/schema#", 13 | "patternProperties": { 14 | "[\\-]": { 15 | "type": "string" 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | cat << 'EOF' > "$TMP/instance.json" 22 | {} 23 | EOF 24 | 25 | "$1" compile "$TMP/schema.json" > "$TMP/template.json" 26 | "$1" validate --template "$TMP/template.json" "$TMP/schema.json" "$TMP/instance.json" 27 | -------------------------------------------------------------------------------- /vendor/core/vendor/jsonschema-2020-12/meta/unevaluated.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$id": "https://json-schema.org/draft/2020-12/meta/unevaluated", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2020-12/vocab/unevaluated": true 6 | }, 7 | "$dynamicAnchor": "meta", 8 | 9 | "title": "Unevaluated applicator vocabulary meta-schema", 10 | "type": ["object", "boolean"], 11 | "properties": { 12 | "unevaluatedItems": { "$dynamicRef": "#meta" }, 13 | "unevaluatedProperties": { "$dynamicRef": "#meta" } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/cpr/callback.cpp: -------------------------------------------------------------------------------- 1 | #include "cpr/callback.h" 2 | #include "cpr/cprtypes.h" 3 | #include 4 | 5 | namespace cpr { 6 | 7 | void CancellationCallback::SetProgressCallback(ProgressCallback& u_cb) { 8 | user_cb.emplace(std::reference_wrapper{u_cb}); 9 | } 10 | bool CancellationCallback::operator()(cpr_pf_arg_t dltotal, cpr_pf_arg_t dlnow, cpr_pf_arg_t ultotal, cpr_pf_arg_t ulnow) const { 11 | const bool cont_operation{!cancellation_state->load()}; 12 | return user_cb ? (cont_operation && (*user_cb)(dltotal, dlnow, ultotal, ulnow)) : cont_operation; 13 | } 14 | } // namespace cpr 15 | -------------------------------------------------------------------------------- /test/format/pass_check_yaml.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.yaml" 11 | type: 1 12 | $schema: http://json-schema.org/draft-04/schema# 13 | EOF 14 | 15 | "$1" fmt "$TMP/schema.yaml" --check >"$TMP/output.txt" 2>&1 && CODE="$?" || CODE="$?" 16 | test "$CODE" = "1" || exit 1 17 | 18 | cat << EOF > "$TMP/expected.txt" 19 | error: This command does not support YAML input files yet 20 | at file path $(realpath "$TMP/schema.yaml") 21 | EOF 22 | 23 | diff "$TMP/output.txt" "$TMP/expected.txt" 24 | -------------------------------------------------------------------------------- /test/validate/pass_2020_12_with_template.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "properties": { 14 | "foo": { 15 | "type": "string" 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | cat << 'EOF' > "$TMP/instance.json" 22 | { "foo": "bar" } 23 | EOF 24 | 25 | "$1" compile "$TMP/schema.json" > "$TMP/template.json" 26 | "$1" validate "$TMP/schema.json" "$TMP/instance.json" --template "$TMP/template.json" 27 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/include/cpr/connect_timeout.h: -------------------------------------------------------------------------------- 1 | #ifndef CPR_CONNECT_TIMEOUT_H 2 | #define CPR_CONNECT_TIMEOUT_H 3 | 4 | #include "cpr/timeout.h" 5 | 6 | namespace cpr { 7 | 8 | class ConnectTimeout : public Timeout { 9 | public: 10 | // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) 11 | ConnectTimeout(const std::chrono::milliseconds& duration) : Timeout{duration} {} 12 | // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) 13 | ConnectTimeout(const std::int32_t& milliseconds) : Timeout{milliseconds} {} 14 | }; 15 | 16 | } // namespace cpr 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/mbedtls/include/psa/build_info.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file psa/build_info.h 3 | * 4 | * \brief Build-time PSA configuration info 5 | * 6 | * Include this file if you need to depend on the 7 | * configuration options defined in mbedtls_config.h or MBEDTLS_CONFIG_FILE 8 | * in PSA cryptography core specific files. 9 | */ 10 | /* 11 | * Copyright The Mbed TLS Contributors 12 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 13 | */ 14 | 15 | #ifndef PSA_CRYPTO_BUILD_INFO_H 16 | #define PSA_CRYPTO_BUILD_INFO_H 17 | 18 | #include "mbedtls/build_info.h" 19 | 20 | #endif /* PSA_CRYPTO_BUILD_INFO_H */ 21 | -------------------------------------------------------------------------------- /test/lint/pass_lint_anonymous_default_with_ref.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-07/schema#", 13 | "default": [ "foo", "bar", "baz" ], 14 | "items": { 15 | "$ref": "./other.json" 16 | } 17 | } 18 | EOF 19 | 20 | cat << 'EOF' > "$TMP/other.json" 21 | { 22 | "$schema": "http://json-schema.org/draft-07/schema#", 23 | "type": "string" 24 | } 25 | EOF 26 | 27 | "$1" lint "$TMP/schema.json" --resolve "$TMP/other.json" --verbose 28 | -------------------------------------------------------------------------------- /test/lint/pass_lint_anonymous_nested_default_with_ref.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "items": { 14 | "default": "foo", 15 | "$ref": "./other.json" 16 | } 17 | } 18 | EOF 19 | 20 | cat << 'EOF' > "$TMP/other.json" 21 | { 22 | "$schema": "https://json-schema.org/draft/2020-12/schema", 23 | "type": "string" 24 | } 25 | EOF 26 | 27 | "$1" lint "$TMP/schema.json" --resolve "$TMP/other.json" --verbose 28 | -------------------------------------------------------------------------------- /vendor/core/vendor/jsonschema-2019-09/meta/content.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/schema", 3 | "$id": "https://json-schema.org/draft/2019-09/meta/content", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2019-09/vocab/content": true 6 | }, 7 | "$recursiveAnchor": true, 8 | 9 | "title": "Content vocabulary meta-schema", 10 | 11 | "type": ["object", "boolean"], 12 | "properties": { 13 | "contentMediaType": { "type": "string" }, 14 | "contentEncoding": { "type": "string" }, 15 | "contentSchema": { "$recursiveRef": "#" } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/validate/pass_jsonl_bigint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": "object" 14 | } 15 | EOF 16 | 17 | cat << 'EOF' > "$TMP/instance.jsonl" 18 | { "foo": 1 } 19 | { "foo": 9223372036854776000 } 20 | { "foo": 3 } 21 | EOF 22 | 23 | "$1" validate "$TMP/schema.json" "$TMP/instance.jsonl" 2> "$TMP/output.txt" 1>&2 24 | 25 | cat << EOF > "$TMP/expected.txt" 26 | EOF 27 | 28 | diff "$TMP/output.txt" "$TMP/expected.txt" 29 | -------------------------------------------------------------------------------- /vendor/core/vendor/jsonschema-2020-12/meta/content.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/schema", 3 | "$id": "https://json-schema.org/draft/2020-12/meta/content", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2020-12/vocab/content": true 6 | }, 7 | "$dynamicAnchor": "meta", 8 | 9 | "title": "Content vocabulary meta-schema", 10 | 11 | "type": ["object", "boolean"], 12 | "properties": { 13 | "contentEncoding": { "type": "string" }, 14 | "contentMediaType": { "type": "string" }, 15 | "contentSchema": { "$dynamicRef": "#meta" } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/validate/pass_2020_12_fast_with_template.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "properties": { 14 | "foo": { 15 | "type": "string" 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | cat << 'EOF' > "$TMP/instance.json" 22 | { "foo": "bar" } 23 | EOF 24 | 25 | "$1" compile "$TMP/schema.json" > "$TMP/template.json" 26 | "$1" validate "$TMP/schema.json" "$TMP/instance.json" \ 27 | --fast --template "$TMP/template.json" 28 | -------------------------------------------------------------------------------- /test/version_command.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | "$1" version 1> "$TMP/stdout" 2> "$TMP/stderr" 11 | 12 | if ! [ -s "$TMP/stdout" ] 13 | then 14 | echo "FAIL: Did not produce output to stdout" 1>&2 15 | exit 1 16 | fi 17 | 18 | cat "$TMP/stdout" 19 | grep -q '^[0-9]\+\.[0-9]\+\.[0-9]\+$' "$TMP/stdout" || \ 20 | (echo "The output does not look like a valid version" 1>&2 && exit 1) 21 | 22 | if [ -s "$TMP/stderr" ] 23 | then 24 | echo "FAIL: Produced output to stderr" 1>&2 25 | cat "$TMP/stderr.txt" 26 | exit 1 27 | fi 28 | -------------------------------------------------------------------------------- /test/version_option_short.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | "$1" -v 1> "$TMP/stdout" 2> "$TMP/stderr" 11 | 12 | if ! [ -s "$TMP/stdout" ] 13 | then 14 | echo "FAIL: Did not produce output to stdout" 1>&2 15 | exit 1 16 | fi 17 | 18 | cat "$TMP/stdout" 19 | grep -q '^[0-9]\+\.[0-9]\+\.[0-9]\+$' "$TMP/stdout" || \ 20 | (echo "The output does not look like a valid version" 1>&2 && exit 1) 21 | 22 | if [ -s "$TMP/stderr" ] 23 | then 24 | echo "FAIL: Produced output to stderr" 1>&2 25 | cat "$TMP/stderr.txt" 26 | exit 1 27 | fi 28 | -------------------------------------------------------------------------------- /vendor/core/src/core/jsonl/jsonl.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include // std::basic_istream 5 | 6 | namespace sourcemeta::core { 7 | 8 | JSONL::JSONL(std::basic_istream &stream) 9 | : data{stream} {} 10 | 11 | auto JSONL::begin() -> JSONL::const_iterator { return {&this->data}; } 12 | auto JSONL::end() -> JSONL::const_iterator { return {nullptr}; } 13 | auto JSONL::cbegin() -> JSONL::const_iterator { return {&this->data}; } 14 | auto JSONL::cend() -> JSONL::const_iterator { return {nullptr}; } 15 | 16 | } // namespace sourcemeta::core 17 | -------------------------------------------------------------------------------- /vendor/core/vendor/googletest/googletest/cmake/libgtest.la.in: -------------------------------------------------------------------------------- 1 | # libgtest.la - a libtool library file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Names of this library. 8 | library_names='libgtest.so' 9 | 10 | # Is this an already installed library? 11 | installed=yes 12 | 13 | # Should we warn about portability when linking against -modules? 14 | shouldnotlink=no 15 | 16 | # Files to dlopen/dlpreopen 17 | dlopen='' 18 | dlpreopen='' 19 | 20 | # Directory that this library needs to be installed in: 21 | libdir='@CMAKE_INSTALL_FULL_LIBDIR@' 22 | -------------------------------------------------------------------------------- /vendorpull.mask: -------------------------------------------------------------------------------- 1 | assets 2 | bin 3 | docs 4 | test 5 | vendor/blaze 6 | vendor/core 7 | vendor/hydra 8 | vendor/jsonbinpack 9 | vendor/vendorpull 10 | .ackrc 11 | .editorconfig 12 | action.yml 13 | Brewfile 14 | CONTRIBUTING.markdown 15 | DEPENDENCIES 16 | Dockerfile 17 | install 18 | Makefile 19 | npm-pack.sh 20 | pip-deploy.sh 21 | README.markdown 22 | cmake/FindBlaze.cmake 23 | cmake/FindCore.cmake 24 | cmake/FindHydra.cmake 25 | cmake/FindJSONBinPack.cmake 26 | cmake/fetch-github-releases.cmake 27 | .pre-commit-hooks.yaml 28 | snapcraft.yaml 29 | .npmignore 30 | cli.js 31 | eslint.config.mjs 32 | package.json 33 | package-lock.json 34 | npm 35 | -------------------------------------------------------------------------------- /test/validate/pass_jsonl_empty.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "properties": { 14 | "foo": { 15 | "type": "string" 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | touch "$TMP/instance.jsonl" 22 | 23 | "$1" validate "$TMP/schema.json" "$TMP/instance.jsonl" 2> "$TMP/output.txt" 1>&2 24 | 25 | cat << EOF > "$TMP/expected.txt" 26 | warning: The JSONL file is empty 27 | EOF 28 | 29 | diff "$TMP/output.txt" "$TMP/expected.txt" 30 | -------------------------------------------------------------------------------- /test/version_option_long.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | "$1" --version 1> "$TMP/stdout" 2> "$TMP/stderr" 11 | 12 | if ! [ -s "$TMP/stdout" ] 13 | then 14 | echo "FAIL: Did not produce output to stdout" 1>&2 15 | exit 1 16 | fi 17 | 18 | cat "$TMP/stdout" 19 | grep -q '^[0-9]\+\.[0-9]\+\.[0-9]\+$' "$TMP/stdout" || \ 20 | (echo "The output does not look like a valid version" 1>&2 && exit 1) 21 | 22 | if [ -s "$TMP/stderr" ] 23 | then 24 | echo "FAIL: Produced output to stderr" 1>&2 25 | cat "$TMP/stderr.txt" 26 | exit 1 27 | fi 28 | -------------------------------------------------------------------------------- /vendor/core/vendor/googletest/googlemock/include/gmock/internal/custom/README.md: -------------------------------------------------------------------------------- 1 | # Customization Points 2 | 3 | The custom directory is an injection point for custom user configurations. 4 | 5 | ## Header `gmock-port.h` 6 | 7 | The following macros can be defined: 8 | 9 | ### Flag related macros: 10 | 11 | * `GMOCK_DECLARE_bool_(name)` 12 | * `GMOCK_DECLARE_int32_(name)` 13 | * `GMOCK_DECLARE_string_(name)` 14 | * `GMOCK_DEFINE_bool_(name, default_val, doc)` 15 | * `GMOCK_DEFINE_int32_(name, default_val, doc)` 16 | * `GMOCK_DEFINE_string_(name, default_val, doc)` 17 | * `GMOCK_FLAG_GET(flag_name)` 18 | * `GMOCK_FLAG_SET(flag_name, value)` 19 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/cpr/auth.cpp: -------------------------------------------------------------------------------- 1 | #include "cpr/auth.h" 2 | 3 | #include 4 | 5 | namespace cpr { 6 | 7 | Authentication::Authentication(std::string_view username, std::string_view password, AuthMode auth_mode) : auth_mode_{auth_mode} { 8 | auth_string_.reserve(username.size() + 1 + password.size()); 9 | auth_string_ += username; 10 | auth_string_ += ':'; 11 | auth_string_ += password; 12 | } 13 | 14 | const char* Authentication::GetAuthString() const noexcept { 15 | return auth_string_.c_str(); 16 | } 17 | 18 | AuthMode Authentication::GetAuthMode() const noexcept { 19 | return auth_mode_; 20 | } 21 | } // namespace cpr 22 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/cpr/proxies.cpp: -------------------------------------------------------------------------------- 1 | #include "cpr/proxies.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | namespace cpr { 9 | 10 | Proxies::Proxies(const std::initializer_list>& hosts) : hosts_{hosts} {} 11 | Proxies::Proxies(const std::map& hosts) : hosts_{hosts} {} 12 | 13 | bool Proxies::has(const std::string& protocol) const { 14 | return hosts_.count(protocol) > 0; 15 | } 16 | 17 | const std::string& Proxies::operator[](const std::string& protocol) { 18 | return hosts_[protocol]; 19 | } 20 | 21 | } // namespace cpr 22 | -------------------------------------------------------------------------------- /vendor/jsonbinpack/src/runtime/decoder_number.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include // std::pow 4 | #include // std::int64_t, std::uint64_t 5 | 6 | namespace sourcemeta::jsonbinpack { 7 | 8 | auto Decoder::DOUBLE_VARINT_TUPLE(const struct DOUBLE_VARINT_TUPLE &) 9 | -> sourcemeta::core::JSON { 10 | const std::int64_t digits{this->get_varint_zigzag()}; 11 | const std::uint64_t point{this->get_varint()}; 12 | const double divisor{std::pow(10, static_cast(point))}; 13 | return sourcemeta::core::JSON{static_cast(digits) / divisor}; 14 | } 15 | 16 | } // namespace sourcemeta::jsonbinpack 17 | -------------------------------------------------------------------------------- /test/ci/fail_bundle_http_non_200.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-07/schema#", 13 | "allOf": [ { "$ref": "https://example.com" } ] 14 | } 15 | EOF 16 | 17 | "$1" bundle "$TMP/schema.json" --http 2> "$TMP/stderr.txt" \ 18 | && CODE="$?" || CODE="$?" 19 | test "$CODE" = "1" || exit 1 20 | 21 | cat << EOF > "$TMP/expected.txt" 22 | error: Failed to parse the JSON document 23 | at line 1 24 | at column 1 25 | EOF 26 | 27 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 28 | -------------------------------------------------------------------------------- /test/lint/pass_lint_fix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-06/schema#", 13 | "type": "string", 14 | "const": "foo", 15 | "title": "I should not be moved up" 16 | } 17 | EOF 18 | 19 | "$1" lint "$TMP/schema.json" --fix 20 | 21 | cat << 'EOF' > "$TMP/expected.json" 22 | { 23 | "$schema": "http://json-schema.org/draft-06/schema#", 24 | "const": "foo", 25 | "title": "I should not be moved up" 26 | } 27 | EOF 28 | 29 | diff "$TMP/schema.json" "$TMP/expected.json" 30 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/include/cpr/proxies.h: -------------------------------------------------------------------------------- 1 | #ifndef CPR_PROXIES_H 2 | #define CPR_PROXIES_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace cpr { 9 | class Proxies { 10 | public: 11 | Proxies() = default; 12 | Proxies(const std::initializer_list>& hosts); 13 | Proxies(const std::map& hosts); 14 | 15 | bool has(const std::string& protocol) const; 16 | const std::string& operator[](const std::string& protocol); 17 | 18 | private: 19 | std::map hosts_; 20 | }; 21 | } // namespace cpr 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /test/ci/pass_validate_http.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-07/schema#", 13 | "allOf": [ 14 | { "$ref": "https://schemas.sourcemeta.com/jsonschema/draft4/schema.json" } 15 | ] 16 | } 17 | EOF 18 | 19 | cat << 'EOF' > "$TMP/instance.json" 20 | { "type": "string" } 21 | EOF 22 | 23 | "$1" validate "$TMP/schema.json" "$TMP/instance.json" --http 2> "$TMP/stderr.txt" 24 | 25 | cat << EOF > "$TMP/expected.txt" 26 | EOF 27 | 28 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 29 | -------------------------------------------------------------------------------- /test/lint/fail_lint_only_unknown.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": "string", 14 | "enum": [ "foo" ] 15 | } 16 | EOF 17 | 18 | "$1" lint "$TMP/schema.json" --only foobarbaz \ 19 | >"$TMP/stderr.txt" 2>&1 && CODE="$?" || CODE="$?" 20 | test "$CODE" = "1" || exit 1 21 | 22 | cat << EOF > "$TMP/expected.txt" 23 | error: The following linting rule does not exist 24 | at rule foobarbaz 25 | EOF 26 | 27 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 28 | -------------------------------------------------------------------------------- /test/lint/pass_lint_fix_strict.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-06/schema#", 13 | "required": [ "foo", "bar" ] 14 | } 15 | EOF 16 | 17 | "$1" lint "$TMP/schema.json" --fix --strict 18 | 19 | cat << 'EOF' > "$TMP/expected.json" 20 | { 21 | "$schema": "http://json-schema.org/draft-06/schema#", 22 | "required": [ "foo", "bar" ], 23 | "properties": { 24 | "foo": true, 25 | "bar": true 26 | } 27 | } 28 | EOF 29 | 30 | diff "$TMP/schema.json" "$TMP/expected.json" 31 | -------------------------------------------------------------------------------- /test/validate/pass_json_ref_yaml.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "$ref": "http://example.com/schema.yaml" 14 | } 15 | EOF 16 | 17 | cat << 'EOF' > "$TMP/schema.yaml" 18 | $id: http://example.com/schema.yaml 19 | $schema: https://json-schema.org/draft/2020-12/schema 20 | type: string 21 | EOF 22 | 23 | cat << 'EOF' > "$TMP/instance.json" 24 | "foo" 25 | EOF 26 | 27 | "$1" validate "$TMP/schema.json" --resolve "$TMP/schema.yaml" "$TMP/instance.json" 28 | -------------------------------------------------------------------------------- /vendor/core/src/extension/schemaconfig/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME schemaconfig 2 | PRIVATE_HEADERS error.h SOURCES parse.cc schemaconfig.cc) 3 | 4 | if(SOURCEMETA_CORE_INSTALL) 5 | sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME schemaconfig) 6 | endif() 7 | 8 | target_link_libraries(sourcemeta_core_schemaconfig PUBLIC sourcemeta::core::json) 9 | target_link_libraries(sourcemeta_core_schemaconfig PUBLIC sourcemeta::core::jsonpointer) 10 | target_link_libraries(sourcemeta_core_schemaconfig PRIVATE sourcemeta::core::uri) 11 | target_link_libraries(sourcemeta_core_schemaconfig PRIVATE sourcemeta::core::io) 12 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/include/cpr/auth.h: -------------------------------------------------------------------------------- 1 | #ifndef CPR_AUTH_H 2 | #define CPR_AUTH_H 3 | 4 | #include 5 | #include 6 | 7 | #include "cpr/util.h" 8 | 9 | namespace cpr { 10 | 11 | enum class AuthMode { BASIC, DIGEST, NTLM, NEGOTIATE, ANY, ANYSAFE }; 12 | 13 | class Authentication { 14 | public: 15 | Authentication(std::string_view username, std::string_view password, AuthMode auth_mode); 16 | 17 | const char* GetAuthString() const noexcept; 18 | AuthMode GetAuthMode() const noexcept; 19 | 20 | private: 21 | util::SecureString auth_string_; 22 | AuthMode auth_mode_; 23 | }; 24 | 25 | } // namespace cpr 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /test/format/fail_check_single_invalid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#" 13 | "type" 1, 14 | } 15 | EOF 16 | 17 | "$1" fmt "$TMP/schema.json" --check >"$TMP/output.txt" 2>&1 && CODE="$?" || CODE="$?" 18 | test "$CODE" = "1" || exit 1 19 | 20 | cat << EOF > "$TMP/expected.txt" 21 | error: Failed to parse the JSON document 22 | at line 3 23 | at column 3 24 | at file path $(realpath "$TMP")/schema.json 25 | EOF 26 | 27 | diff "$TMP/output.txt" "$TMP/expected.txt" 28 | -------------------------------------------------------------------------------- /test/lint/pass_lint_fix_no_reformat.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": 13 | "http://json-schema.org/draft-06/schema#", "type" : "string" 14 | } 15 | EOF 16 | 17 | "$1" lint "$TMP/schema.json" --fix 18 | 19 | # If no linting rule applies, we should leave the schema intact 20 | cat << 'EOF' > "$TMP/expected.json" 21 | { 22 | "$schema": 23 | "http://json-schema.org/draft-06/schema#", "type" : "string" 24 | } 25 | EOF 26 | 27 | diff "$TMP/schema.json" "$TMP/expected.json" 28 | -------------------------------------------------------------------------------- /test/lint/pass_lint_no_fix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": "string" 14 | } 15 | EOF 16 | 17 | "$1" lint "$TMP/schema.json" > "$TMP/result.txt" 2>&1 18 | 19 | cat << 'EOF' > "$TMP/output.txt" 20 | EOF 21 | 22 | diff "$TMP/result.txt" "$TMP/output.txt" 23 | 24 | cat << 'EOF' > "$TMP/expected.json" 25 | { 26 | "$schema": "http://json-schema.org/draft-04/schema#", 27 | "type": "string" 28 | } 29 | EOF 30 | 31 | diff "$TMP/schema.json" "$TMP/expected.json" 32 | -------------------------------------------------------------------------------- /vendor/core/src/core/jsonpointer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | sourcemeta_library(NAMESPACE sourcemeta PROJECT core NAME jsonpointer 2 | PRIVATE_HEADERS pointer.h position.h error.h token.h 3 | walker.h template.h 4 | SOURCES jsonpointer.cc stringify.h parser.h grammar.h position.cc) 5 | 6 | if(SOURCEMETA_CORE_INSTALL) 7 | sourcemeta_library_install(NAMESPACE sourcemeta PROJECT core NAME jsonpointer) 8 | endif() 9 | 10 | target_link_libraries(sourcemeta_core_jsonpointer PUBLIC 11 | sourcemeta::core::uri) 12 | target_link_libraries(sourcemeta_core_jsonpointer PUBLIC 13 | sourcemeta::core::json) 14 | target_link_libraries(sourcemeta_core_jsonpointer PUBLIC 15 | sourcemeta::core::regex) 16 | -------------------------------------------------------------------------------- /test/validate/pass_no_identifier_ref.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "$ref": "./schemas/other.json" 14 | } 15 | EOF 16 | 17 | mkdir -p "$TMP/schemas" 18 | 19 | cat << 'EOF' > "$TMP/schemas/other.json" 20 | { 21 | "$schema": "https://json-schema.org/draft/2020-12/schema", 22 | "type": "string" 23 | } 24 | EOF 25 | 26 | cat << 'EOF' > "$TMP/instance.json" 27 | "foo bar" 28 | EOF 29 | 30 | "$1" validate "$TMP/schema.json" --resolve "$TMP/schemas" "$TMP/instance.json" 31 | -------------------------------------------------------------------------------- /vendor/blaze/src/linter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | sourcemeta_library(NAMESPACE sourcemeta PROJECT blaze NAME linter 2 | FOLDER "Blaze/Linter" 3 | SOURCES 4 | valid_default.cc 5 | valid_examples.cc) 6 | 7 | if(BLAZE_INSTALL) 8 | sourcemeta_library_install(NAMESPACE sourcemeta PROJECT blaze NAME linter) 9 | endif() 10 | 11 | target_link_libraries(sourcemeta_blaze_linter PUBLIC 12 | sourcemeta::core::jsonschema) 13 | target_link_libraries(sourcemeta_blaze_linter PUBLIC 14 | sourcemeta::blaze::compiler) 15 | target_link_libraries(sourcemeta_blaze_linter PRIVATE 16 | sourcemeta::blaze::evaluator) 17 | target_link_libraries(sourcemeta_blaze_linter PRIVATE 18 | sourcemeta::blaze::output) 19 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/include/cpr/resolve.h: -------------------------------------------------------------------------------- 1 | #ifndef CPR_RESOLVE_H 2 | #define CPR_RESOLVE_H 3 | 4 | #include 5 | #include 6 | 7 | namespace cpr { 8 | class Resolve { 9 | public: 10 | std::string host; 11 | std::string addr; 12 | std::set ports; 13 | 14 | Resolve(const std::string& host_param, const std::string& addr_param, const std::set& ports_param = std::set{80U, 443U}) : host(host_param), addr(addr_param), ports(ports_param) { 15 | if (this->ports.empty()) { 16 | this->ports.insert(80U); 17 | this->ports.insert(443U); 18 | } 19 | } 20 | }; 21 | } // namespace cpr 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: JSON Schema CLI 2 | description: Install the JSON Schema CLI 3 | runs: 4 | using: composite 5 | steps: 6 | - name: Install the JSON Schema CLI (latest) 7 | shell: bash 8 | run: | 9 | INSTALL_DIR="$HOME/.local" 10 | curl --retry 5 --location --fail-early --silent --show-error \ 11 | --output "${GITHUB_WORKSPACE}/install.sh" \ 12 | "https://raw.githubusercontent.com/sourcemeta/jsonschema/main/install" 13 | chmod +x "${GITHUB_WORKSPACE}/install.sh" 14 | "${GITHUB_WORKSPACE}/install.sh" 12.10.1 "${INSTALL_DIR}" 15 | rm "${GITHUB_WORKSPACE}/install.sh" 16 | echo "${INSTALL_DIR}/bin" >> "$GITHUB_PATH" 17 | -------------------------------------------------------------------------------- /test/format/pass_check_single.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": 1 14 | } 15 | EOF 16 | 17 | "$1" fmt "$TMP/schema.json" --check >"$TMP/output.txt" 2>&1 18 | 19 | cat << 'EOF' > "$TMP/expected_output.txt" 20 | EOF 21 | 22 | diff "$TMP/output.txt" "$TMP/expected_output.txt" 23 | 24 | cat << 'EOF' > "$TMP/expected.json" 25 | { 26 | "$schema": "http://json-schema.org/draft-04/schema#", 27 | "type": 1 28 | } 29 | EOF 30 | 31 | diff "$TMP/schema.json" "$TMP/expected.json" 32 | -------------------------------------------------------------------------------- /test/validate/pass_jsonl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "properties": { 14 | "foo": { 15 | "type": "string" 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | cat << 'EOF' > "$TMP/instance.jsonl" 22 | { "foo": "first" } 23 | { "foo": "second" } 24 | { "foo": "third" } 25 | EOF 26 | 27 | "$1" validate "$TMP/schema.json" "$TMP/instance.jsonl" 2> "$TMP/output.txt" 1>&2 28 | 29 | cat << EOF > "$TMP/expected.txt" 30 | EOF 31 | 32 | diff "$TMP/output.txt" "$TMP/expected.txt" 33 | -------------------------------------------------------------------------------- /test/format/pass_bignum_real.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "minimum": 1e-05 14 | } 15 | EOF 16 | 17 | "$1" fmt "$TMP/schema.json" >"$TMP/output.txt" 2>&1 18 | 19 | cat << 'EOF' > "$TMP/expected_output.txt" 20 | EOF 21 | 22 | diff "$TMP/output.txt" "$TMP/expected_output.txt" 23 | 24 | cat << 'EOF' > "$TMP/expected.json" 25 | { 26 | "$schema": "http://json-schema.org/draft-04/schema#", 27 | "minimum": 1e-5 28 | } 29 | EOF 30 | 31 | diff "$TMP/schema.json" "$TMP/expected.json" 32 | -------------------------------------------------------------------------------- /test/lint/pass_lint_fix_indentation.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-06/schema#", 13 | "type": "string", 14 | "const": "foo", 15 | "title": "I should not be moved up" 16 | } 17 | EOF 18 | 19 | "$1" lint "$TMP/schema.json" --fix --indentation 4 20 | 21 | cat << 'EOF' > "$TMP/expected.json" 22 | { 23 | "$schema": "http://json-schema.org/draft-06/schema#", 24 | "const": "foo", 25 | "title": "I should not be moved up" 26 | } 27 | EOF 28 | 29 | diff "$TMP/schema.json" "$TMP/expected.json" 30 | -------------------------------------------------------------------------------- /test/test/pass_empty.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "id": "https://example.com", 13 | "$schema": "http://json-schema.org/draft-04/schema#", 14 | "type": "string" 15 | } 16 | EOF 17 | 18 | cat << 'EOF' > "$TMP/test.json" 19 | { 20 | "target": "https://example.com", 21 | "tests": [] 22 | } 23 | EOF 24 | 25 | "$1" test "$TMP/test.json" --resolve "$TMP/schema.json" 1> "$TMP/output.txt" 2>&1 26 | 27 | cat << EOF > "$TMP/expected.txt" 28 | $(realpath "$TMP")/test.json: NO TESTS 29 | EOF 30 | 31 | diff "$TMP/output.txt" "$TMP/expected.txt" 32 | -------------------------------------------------------------------------------- /test/validate/pass_yaml_multi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "properties": { 14 | "foo": { 15 | "type": "string" 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | cat << 'EOF' > "$TMP/instance.yaml" 22 | --- 23 | foo: first 24 | --- 25 | foo: second 26 | --- 27 | foo: third 28 | EOF 29 | 30 | "$1" validate "$TMP/schema.json" "$TMP/instance.yaml" 2> "$TMP/output.txt" 1>&2 31 | 32 | cat << EOF > "$TMP/expected.txt" 33 | EOF 34 | 35 | diff "$TMP/output.txt" "$TMP/expected.txt" 36 | -------------------------------------------------------------------------------- /vendor/blaze/LICENSE: -------------------------------------------------------------------------------- 1 | This software is dual-licensed: you can redistribute it and/or modify it under 2 | the terms of the GNU Affero General Public License as published by the Free 3 | Software Foundation, either version 3 of the License, or (at your option) any 4 | later version. For the terms of this license, see 5 | . 6 | 7 | You are free to use this software under the terms of the GNU Affero General 8 | Public License WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | 11 | Alternatively, you can use this software under a commercial license, as set out 12 | in . 13 | -------------------------------------------------------------------------------- /vendor/core/LICENSE: -------------------------------------------------------------------------------- 1 | This software is dual-licensed: you can redistribute it and/or modify it under 2 | the terms of the GNU Affero General Public License as published by the Free 3 | Software Foundation, either version 3 of the License, or (at your option) any 4 | later version. For the terms of this license, see 5 | . 6 | 7 | You are free to use this software under the terms of the GNU Affero General 8 | Public License WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | 11 | Alternatively, you can use this software under a commercial license, as set out 12 | in . 13 | -------------------------------------------------------------------------------- /vendor/hydra/LICENSE: -------------------------------------------------------------------------------- 1 | This software is dual-licensed: you can redistribute it and/or modify it under 2 | the terms of the GNU Affero General Public License as published by the Free 3 | Software Foundation, either version 3 of the License, or (at your option) any 4 | later version. For the terms of this license, see 5 | . 6 | 7 | You are free to use this software under the terms of the GNU Affero General 8 | Public License WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | 11 | Alternatively, you can use this software under a commercial license, as set out 12 | in . 13 | -------------------------------------------------------------------------------- /test/lint/fail_lint_only_with_exclude.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": "string", 14 | "enum": [ "foo" ] 15 | } 16 | EOF 17 | 18 | "$1" lint "$TMP/schema.json" \ 19 | --only enum_with_type --exclude const_with_type --verbose \ 20 | >"$TMP/stderr.txt" 2>&1 && CODE="$?" || CODE="$?" 21 | test "$CODE" = "1" || exit 1 22 | 23 | cat << EOF > "$TMP/expected.txt" 24 | error: Cannot use --only and --exclude at the same time 25 | EOF 26 | 27 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 28 | -------------------------------------------------------------------------------- /vendor/jsonbinpack/LICENSE: -------------------------------------------------------------------------------- 1 | This software is dual-licensed: you can redistribute it and/or modify it under 2 | the terms of the GNU Affero General Public License as published by the Free 3 | Software Foundation, either version 3 of the License, or (at your option) any 4 | later version. For the terms of this license, see 5 | . 6 | 7 | You are free to use this software under the terms of the GNU Affero General 8 | Public License WITHOUT ANY WARRANTY; without even the implied warranty of 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | 11 | Alternatively, you can use this software under a commercial license, as set out 12 | in . 13 | -------------------------------------------------------------------------------- /test/lint/pass_lint_embedded_resource.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "$id": "https://example.com/main", 14 | "$ref": "embedded", 15 | "$defs": { 16 | "embedded": { 17 | "$schema": "http://json-schema.org/draft-07/schema#", 18 | "$id": "embedded", 19 | "allOf": [ { "$ref": "#/definitions/foo" } ], 20 | "definitions": { 21 | "foo": { "type": "number" } 22 | } 23 | } 24 | } 25 | } 26 | EOF 27 | 28 | cd "$TMP" 29 | "$1" lint "$TMP/schema.json" 30 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/include/cpr/low_speed.h: -------------------------------------------------------------------------------- 1 | #ifndef CPR_LOW_SPEED_H 2 | #define CPR_LOW_SPEED_H 3 | 4 | #include 5 | #include 6 | 7 | namespace cpr { 8 | 9 | class LowSpeed { 10 | public: 11 | 12 | [[deprecated("Will be removed in CPR 2.x - Use the constructor with std::chrono::seconds instead of std::int32_t")]] 13 | LowSpeed(const std::int32_t p_limit, const std::int32_t p_time) : limit(p_limit), time(std::chrono::seconds(p_time)) {} 14 | 15 | LowSpeed(const std::int32_t p_limit, const std::chrono::seconds p_time) : limit(p_limit), time(p_time) {} 16 | 17 | std::int32_t limit; 18 | std::chrono::seconds time; 19 | }; 20 | 21 | } // namespace cpr 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /test/lint/pass_lint_fix_keep_ordering.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "type": "string", 13 | "$schema": "http://json-schema.org/draft-06/schema#" 14 | } 15 | EOF 16 | 17 | "$1" lint "$TMP/schema.json" --keep-ordering --fix > "$TMP/result.txt" 2>&1 18 | 19 | cat << 'EOF' > "$TMP/output.txt" 20 | EOF 21 | 22 | diff "$TMP/result.txt" "$TMP/output.txt" 23 | 24 | cat << 'EOF' > "$TMP/expected.json" 25 | { 26 | "type": "string", 27 | "$schema": "http://json-schema.org/draft-06/schema#" 28 | } 29 | EOF 30 | 31 | diff "$TMP/schema.json" "$TMP/expected.json" 32 | -------------------------------------------------------------------------------- /test/lint/fail_lint_only_unknown_verbose.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": "string", 14 | "enum": [ "foo" ] 15 | } 16 | EOF 17 | 18 | "$1" lint "$TMP/schema.json" --only foobarbaz --verbose \ 19 | >"$TMP/stderr.txt" 2>&1 && CODE="$?" || CODE="$?" 20 | test "$CODE" = "1" || exit 1 21 | 22 | cat << EOF > "$TMP/expected.txt" 23 | Only enabling rule: foobarbaz 24 | error: The following linting rule does not exist 25 | at rule foobarbaz 26 | EOF 27 | 28 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 29 | -------------------------------------------------------------------------------- /test/format/pass_check_single_keep_ordering.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "type": 1, 13 | "$schema": "http://json-schema.org/draft-04/schema#" 14 | } 15 | EOF 16 | 17 | "$1" fmt "$TMP/schema.json" --check --keep-ordering >"$TMP/output.txt" 2>&1 18 | 19 | cat << 'EOF' > "$TMP/expected_output.txt" 20 | EOF 21 | 22 | diff "$TMP/output.txt" "$TMP/expected_output.txt" 23 | 24 | cat << 'EOF' > "$TMP/expected.json" 25 | { 26 | "type": 1, 27 | "$schema": "http://json-schema.org/draft-04/schema#" 28 | } 29 | EOF 30 | 31 | diff "$TMP/schema.json" "$TMP/expected.json" 32 | -------------------------------------------------------------------------------- /test/ci/fail_bundle_http_non_200_verbose.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-07/schema#", 13 | "allOf": [ { "$ref": "https://example.com" } ] 14 | } 15 | EOF 16 | 17 | "$1" bundle "$TMP/schema.json" --http --verbose 2> "$TMP/stderr.txt" \ 18 | && CODE="$?" || CODE="$?" 19 | test "$CODE" = "1" || exit 1 20 | 21 | cat << EOF > "$TMP/expected.txt" 22 | Resolving over HTTP: https://example.com 23 | error: Failed to parse the JSON document 24 | at line 1 25 | at column 1 26 | EOF 27 | 28 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 29 | -------------------------------------------------------------------------------- /test/format/pass_check_single_indentation.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": 1 14 | } 15 | EOF 16 | 17 | "$1" fmt "$TMP/schema.json" --check --indentation 4 >"$TMP/output.txt" 2>&1 18 | 19 | cat << 'EOF' > "$TMP/expected_output.txt" 20 | EOF 21 | 22 | diff "$TMP/output.txt" "$TMP/expected_output.txt" 23 | 24 | cat << 'EOF' > "$TMP/expected.json" 25 | { 26 | "$schema": "http://json-schema.org/draft-04/schema#", 27 | "type": 1 28 | } 29 | EOF 30 | 31 | diff "$TMP/schema.json" "$TMP/expected.json" 32 | -------------------------------------------------------------------------------- /test/validate/pass_jsonl_empty_verbose.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "properties": { 14 | "foo": { 15 | "type": "string" 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | touch "$TMP/instance.jsonl" 22 | 23 | "$1" validate "$TMP/schema.json" "$TMP/instance.jsonl" --verbose 2> "$TMP/output.txt" 1>&2 24 | 25 | cat << EOF > "$TMP/expected.txt" 26 | Interpreting input as JSONL: $(realpath "$TMP")/instance.jsonl 27 | warning: The JSONL file is empty 28 | EOF 29 | 30 | diff "$TMP/output.txt" "$TMP/expected.txt" 31 | -------------------------------------------------------------------------------- /test/validate/pass_json_fast.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "$id": "https://example.com", 14 | "properties": { 15 | "foo": { 16 | "type": "string" 17 | } 18 | } 19 | } 20 | EOF 21 | 22 | cat << 'EOF' > "$TMP/instance.json" 23 | { "foo": "bar" } 24 | EOF 25 | 26 | "$1" validate "$TMP/schema.json" "$TMP/instance.json" --fast --json > "$TMP/output.json" 27 | 28 | cat << EOF > "$TMP/expected.json" 29 | { 30 | "valid": true 31 | } 32 | EOF 33 | 34 | diff "$TMP/expected.json" "$TMP/output.json" 35 | -------------------------------------------------------------------------------- /test/lint/pass_lint_ignore_short.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": "string" 14 | } 15 | EOF 16 | 17 | cat << 'EOF' > "$TMP/ignored.json" 18 | { 19 | "$schema": "http://json-schema.org/draft-04/schema#", 20 | "type": "string", 21 | "enum": [ "foo" ] 22 | } 23 | EOF 24 | 25 | "$1" lint "$TMP" -i "$TMP/ignored.json" 26 | 27 | cat << 'EOF' > "$TMP/expected.json" 28 | { 29 | "$schema": "http://json-schema.org/draft-04/schema#", 30 | "type": "string" 31 | } 32 | EOF 33 | 34 | diff "$TMP/schema.json" "$TMP/expected.json" 35 | -------------------------------------------------------------------------------- /test/lint/pass_lint_ignore_long.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": "string" 14 | } 15 | EOF 16 | 17 | cat << 'EOF' > "$TMP/ignored.json" 18 | { 19 | "$schema": "http://json-schema.org/draft-04/schema#", 20 | "type": "string", 21 | "enum": [ "foo" ] 22 | } 23 | EOF 24 | 25 | "$1" lint "$TMP" --ignore "$TMP/ignored.json" 26 | 27 | cat << 'EOF' > "$TMP/expected.json" 28 | { 29 | "$schema": "http://json-schema.org/draft-04/schema#", 30 | "type": "string" 31 | } 32 | EOF 33 | 34 | diff "$TMP/schema.json" "$TMP/expected.json" 35 | -------------------------------------------------------------------------------- /test/validate/pass_benchmark_loop_jsonl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "type": "string" 14 | } 15 | EOF 16 | 17 | cat << 'EOF' > "$TMP/instance.jsonl" 18 | "Hello World!" 19 | "Bonjour tout le monde!" 20 | "" 21 | EOF 22 | 23 | "$1" validate "$TMP/schema.json" "$TMP/instance.jsonl" --benchmark --loop 1000 > "$TMP/output.txt" 24 | 25 | if ! grep -E "/instance\.jsonl\[[0-9]+]: PASS [0-9]+\.[0-9]+ \+- [0-9]+\.[0-9]+ us \([0-9]+\.[0-9]+\)$" "$TMP/output.txt" > /dev/null 26 | then 27 | cat "$TMP/output.txt" >&2 28 | exit 1 29 | fi 30 | -------------------------------------------------------------------------------- /src/logger.h: -------------------------------------------------------------------------------- 1 | #ifndef SOURCEMETA_JSONSCHEMA_CLI_LOGGER_H_ 2 | #define SOURCEMETA_JSONSCHEMA_CLI_LOGGER_H_ 3 | 4 | #include 5 | 6 | #include // std::ofstream 7 | #include // std::cerr 8 | #include // std::ostream 9 | 10 | namespace sourcemeta::jsonschema { 11 | 12 | inline auto LOG_VERBOSE(const sourcemeta::core::Options &options) 13 | -> std::ostream & { 14 | if (options.contains("verbose")) { 15 | return std::cerr; 16 | } 17 | 18 | static std::ofstream null_stream; 19 | return null_stream; 20 | } 21 | 22 | inline auto LOG_WARNING() -> std::ostream & { 23 | std::cerr << "warning: "; 24 | return std::cerr; 25 | } 26 | 27 | } // namespace sourcemeta::jsonschema 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /test/encode/pass_schema_less.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/document.json" 11 | { "version": 2.0 } 12 | EOF 13 | 14 | "$1" encode "$TMP/document.json" "$TMP/output.binpack" > "$TMP/output.txt" 2>&1 15 | xxd "$TMP/output.binpack" > "$TMP/output.hex" 16 | 17 | cat << 'EOF' > "$TMP/expected.txt" 18 | 00000000: 1308 7665 7273 696f 6e37 02 ..version7. 19 | EOF 20 | 21 | cat << 'EOF' > "$TMP/expected-output.txt" 22 | original file size: 19 bytes 23 | encoded file size: 11 bytes 24 | compression ratio: 57% 25 | EOF 26 | 27 | diff "$TMP/expected.txt" "$TMP/output.hex" 28 | diff "$TMP/output.txt" "$TMP/expected-output.txt" 29 | -------------------------------------------------------------------------------- /test/test/fail_no_tests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/test.json" 11 | { 12 | "target": "https://json-schema.org/draft/2020-12/schema" 13 | } 14 | EOF 15 | 16 | "$1" test "$TMP/test.json" 1> "$TMP/output.txt" 2>&1 \ 17 | && CODE="$?" || CODE="$?" 18 | test "$CODE" = "1" || exit 1 19 | 20 | cat << EOF > "$TMP/expected.txt" 21 | $(realpath "$TMP")/test.json: 22 | error: The test document must contain a \`tests\` property 23 | at file path $(realpath "$TMP")/test.json 24 | 25 | Learn more here: https://github.com/sourcemeta/jsonschema/blob/main/docs/test.markdown 26 | EOF 27 | 28 | diff "$TMP/output.txt" "$TMP/expected.txt" 29 | -------------------------------------------------------------------------------- /vendor/core/vendor/jsonschema-draft0/links.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema" : "http://json-schema.org/draft-00/hyper-schema#", 3 | "id" : "http://json-schema.org/draft-00/links#", 4 | "type" : "object", 5 | 6 | "properties" : { 7 | "href" : { 8 | "type" : "string" 9 | }, 10 | 11 | "rel" : { 12 | "type" : "string" 13 | }, 14 | 15 | "method" : { 16 | "type" : "string", 17 | "default" : "GET", 18 | "optional" : true 19 | }, 20 | 21 | "enctype" : { 22 | "type" : "string", 23 | "requires" : "method", 24 | "optional" : true 25 | }, 26 | 27 | "properties" : { 28 | "type" : "object", 29 | "additionalProperties" : {"$ref" : "http://json-schema.org/draft-00/hyper-schema#"}, 30 | "optional" : true 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /vendor/core/vendor/jsonschema-draft1/links.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema" : "http://json-schema.org/draft-01/hyper-schema#", 3 | "id" : "http://json-schema.org/draft-01/links#", 4 | "type" : "object", 5 | 6 | "properties" : { 7 | "href" : { 8 | "type" : "string" 9 | }, 10 | 11 | "rel" : { 12 | "type" : "string" 13 | }, 14 | 15 | "method" : { 16 | "type" : "string", 17 | "default" : "GET", 18 | "optional" : true 19 | }, 20 | 21 | "enctype" : { 22 | "type" : "string", 23 | "requires" : "method", 24 | "optional" : true 25 | }, 26 | 27 | "properties" : { 28 | "type" : "object", 29 | "additionalProperties" : {"$ref" : "http://json-schema.org/draft-01/hyper-schema#"}, 30 | "optional" : true 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /vendor/hydra/vendor/mbedtls/library/ssl_tls13_invasive.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright The Mbed TLS Contributors 3 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 4 | */ 5 | 6 | #ifndef MBEDTLS_SSL_TLS13_INVASIVE_H 7 | #define MBEDTLS_SSL_TLS13_INVASIVE_H 8 | 9 | #include "common.h" 10 | 11 | #if defined(MBEDTLS_SSL_PROTO_TLS1_3) 12 | 13 | #include "psa/crypto.h" 14 | 15 | #if defined(MBEDTLS_TEST_HOOKS) 16 | int mbedtls_ssl_tls13_parse_certificate(mbedtls_ssl_context *ssl, 17 | const unsigned char *buf, 18 | const unsigned char *end); 19 | #endif /* MBEDTLS_TEST_HOOKS */ 20 | 21 | #endif /* MBEDTLS_SSL_PROTO_TLS1_3 */ 22 | 23 | #endif /* MBEDTLS_SSL_TLS13_INVASIVE_H */ 24 | -------------------------------------------------------------------------------- /test/format/pass_yaml.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.yaml" 11 | additionalProperties: false 12 | title: Hello World 13 | EOF 14 | 15 | "$1" fmt "$TMP/schema.yaml" >"$TMP/output.txt" 2>&1 && CODE="$?" || CODE="$?" 16 | test "$CODE" = "1" || exit 1 17 | 18 | cat << EOF > "$TMP/expected.txt" 19 | error: This command does not support YAML input files yet 20 | at file path $(realpath "$TMP/schema.yaml") 21 | EOF 22 | 23 | diff "$TMP/output.txt" "$TMP/expected.txt" 24 | 25 | cat << EOF > "$TMP/expected.yaml" 26 | additionalProperties: false 27 | title: Hello World 28 | EOF 29 | 30 | diff "$TMP/schema.yaml" "$TMP/expected.yaml" 31 | -------------------------------------------------------------------------------- /test/validate/pass_benchmark.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "type": "object", 14 | "properties": { 15 | "foo": { 16 | "type": "string" 17 | } 18 | } 19 | } 20 | EOF 21 | 22 | cat << 'EOF' > "$TMP/instance.json" 23 | { "foo": "bar" } 24 | EOF 25 | 26 | "$1" validate "$TMP/schema.json" "$TMP/instance.json" --benchmark > "$TMP/output.txt" 27 | 28 | if ! grep -E "/instance\.json: PASS [0-9]+\.[0-9]+ \+- 0\.000 us \([0-9]+\.[0-9]+\)$" "$TMP/output.txt" > /dev/null 29 | then 30 | cat "$TMP/output.txt" >&2 31 | exit 1 32 | fi 33 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/c-ares/src/lib/windows_port.c: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * 3 | * Copyright (c) 1998 Massachusetts Institute of Technology 4 | * Copyright (C) Daniel Stenberg 5 | * 6 | * SPDX-License-Identifier: MIT 7 | * 8 | */ 9 | #include "ares_private.h" 10 | 11 | 12 | /* only do the following on windows 13 | */ 14 | #if defined(_WIN32) && !defined(MSDOS) 15 | 16 | # ifdef __WATCOMC__ 17 | /* 18 | * Watcom needs a DllMain() in order to initialise the clib startup code. 19 | */ 20 | BOOL WINAPI DllMain(HINSTANCE hnd, DWORD reason, LPVOID reserved) 21 | { 22 | (void)hnd; 23 | (void)reason; 24 | (void)reserved; 25 | return (TRUE); 26 | } 27 | # endif 28 | 29 | #endif /* WIN32 builds only */ 30 | -------------------------------------------------------------------------------- /test/ci/fail_validate_http_non_200.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-07/schema#", 13 | "allOf": [ { "$ref": "https://example.com" } ] 14 | } 15 | EOF 16 | 17 | cat << 'EOF' > "$TMP/instance.json" 18 | { "type": "string" } 19 | EOF 20 | 21 | "$1" validate "$TMP/schema.json" "$TMP/instance.json" --http 2> "$TMP/stderr.txt" \ 22 | && CODE="$?" || CODE="$?" 23 | test "$CODE" = "1" || exit 1 24 | 25 | cat << EOF > "$TMP/expected.txt" 26 | error: Failed to parse the JSON document 27 | at line 1 28 | at column 1 29 | EOF 30 | 31 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 32 | -------------------------------------------------------------------------------- /test/unknown_option.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -o errexit 3 | set -o nounset 4 | 5 | TMP="$(mktemp -d)" 6 | clean() { rm -rf "$TMP"; } 7 | trap clean EXIT 8 | 9 | cat << 'EOF' > "$TMP/schema.json" 10 | { 11 | "$schema": "https://json-schema.org/draft/2020-12/schema", 12 | "$id": "https://example.com", 13 | "$ref": "#/$defs/string", 14 | "$defs": { 15 | "string": { "type": "string" } 16 | } 17 | } 18 | EOF 19 | 20 | "$1" inspect "$TMP/schema.json" --hello foo > "$TMP/output.txt" 2>&1 \ 21 | && CODE="$?" || CODE="$?" 22 | test "$CODE" = "1" || exit 1 23 | 24 | cat << EOF > "$TMP/expected.txt" 25 | error: Unknown option 26 | at option hello 27 | 28 | Run the \`help\` command for usage information 29 | EOF 30 | 31 | diff "$TMP/output.txt" "$TMP/expected.txt" 32 | -------------------------------------------------------------------------------- /vendor/blaze/src/output/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | sourcemeta_library(NAMESPACE sourcemeta PROJECT blaze NAME output 2 | FOLDER "Blaze/Output" 3 | PRIVATE_HEADERS simple.h trace.h standard.h 4 | SOURCES 5 | output_simple.cc 6 | output_trace.cc 7 | output_standard.cc) 8 | 9 | if(BLAZE_INSTALL) 10 | sourcemeta_library_install(NAMESPACE sourcemeta PROJECT blaze NAME output) 11 | endif() 12 | 13 | target_link_libraries(sourcemeta_blaze_output PUBLIC 14 | sourcemeta::core::json) 15 | target_link_libraries(sourcemeta_blaze_output PUBLIC 16 | sourcemeta::core::jsonpointer) 17 | target_link_libraries(sourcemeta_blaze_output PUBLIC 18 | sourcemeta::core::jsonschema) 19 | 20 | target_link_libraries(sourcemeta_blaze_output PUBLIC 21 | sourcemeta::blaze::evaluator) 22 | -------------------------------------------------------------------------------- /test/compile/pass_minify.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$id": "https://example.com", 13 | "$schema": "https://json-schema.org/draft/2020-12/schema", 14 | "additionalProperties": { 15 | "type": "string" 16 | } 17 | } 18 | EOF 19 | 20 | "$1" compile --minify "$TMP/schema.json" > "$TMP/template.json" 21 | 22 | cat << 'EOF' > "$TMP/expected.json" 23 | [false,true,["","https://example.com"],[[61,"/additionalProperties","","#/additionalProperties",2,[0],[[11,"/type","","#/additionalProperties/type",2,[8,4]],[46,"","","#/additionalProperties",2,[0]]]]]] 24 | EOF 25 | 26 | diff "$TMP/template.json" "$TMP/expected.json" 27 | -------------------------------------------------------------------------------- /test/flag_with_value.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -o errexit 3 | set -o nounset 4 | 5 | TMP="$(mktemp -d)" 6 | clean() { rm -rf "$TMP"; } 7 | trap clean EXIT 8 | 9 | cat << 'EOF' > "$TMP/schema.json" 10 | { 11 | "$schema": "https://json-schema.org/draft/2020-12/schema", 12 | "$id": "https://example.com", 13 | "$ref": "#/$defs/string", 14 | "$defs": { 15 | "string": { "type": "string" } 16 | } 17 | } 18 | EOF 19 | 20 | "$1" inspect "$TMP/schema.json" --json=foo > "$TMP/output.txt" 2>&1 \ 21 | && CODE="$?" || CODE="$?" 22 | test "$CODE" = "1" || exit 1 23 | 24 | cat << EOF > "$TMP/expected.txt" 25 | error: This flag cannot take a value 26 | at option json 27 | 28 | Run the \`help\` command for usage information 29 | EOF 30 | 31 | diff "$TMP/output.txt" "$TMP/expected.txt" 32 | -------------------------------------------------------------------------------- /vendor/jsonbinpack/src/runtime/encoder_number.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include // assert 5 | #include // std::uint64_t 6 | 7 | namespace sourcemeta::jsonbinpack { 8 | 9 | auto Encoder::DOUBLE_VARINT_TUPLE(const sourcemeta::core::JSON &document, 10 | const struct DOUBLE_VARINT_TUPLE &) -> void { 11 | assert(document.is_real()); 12 | const auto value{document.to_real()}; 13 | std::uint64_t point_position; 14 | const std::int64_t integral{ 15 | real_digits(value, &point_position)}; 16 | this->put_varint_zigzag(integral); 17 | this->put_varint(point_position); 18 | } 19 | 20 | } // namespace sourcemeta::jsonbinpack 21 | -------------------------------------------------------------------------------- /test/bundle/fail_no_schema.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | "$1" bundle 2>"$TMP/stderr.txt" && CODE="$?" || CODE="$?" 11 | test "$CODE" = "1" || exit 1 12 | 13 | cat << 'EOF' > "$TMP/expected.txt" 14 | error: This command expects a path to a schema 15 | 16 | For example: jsonschema bundle path/to/schema.json 17 | EOF 18 | 19 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 20 | 21 | # JSON error 22 | "$1" bundle --json > "$TMP/stdout.txt" 2>&1 && CODE="$?" || CODE="$?" 23 | test "$CODE" = "1" || exit 1 24 | 25 | cat << 'EOF' > "$TMP/expected.txt" 26 | { 27 | "error": "This command expects a path to a schema" 28 | } 29 | EOF 30 | 31 | diff "$TMP/stdout.txt" "$TMP/expected.txt" 32 | -------------------------------------------------------------------------------- /test/compile/fail_no_schema.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | "$1" compile 2>"$TMP/stderr.txt" && CODE="$?" || CODE="$?" 11 | test "$CODE" = "1" || exit 1 12 | 13 | cat << 'EOF' > "$TMP/expected.txt" 14 | error: This command expects a path to a schema 15 | 16 | For example: jsonschema compile path/to/schema.json 17 | EOF 18 | 19 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 20 | 21 | # JSON error 22 | "$1" compile --json > "$TMP/stdout.txt" 2>&1 && CODE="$?" || CODE="$?" 23 | test "$CODE" = "1" || exit 1 24 | 25 | cat << 'EOF' > "$TMP/expected.txt" 26 | { 27 | "error": "This command expects a path to a schema" 28 | } 29 | EOF 30 | 31 | diff "$TMP/stdout.txt" "$TMP/expected.txt" 32 | -------------------------------------------------------------------------------- /test/inspect/fail_no_schema.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | "$1" inspect 2>"$TMP/stderr.txt" && CODE="$?" || CODE="$?" 11 | test "$CODE" = "1" || exit 1 12 | 13 | cat << 'EOF' > "$TMP/expected.txt" 14 | error: This command expects a path to a schema 15 | 16 | For example: jsonschema inspect path/to/schema.json 17 | EOF 18 | 19 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 20 | 21 | # JSON error 22 | "$1" inspect --json > "$TMP/stdout.txt" 2>&1 && CODE="$?" || CODE="$?" 23 | test "$CODE" = "1" || exit 1 24 | 25 | cat << 'EOF' > "$TMP/expected.txt" 26 | { 27 | "error": "This command expects a path to a schema" 28 | } 29 | EOF 30 | 31 | diff "$TMP/stdout.txt" "$TMP/expected.txt" 32 | -------------------------------------------------------------------------------- /test/validate/pass_benchmark_loop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "type": "object", 14 | "properties": { 15 | "foo": { 16 | "type": "string" 17 | } 18 | } 19 | } 20 | EOF 21 | 22 | cat << 'EOF' > "$TMP/instance.json" 23 | { "foo": "bar" } 24 | EOF 25 | 26 | "$1" validate "$TMP/schema.json" "$TMP/instance.json" --benchmark --loop 1000 > "$TMP/output.txt" 27 | 28 | if ! grep -E "/instance\.json: PASS [0-9]+\.[0-9]+ \+- [0-9]+\.[0-9]+ us \([0-9]+\.[0-9]+\)$" "$TMP/output.txt" > /dev/null 29 | then 30 | cat "$TMP/output.txt" >&2 31 | exit 1 32 | fi 33 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/zlib/gzclose.c: -------------------------------------------------------------------------------- 1 | /* gzclose.c -- zlib gzclose() function 2 | * Copyright (C) 2004, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "gzguts.h" 7 | 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. 9 | That way the other gzclose functions can be used instead to avoid linking in 10 | unneeded compression or decompression routines. */ 11 | int ZEXPORT gzclose(gzFile file) { 12 | #ifndef NO_GZCOMPRESS 13 | gz_statep state; 14 | 15 | if (file == NULL) 16 | return Z_STREAM_ERROR; 17 | state = (gz_statep)file; 18 | 19 | return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); 20 | #else 21 | return gzclose_r(file); 22 | #endif 23 | } 24 | -------------------------------------------------------------------------------- /test/format/pass_check_single_verbose.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": 1 14 | } 15 | EOF 16 | 17 | "$1" fmt "$TMP/schema.json" --check --verbose >"$TMP/output.txt" 2>&1 18 | 19 | cat << EOF > "$TMP/expected_output.txt" 20 | Checking: $(realpath "$TMP")/schema.json 21 | ok: $(realpath "$TMP")/schema.json 22 | EOF 23 | 24 | diff "$TMP/output.txt" "$TMP/expected_output.txt" 25 | 26 | cat << 'EOF' > "$TMP/expected.json" 27 | { 28 | "$schema": "http://json-schema.org/draft-04/schema#", 29 | "type": 1 30 | } 31 | EOF 32 | 33 | diff "$TMP/schema.json" "$TMP/expected.json" 34 | -------------------------------------------------------------------------------- /test/validate/pass_no_identifier_half_ref.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | # This schema has no identifier 11 | cat << 'EOF' > "$TMP/schema.json" 12 | { 13 | "$schema": "https://json-schema.org/draft/2020-12/schema", 14 | "$ref": "./schemas/other.json" 15 | } 16 | EOF 17 | 18 | mkdir -p "$TMP/schemas" 19 | 20 | # But the target does 21 | cat << 'EOF' > "$TMP/schemas/other.json" 22 | { 23 | "$id": "https://example.com", 24 | "$schema": "https://json-schema.org/draft/2020-12/schema", 25 | "type": "string" 26 | } 27 | EOF 28 | 29 | cat << 'EOF' > "$TMP/instance.json" 30 | "foo bar" 31 | EOF 32 | 33 | "$1" validate "$TMP/schema.json" --resolve "$TMP/schemas" "$TMP/instance.json" 34 | -------------------------------------------------------------------------------- /test/option_without_value.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -o errexit 3 | set -o nounset 4 | 5 | TMP="$(mktemp -d)" 6 | clean() { rm -rf "$TMP"; } 7 | trap clean EXIT 8 | 9 | cat << 'EOF' > "$TMP/schema.json" 10 | { 11 | "$schema": "https://json-schema.org/draft/2020-12/schema", 12 | "$id": "https://example.com", 13 | "$ref": "#/$defs/string", 14 | "$defs": { 15 | "string": { "type": "string" } 16 | } 17 | } 18 | EOF 19 | 20 | "$1" inspect "$TMP/schema.json" --default-dialect > "$TMP/output.txt" 2>&1 \ 21 | && CODE="$?" || CODE="$?" 22 | test "$CODE" = "1" || exit 1 23 | 24 | cat << EOF > "$TMP/expected.txt" 25 | error: This option must take a value 26 | at option default-dialect 27 | 28 | Run the \`help\` command for usage information 29 | EOF 30 | 31 | diff "$TMP/output.txt" "$TMP/expected.txt" 32 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/mbedtls/library/md_psa.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Translation between MD and PSA identifiers (algorithms, errors). 3 | * 4 | * Note: this internal module will go away when everything becomes based on 5 | * PSA Crypto; it is a helper for the transition period. 6 | * 7 | * Copyright The Mbed TLS Contributors 8 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 9 | */ 10 | #ifndef MBEDTLS_MD_PSA_H 11 | #define MBEDTLS_MD_PSA_H 12 | 13 | #include "common.h" 14 | 15 | #include "mbedtls/md.h" 16 | #include "psa/crypto.h" 17 | 18 | /** Convert PSA status to MD error code. 19 | * 20 | * \param status PSA status. 21 | * 22 | * \return The corresponding MD error code, 23 | */ 24 | int mbedtls_md_error_from_psa(psa_status_t status); 25 | 26 | #endif /* MBEDTLS_MD_PSA_H */ 27 | -------------------------------------------------------------------------------- /test/format/pass_single_keep_ordering.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "additionalProperties": false, 13 | "title": "Hello World", 14 | "properties": {"foo": {}, "bar": {}} 15 | } 16 | EOF 17 | 18 | "$1" fmt --keep-ordering "$TMP/schema.json" >"$TMP/output.txt" 2>&1 19 | 20 | cat << 'EOF' > "$TMP/expected_output.txt" 21 | EOF 22 | 23 | diff "$TMP/output.txt" "$TMP/expected_output.txt" 24 | 25 | cat << 'EOF' > "$TMP/expected.json" 26 | { 27 | "additionalProperties": false, 28 | "title": "Hello World", 29 | "properties": { 30 | "foo": {}, 31 | "bar": {} 32 | } 33 | } 34 | EOF 35 | 36 | diff "$TMP/schema.json" "$TMP/expected.json" 37 | -------------------------------------------------------------------------------- /test/lint/fail_lint_with_id.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "$id": "https://example.com", 14 | "additionalProperties": true 15 | } 16 | EOF 17 | 18 | cd "$TMP" 19 | "$1" lint "$TMP/schema.json" >"$TMP/stderr.txt" 2>&1 && CODE="$?" || CODE="$?" 20 | test "$CODE" = "2" || exit 1 21 | 22 | cat << 'EOF' > "$TMP/expected.txt" 23 | schema.json:4:3: 24 | Setting the `additionalProperties` keyword to the true schema does not add any further constraint (additional_properties_default) 25 | at location "/additionalProperties" 26 | EOF 27 | 28 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 29 | -------------------------------------------------------------------------------- /test/lint/fail_lint_non_schema.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { "foo": "bar" } 12 | EOF 13 | 14 | "$1" lint "$TMP/schema.json" >"$TMP/output.txt" 2>&1 && CODE="$?" || CODE="$?" 15 | test "$CODE" = "1" || exit 1 16 | 17 | cat << EOF > "$TMP/expected.txt" 18 | error: Could not determine the base dialect of the schema 19 | at file path $(realpath "$TMP/schema.json") 20 | 21 | Are you sure the input is a valid JSON Schema and its base dialect is known? 22 | If the input does not declare the \`\$schema\` keyword, you might want to 23 | explicitly declare a default dialect using \`--default-dialect/-d\` 24 | EOF 25 | 26 | diff "$TMP/output.txt" "$TMP/expected.txt" 27 | -------------------------------------------------------------------------------- /test/lint/pass_lint_fix_json.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-06/schema#", 13 | "type": "string", 14 | "enum": [ "foo" ] 15 | } 16 | EOF 17 | 18 | "$1" lint "$TMP/schema.json" --fix --json >"$TMP/output.json" 2>&1 19 | 20 | cat << EOF > "$TMP/expected.json" 21 | { 22 | "valid": true, 23 | "health": null, 24 | "errors": [] 25 | } 26 | EOF 27 | 28 | diff "$TMP/output.json" "$TMP/expected.json" 29 | 30 | cat << 'EOF' > "$TMP/expected_fixed.json" 31 | { 32 | "$schema": "http://json-schema.org/draft-06/schema#", 33 | "const": "foo" 34 | } 35 | EOF 36 | 37 | diff "$TMP/schema.json" "$TMP/expected_fixed.json" 38 | -------------------------------------------------------------------------------- /test/validate/pass_jsonl_json.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "properties": { 14 | "foo": { 15 | "type": "string" 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | cat << 'EOF' > "$TMP/instance.jsonl" 22 | { "foo": "first" } 23 | { "foo": "second" } 24 | { "foo": "third" } 25 | EOF 26 | 27 | "$1" validate "$TMP/schema.json" "$TMP/instance.jsonl" --json > "$TMP/output.json" 2>&1 28 | 29 | cat << EOF > "$TMP/expected.json" 30 | { 31 | "valid": true 32 | } 33 | { 34 | "valid": true 35 | } 36 | { 37 | "valid": true 38 | } 39 | EOF 40 | 41 | diff "$TMP/output.json" "$TMP/expected.json" 42 | -------------------------------------------------------------------------------- /test/validate/pass_yaml_multi_json.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "properties": { 14 | "foo": { 15 | "type": "string" 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | cat << 'EOF' > "$TMP/instance.yaml" 22 | --- 23 | foo: first 24 | --- 25 | foo: second 26 | --- 27 | foo: third 28 | EOF 29 | 30 | "$1" validate "$TMP/schema.json" "$TMP/instance.yaml" --json > "$TMP/output.json" 2>&1 31 | 32 | cat << EOF > "$TMP/expected.json" 33 | { 34 | "valid": true 35 | } 36 | { 37 | "valid": true 38 | } 39 | { 40 | "valid": true 41 | } 42 | EOF 43 | 44 | diff "$TMP/output.json" "$TMP/expected.json" 45 | -------------------------------------------------------------------------------- /test/compile/pass_fast.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$id": "https://example.com", 13 | "$schema": "https://json-schema.org/draft/2020-12/schema", 14 | "additionalProperties": { 15 | "type": "string" 16 | } 17 | } 18 | EOF 19 | 20 | "$1" compile "$TMP/schema.json" --fast > "$TMP/template.json" 21 | 22 | cat << 'EOF' > "$TMP/expected.json" 23 | [ 24 | false, 25 | false, 26 | [ "", "https://example.com" ], 27 | [ 28 | [ 29 | 71, 30 | "/additionalProperties", 31 | "", 32 | "#/additionalProperties", 33 | 2, 34 | [ 8, 4 ] 35 | ] 36 | ] 37 | ] 38 | EOF 39 | 40 | diff "$TMP/template.json" "$TMP/expected.json" 41 | -------------------------------------------------------------------------------- /test/lint/fail_lint_non_schema_fix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { "foo": "bar" } 12 | EOF 13 | 14 | "$1" lint "$TMP/schema.json" --fix >"$TMP/output.txt" 2>&1 && CODE="$?" || CODE="$?" 15 | test "$CODE" = "1" || exit 1 16 | 17 | cat << EOF > "$TMP/expected.txt" 18 | error: Could not determine the base dialect of the schema 19 | at file path $(realpath "$TMP/schema.json") 20 | 21 | Are you sure the input is a valid JSON Schema and its base dialect is known? 22 | If the input does not declare the \`\$schema\` keyword, you might want to 23 | explicitly declare a default dialect using \`--default-dialect/-d\` 24 | EOF 25 | 26 | diff "$TMP/output.txt" "$TMP/expected.txt" 27 | -------------------------------------------------------------------------------- /test/metaschema/fail_directory_non_resolved.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | mkdir "$TMP/schemas" 11 | 12 | cat << 'EOF' > "$TMP/schemas/schema_1.json" 13 | { 14 | "$schema": "http://example.com", 15 | "type": "string" 16 | } 17 | EOF 18 | 19 | "$1" metaschema "$TMP/schemas" > "$TMP/stderr.txt" 2>&1 && CODE="$?" || CODE="$?" 20 | test "$CODE" = "1" || exit 1 21 | 22 | cat << EOF > "$TMP/expected.txt" 23 | error: Could not resolve the metaschema of the schema 24 | at identifier http://example.com 25 | at file path $(realpath "$TMP")/schemas/schema_1.json 26 | 27 | This is likely because you forgot to import such schema using \`--resolve/-r\` 28 | EOF 29 | 30 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 31 | -------------------------------------------------------------------------------- /test/validate/fail_benchmark_zero.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "type": "object", 14 | "properties": { 15 | "foo": { 16 | "type": "string" 17 | } 18 | } 19 | } 20 | EOF 21 | 22 | cat << 'EOF' > "$TMP/instance.json" 23 | { "foo": "bar" } 24 | EOF 25 | 26 | "$1" validate "$TMP/schema.json" "$TMP/instance.json" --benchmark --loop 0 > "$TMP/output.txt" 2>&1 \ 27 | && EXIT_CODE="$?" || EXIT_CODE="$?" 28 | test "$EXIT_CODE" = "1" || exit 1 29 | 30 | cat << EOF > "$TMP/expected.txt" 31 | error: The loop number cannot be zero 32 | EOF 33 | 34 | diff "$TMP/output.txt" "$TMP/expected.txt" 35 | -------------------------------------------------------------------------------- /vendor/core/vendor/googlebenchmark/src/benchmark_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "benchmark/benchmark.h" 16 | 17 | BENCHMARK_EXPORT int main(int, char**); 18 | BENCHMARK_MAIN(); 19 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/mbedtls/library/version.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Version information 3 | * 4 | * Copyright The Mbed TLS Contributors 5 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 6 | */ 7 | 8 | #include "common.h" 9 | 10 | #if defined(MBEDTLS_VERSION_C) 11 | 12 | #include "mbedtls/version.h" 13 | #include 14 | 15 | unsigned int mbedtls_version_get_number(void) 16 | { 17 | return MBEDTLS_VERSION_NUMBER; 18 | } 19 | 20 | void mbedtls_version_get_string(char *string) 21 | { 22 | memcpy(string, MBEDTLS_VERSION_STRING, 23 | sizeof(MBEDTLS_VERSION_STRING)); 24 | } 25 | 26 | void mbedtls_version_get_string_full(char *string) 27 | { 28 | memcpy(string, MBEDTLS_VERSION_STRING_FULL, 29 | sizeof(MBEDTLS_VERSION_STRING_FULL)); 30 | } 31 | 32 | #endif /* MBEDTLS_VERSION_C */ 33 | -------------------------------------------------------------------------------- /test/ci/fail_validate_http_non_200_verbose.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-07/schema#", 13 | "allOf": [ { "$ref": "https://example.com" } ] 14 | } 15 | EOF 16 | 17 | cat << 'EOF' > "$TMP/instance.json" 18 | { "type": "string" } 19 | EOF 20 | 21 | "$1" validate "$TMP/schema.json" "$TMP/instance.json" --http --verbose 2> "$TMP/stderr.txt" \ 22 | && CODE="$?" || CODE="$?" 23 | test "$CODE" = "1" || exit 1 24 | 25 | cat << EOF > "$TMP/expected.txt" 26 | Resolving over HTTP: https://example.com 27 | error: Failed to parse the JSON document 28 | at line 1 29 | at column 1 30 | EOF 31 | 32 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 33 | -------------------------------------------------------------------------------- /test/format/fail_check_single_json.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | mkdir -p "$TMP/this/is/a/very/very/very/long/path" 11 | 12 | cat << 'EOF' > "$TMP/this/is/a/very/very/very/long/path/schema.json" 13 | { 14 | "type": 1, 15 | "$schema": "http://json-schema.org/draft-04/schema#" 16 | } 17 | EOF 18 | 19 | "$1" fmt "$TMP/this/is/a/very/very/very/long/path/schema.json" \ 20 | --check --json >"$TMP/output.json" 2>&1 && CODE="$?" || CODE="$?" 21 | test "$CODE" = "2" || exit 1 22 | 23 | cat << EOF > "$TMP/expected.json" 24 | { 25 | "valid": false, 26 | "errors": [ 27 | "$(realpath "$TMP")/this/is/a/very/very/very/long/path/schema.json" 28 | ] 29 | } 30 | EOF 31 | 32 | diff "$TMP/output.json" "$TMP/expected.json" 33 | -------------------------------------------------------------------------------- /test/metaschema/pass_cwd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema_1.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": "string" 14 | } 15 | EOF 16 | 17 | cat << 'EOF' > "$TMP/schema_2.json" 18 | { 19 | "$schema": "http://json-schema.org/draft-04/schema#", 20 | "type": "object" 21 | } 22 | EOF 23 | 24 | cd "$TMP" 25 | "$1" metaschema --verbose > "$TMP/output.txt" 2>&1 26 | 27 | cat << EOF > "$TMP/expected.txt" 28 | ok: $(realpath "$TMP")/schema_1.json 29 | matches http://json-schema.org/draft-04/schema# 30 | ok: $(realpath "$TMP")/schema_2.json 31 | matches http://json-schema.org/draft-04/schema# 32 | EOF 33 | 34 | diff "$TMP/output.txt" "$TMP/expected.txt" 35 | -------------------------------------------------------------------------------- /test/ci/pass_validate_json_ref_yaml_http.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | mkdir "$TMP/server" 8 | npx --yes http-server --version 9 | npx --yes http-server "$TMP/server" --port 5889 & 10 | SERVER_PID="$!" 11 | 12 | clean() { 13 | kill "$SERVER_PID" 14 | rm -rf "$TMP" 15 | } 16 | 17 | trap clean EXIT 18 | 19 | cat << 'EOF' > "$TMP/server/schema.yaml" 20 | $schema: https://json-schema.org/draft/2020-12/schema 21 | type: string 22 | EOF 23 | 24 | cat << 'EOF' > "$TMP/schema.json" 25 | { 26 | "$schema": "https://json-schema.org/draft/2020-12/schema", 27 | "$ref": "http://localhost:5889/schema.yaml" 28 | } 29 | EOF 30 | 31 | cat << 'EOF' > "$TMP/instance.json" 32 | "foo" 33 | EOF 34 | 35 | sleep 3 36 | 37 | "$1" validate "$TMP/schema.json" --http "$TMP/instance.json" --verbose 38 | -------------------------------------------------------------------------------- /test/test/fail_tests_non_array.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/test.json" 11 | { 12 | "target": "https://json-schema.org/draft/2020-12/schema", 13 | "tests": { 14 | "valid": true, 15 | "data": {} 16 | } 17 | } 18 | EOF 19 | 20 | "$1" test "$TMP/test.json" 1> "$TMP/output.txt" 2>&1 \ 21 | && CODE="$?" || CODE="$?" 22 | test "$CODE" = "1" || exit 1 23 | 24 | cat << EOF > "$TMP/expected.txt" 25 | $(realpath "$TMP")/test.json: 26 | error: The test document \`tests\` property must be an array 27 | at file path $(realpath "$TMP")/test.json 28 | 29 | Learn more here: https://github.com/sourcemeta/jsonschema/blob/main/docs/test.markdown 30 | EOF 31 | 32 | diff "$TMP/output.txt" "$TMP/expected.txt" 33 | -------------------------------------------------------------------------------- /test/test/pass_file_target_without_resolve.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": "string" 14 | } 15 | EOF 16 | 17 | cat << 'EOF' > "$TMP/test.json" 18 | { 19 | "target": "./schema.json", 20 | "$comment": "A random comment", 21 | "tests": [ 22 | { 23 | "valid": true, 24 | "data": "foo" 25 | }, 26 | { 27 | "valid": false, 28 | "data": 1 29 | } 30 | ] 31 | } 32 | EOF 33 | 34 | "$1" test "$TMP/test.json" 1> "$TMP/output.txt" 2>&1 35 | 36 | cat << EOF > "$TMP/expected.txt" 37 | $(realpath "$TMP")/test.json: PASS 2/2 38 | EOF 39 | 40 | diff "$TMP/output.txt" "$TMP/expected.txt" 41 | -------------------------------------------------------------------------------- /test/validate/fail_2020_12_fast.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "type": "object", 14 | "properties": { 15 | "foo": { 16 | "type": "string" 17 | } 18 | } 19 | } 20 | EOF 21 | 22 | cat << 'EOF' > "$TMP/instance.json" 23 | { "foo": 1 } 24 | EOF 25 | 26 | "$1" validate "$TMP/schema.json" "$TMP/instance.json" --fast 2> "$TMP/stderr.txt" \ 27 | && EXIT_CODE="$?" || EXIT_CODE="$?" 28 | test "$EXIT_CODE" = "2" || exit 1 29 | 30 | cat << EOF > "$TMP/expected.txt" 31 | fail: $(realpath "$TMP")/instance.json 32 | error: Schema validation failure 33 | EOF 34 | 35 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 36 | -------------------------------------------------------------------------------- /test/validate/fail_invalid_config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "type": "string" 13 | } 14 | EOF 15 | 16 | cat << 'EOF' > "$TMP/instance.json" 17 | "foo" 18 | EOF 19 | 20 | cat << 'EOF' > "$TMP/jsonschema.json" 21 | { 22 | "defaultDialect": 1 23 | } 24 | EOF 25 | 26 | "$1" validate "$TMP/schema.json" "$TMP/instance.json" >"$TMP/output.txt" 2>&1 \ 27 | && EXIT_CODE="$?" || EXIT_CODE="$?" 28 | test "$EXIT_CODE" = "1" || exit 1 29 | 30 | cat << EOF > "$TMP/expected.txt" 31 | error: The defaultDialect property must be a string 32 | at file path $(realpath "$TMP")/jsonschema.json 33 | at location "/defaultDialect" 34 | EOF 35 | 36 | diff "$TMP/output.txt" "$TMP/expected.txt" 37 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/include/cpr/ssl_ctx.h: -------------------------------------------------------------------------------- 1 | #ifndef CPR_SSL_CTX_H 2 | #define CPR_SSL_CTX_H 3 | 4 | #include "cpr/ssl_options.h" 5 | #include 6 | 7 | #if SUPPORT_CURLOPT_SSL_CTX_FUNCTION 8 | 9 | namespace cpr { 10 | 11 | /** 12 | * This callback function loads a CA certificate from raw_cert_buf and gets called by libcurl 13 | * just before the initialization of an SSL connection. 14 | * The raw_cert_buf argument is set with the CURLOPT_SSL_CTX_DATA option and has to be a nul 15 | * terminated buffer. 16 | * 17 | * Sources: https://curl.se/libcurl/c/CURLOPT_SSL_CTX_FUNCTION.html 18 | * https://curl.se/libcurl/c/CURLOPT_SSL_CTX_DATA.html 19 | */ 20 | CURLcode sslctx_function_load_ca_cert_from_buffer(CURL* curl, void* sslctx, void* raw_cert_buf); 21 | 22 | } // Namespace cpr 23 | 24 | #endif 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /test/format/pass_default_dialect.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "additionalProperties": false, 13 | "title": "Hello World", 14 | "properties": {"foo": {}, "bar": {}} 15 | } 16 | EOF 17 | 18 | "$1" fmt "$TMP/schema.json" --default-dialect "https://json-schema.org/draft/2020-12/schema" >"$TMP/output.txt" 2>&1 19 | 20 | cat << 'EOF' > "$TMP/expected_output.txt" 21 | EOF 22 | 23 | diff "$TMP/output.txt" "$TMP/expected_output.txt" 24 | 25 | cat << 'EOF' > "$TMP/expected.json" 26 | { 27 | "title": "Hello World", 28 | "properties": { 29 | "foo": {}, 30 | "bar": {} 31 | }, 32 | "additionalProperties": false 33 | } 34 | EOF 35 | 36 | diff "$TMP/schema.json" "$TMP/expected.json" 37 | -------------------------------------------------------------------------------- /test/lint/pass_lint_default_fix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-06/schema#", 13 | "properties": { 14 | "foo": { 15 | "type": "string", 16 | "default": 1 17 | } 18 | } 19 | } 20 | EOF 21 | 22 | "$1" lint "$TMP/schema.json" --fix > "$TMP/result.txt" 2>&1 23 | 24 | cat << 'EOF' > "$TMP/output.txt" 25 | EOF 26 | 27 | diff "$TMP/result.txt" "$TMP/output.txt" 28 | 29 | cat << 'EOF' > "$TMP/expected.json" 30 | { 31 | "$schema": "http://json-schema.org/draft-06/schema#", 32 | "properties": { 33 | "foo": { 34 | "type": "string" 35 | } 36 | } 37 | } 38 | EOF 39 | 40 | diff "$TMP/schema.json" "$TMP/expected.json" 41 | -------------------------------------------------------------------------------- /test/validate/pass_verbose.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "properties": { 14 | "foo": { 15 | "type": "string" 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | cat << 'EOF' > "$TMP/instance.json" 22 | { "foo": "bar" } 23 | EOF 24 | 25 | "$1" validate "$TMP/schema.json" "$TMP/instance.json" --verbose 2> "$TMP/stderr.txt" 26 | 27 | cat << EOF > "$TMP/expected.txt" 28 | ok: $(realpath "$TMP")/instance.json 29 | matches $(realpath "$TMP")/schema.json 30 | annotation: "foo" 31 | at instance location "" (line 1, column 1) 32 | at evaluate path "/properties" 33 | EOF 34 | 35 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 36 | -------------------------------------------------------------------------------- /vendor/core/vendor/jsonschema-draft2/links.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema" : "http://json-schema.org/draft-02/hyper-schema#", 3 | "id" : "http://json-schema.org/draft-02/links#", 4 | "type" : "object", 5 | 6 | "properties" : { 7 | "href" : { 8 | "type" : "string" 9 | }, 10 | 11 | "rel" : { 12 | "type" : "string" 13 | }, 14 | 15 | "targetSchema" : {"$ref" : "http://json-schema.org/draft-02/hyper-schema#"}, 16 | 17 | "method" : { 18 | "type" : "string", 19 | "default" : "GET", 20 | "optional" : true 21 | }, 22 | 23 | "enctype" : { 24 | "type" : "string", 25 | "requires" : "method", 26 | "optional" : true 27 | }, 28 | 29 | "properties" : { 30 | "type" : "object", 31 | "additionalProperties" : {"$ref" : "http://json-schema.org/draft-02/hyper-schema#"}, 32 | "optional" : true 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /test/metaschema/pass_2020_12_default_dialect_config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "type": "string", 13 | "$defs": { 14 | "foo": { 15 | "type": [ "string", "null" ] 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | cat << 'EOF' > "$TMP/jsonschema.json" 22 | { 23 | "defaultDialect": "https://json-schema.org/draft/2020-12/schema" 24 | } 25 | EOF 26 | 27 | "$1" metaschema --verbose "$TMP/schema.json" 2> "$TMP/output.txt" 28 | 29 | cat << EOF > "$TMP/expected.txt" 30 | Using configuration file: $(realpath "$TMP")/jsonschema.json 31 | ok: $(realpath "$TMP")/schema.json 32 | matches https://json-schema.org/draft/2020-12/schema 33 | EOF 34 | 35 | diff "$TMP/output.txt" "$TMP/expected.txt" 36 | -------------------------------------------------------------------------------- /test/validate/pass_directory_ignore.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": "object", 14 | "properties": { 15 | "name": { 16 | "type": "string" 17 | } 18 | } 19 | } 20 | EOF 21 | 22 | mkdir -p "$TMP/instances/drafts" 23 | 24 | cat << 'EOF' > "$TMP/instances/instance_1.json" 25 | { "name": "Alice" } 26 | EOF 27 | 28 | cat << 'EOF' > "$TMP/instances/drafts/invalid.json" 29 | { "name": 123 } 30 | EOF 31 | 32 | "$1" validate "$TMP/schema.json" "$TMP/instances" --ignore "$TMP/instances/drafts" 2> "$TMP/stderr.txt" 33 | 34 | cat << 'EOF' > "$TMP/expected.txt" 35 | EOF 36 | 37 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 38 | -------------------------------------------------------------------------------- /test/validate/pass_with_invalid_template.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "properties": { 14 | "foo": { 15 | "type": "string" 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | cat << 'EOF' > "$TMP/instance.json" 22 | { "foo": "bar" } 23 | EOF 24 | 25 | cat << 'EOF' > "$TMP/template.json" 26 | { "foo": 1 } 27 | EOF 28 | 29 | "$1" validate "$TMP/schema.json" "$TMP/instance.json" \ 30 | --template "$TMP/template.json" 2> "$TMP/stderr.txt" 31 | 32 | cat << EOF > "$TMP/expected.txt" 33 | warning: Failed to parse pre-compiled schema template. Compiling from scratch 34 | EOF 35 | 36 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 37 | -------------------------------------------------------------------------------- /test/format/fail_check_single.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "type": 1, 13 | "$schema": "http://json-schema.org/draft-04/schema#" 14 | } 15 | EOF 16 | 17 | "$1" fmt "$TMP/schema.json" --check >"$TMP/output.txt" 2>&1 && CODE="$?" || CODE="$?" 18 | test "$CODE" = "2" || exit 1 19 | 20 | cat << EOF > "$TMP/expected.txt" 21 | fail: $(realpath "$TMP")/schema.json 22 | 23 | Run the \`fmt\` command without \`--check/-c\` to fix the formatting 24 | EOF 25 | 26 | diff "$TMP/output.txt" "$TMP/expected.txt" 27 | 28 | cat << 'EOF' > "$TMP/expected.json" 29 | { 30 | "type": 1, 31 | "$schema": "http://json-schema.org/draft-04/schema#" 32 | } 33 | EOF 34 | 35 | diff "$TMP/schema.json" "$TMP/expected.json" 36 | -------------------------------------------------------------------------------- /test/lint/pass_lint_examples_fix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-06/schema#", 13 | "properties": { 14 | "foo": { 15 | "type": "string", 16 | "examples": [ 1, 2, 3 ] 17 | } 18 | } 19 | } 20 | EOF 21 | 22 | "$1" lint "$TMP/schema.json" --fix > "$TMP/result.txt" 2>&1 23 | 24 | cat << 'EOF' > "$TMP/output.txt" 25 | EOF 26 | 27 | diff "$TMP/result.txt" "$TMP/output.txt" 28 | 29 | cat << 'EOF' > "$TMP/expected.json" 30 | { 31 | "$schema": "http://json-schema.org/draft-06/schema#", 32 | "properties": { 33 | "foo": { 34 | "type": "string" 35 | } 36 | } 37 | } 38 | EOF 39 | 40 | diff "$TMP/schema.json" "$TMP/expected.json" 41 | -------------------------------------------------------------------------------- /test/validate/fail_benchmark.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "type": "object", 14 | "properties": { 15 | "foo": { 16 | "type": "string" 17 | } 18 | } 19 | } 20 | EOF 21 | 22 | cat << 'EOF' > "$TMP/instance.json" 23 | { "foo": 1 } 24 | EOF 25 | 26 | "$1" validate "$TMP/schema.json" "$TMP/instance.json" --benchmark > "$TMP/output.txt" 2>&1 \ 27 | && EXIT_CODE="$?" || EXIT_CODE="$?" 28 | test "$EXIT_CODE" = "2" || exit 1 29 | 30 | if ! grep -E "/instance\.json: FAIL [0-9]+\.[0-9]+ \+- [0-9]+\.[0-9]+ us \([0-9]+\.[0-9]+\)$" "$TMP/output.txt" > /dev/null 31 | then 32 | cat "$TMP/output.txt" >&2 33 | exit 1 34 | fi 35 | -------------------------------------------------------------------------------- /test/ci/pass_validate_http_verbose.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-07/schema#", 13 | "allOf": [ 14 | { "$ref": "https://schemas.sourcemeta.com/jsonschema/draft4/schema.json" } 15 | ] 16 | } 17 | EOF 18 | 19 | cat << 'EOF' > "$TMP/instance.json" 20 | { "type": "string" } 21 | EOF 22 | 23 | "$1" validate "$TMP/schema.json" "$TMP/instance.json" --http --verbose 2> "$TMP/stderr.txt" 24 | 25 | cat << EOF > "$TMP/expected.txt" 26 | Resolving over HTTP: https://schemas.sourcemeta.com/jsonschema/draft4/schema.json 27 | ok: $(realpath "$TMP")/instance.json 28 | matches $(realpath "$TMP")/schema.json 29 | EOF 30 | 31 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 32 | -------------------------------------------------------------------------------- /test/format/fail_check_single_json_indentation.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | mkdir -p "$TMP/this/is/a/very/very/very/long/path" 11 | 12 | cat << 'EOF' > "$TMP/this/is/a/very/very/very/long/path/schema.json" 13 | { 14 | "type": 1, 15 | "$schema": "http://json-schema.org/draft-04/schema#" 16 | } 17 | EOF 18 | 19 | "$1" fmt "$TMP/this/is/a/very/very/very/long/path/schema.json" \ 20 | --check --json --indentation 4 >"$TMP/output.json" 2>&1 && CODE="$?" || CODE="$?" 21 | test "$CODE" = "2" || exit 1 22 | 23 | cat << EOF > "$TMP/expected.json" 24 | { 25 | "valid": false, 26 | "errors": [ 27 | "$(realpath "$TMP")/this/is/a/very/very/very/long/path/schema.json" 28 | ] 29 | } 30 | EOF 31 | 32 | diff "$TMP/output.json" "$TMP/expected.json" 33 | -------------------------------------------------------------------------------- /test/test/pass_file_target_with_resolve.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": "string" 14 | } 15 | EOF 16 | 17 | cat << 'EOF' > "$TMP/test.json" 18 | { 19 | "target": "./schema.json", 20 | "$comment": "A random comment", 21 | "tests": [ 22 | { 23 | "valid": true, 24 | "data": "foo" 25 | }, 26 | { 27 | "valid": false, 28 | "data": 1 29 | } 30 | ] 31 | } 32 | EOF 33 | 34 | "$1" test "$TMP/test.json" --resolve "$TMP/schema.json" 1> "$TMP/output.txt" 2>&1 35 | 36 | cat << EOF > "$TMP/expected.txt" 37 | $(realpath "$TMP")/test.json: PASS 2/2 38 | EOF 39 | 40 | diff "$TMP/output.txt" "$TMP/expected.txt" 41 | -------------------------------------------------------------------------------- /vendor/core/src/lang/numeric/parse.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include // std::invalid_argument, std::out_of_range 4 | 5 | namespace sourcemeta::core { 6 | 7 | auto to_double(const std::string &input) noexcept -> std::optional { 8 | try { 9 | return std::stod(input); 10 | } catch (const std::invalid_argument &) { 11 | return std::nullopt; 12 | } catch (const std::out_of_range &) { 13 | return std::nullopt; 14 | } 15 | } 16 | 17 | auto to_int64_t(const std::string &input) noexcept 18 | -> std::optional { 19 | try { 20 | return static_cast(std::stoll(input)); 21 | } catch (const std::invalid_argument &) { 22 | return std::nullopt; 23 | } catch (const std::out_of_range &) { 24 | return std::nullopt; 25 | } 26 | } 27 | 28 | } // namespace sourcemeta::core 29 | -------------------------------------------------------------------------------- /test/ci/precommit_lint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | ROOT="$(dirname "$(dirname "$(pwd)")")" 11 | 12 | cat << EOF > "$TMP/.pre-commit-config.yaml" 13 | repos: 14 | - repo: $ROOT 15 | rev: HEAD 16 | hooks: 17 | - id: sourcemeta-jsonschema-lint 18 | EOF 19 | 20 | cat << 'EOF' > "$TMP/schema.json" 21 | { 22 | "$schema": "http://json-schema.org/draft-04/schema#", 23 | "type": "string", 24 | "enum": [ "foo" ] 25 | } 26 | EOF 27 | 28 | git -C "$TMP" init 29 | git -C "$TMP" add . 30 | 31 | cd "$TMP" 32 | pre-commit install 33 | PATH="$ROOT/bin:$PATH" \ 34 | pre-commit run --files schema.json > "$TMP/out.txt" 2>&1 \ 35 | && CODE="$?" || CODE="$?" 36 | cat "$TMP/out.txt" 37 | test "$CODE" = "1" || exit 1 38 | grep -q "enum_with_type" "$TMP/out.txt" || exit 1 39 | -------------------------------------------------------------------------------- /test/lint/pass_lint_default_no_fix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "properties": { 14 | "foo": { 15 | "type": "string", 16 | "default": "foo" 17 | } 18 | } 19 | } 20 | EOF 21 | 22 | "$1" lint "$TMP/schema.json" > "$TMP/result.txt" 2>&1 23 | 24 | cat << 'EOF' > "$TMP/output.txt" 25 | EOF 26 | 27 | diff "$TMP/result.txt" "$TMP/output.txt" 28 | 29 | cat << 'EOF' > "$TMP/expected.json" 30 | { 31 | "$schema": "http://json-schema.org/draft-04/schema#", 32 | "properties": { 33 | "foo": { 34 | "type": "string", 35 | "default": "foo" 36 | } 37 | } 38 | } 39 | EOF 40 | 41 | diff "$TMP/schema.json" "$TMP/expected.json" 42 | -------------------------------------------------------------------------------- /test/metaschema/pass_2020_12_default_dialect_config_relative.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "type": "string", 13 | "$defs": { 14 | "foo": { 15 | "type": [ "string", "null" ] 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | cat << 'EOF' > "$TMP/jsonschema.json" 22 | { 23 | "defaultDialect": "https://json-schema.org/draft/2020-12/schema" 24 | } 25 | EOF 26 | 27 | cd "$TMP" 28 | 29 | "$1" metaschema --verbose schema.json 2> "$TMP/output.txt" 30 | 31 | cat << EOF > "$TMP/expected.txt" 32 | Using configuration file: $(realpath "$TMP")/jsonschema.json 33 | ok: $(realpath "$TMP")/schema.json 34 | matches https://json-schema.org/draft/2020-12/schema 35 | EOF 36 | 37 | diff "$TMP/output.txt" "$TMP/expected.txt" 38 | -------------------------------------------------------------------------------- /test/unknown_command.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -o errexit 3 | set -o nounset 4 | 5 | TMP="$(mktemp -d)" 6 | clean() { rm -rf "$TMP"; } 7 | trap clean EXIT 8 | 9 | "$1" unknown_command 1> "$TMP/stdout" 2> "$TMP/stderr" && CODE="$?" || CODE="$?" 10 | if [ "$CODE" != "1" ] 11 | then 12 | echo "FAIL: Unknown command did not return exit code 1" 1>&2 13 | exit 1 14 | fi 15 | if [ -s "$TMP/stdout" ] 16 | then 17 | echo "FAIL: Unexpected output to stdout for unknown command" 1>&2 18 | exit 1 19 | fi 20 | if ! [ -s "$TMP/stderr" ] 21 | then 22 | echo "FAIL: No error message produced to stderr for unknown command" 1>&2 23 | exit 1 24 | fi 25 | 26 | cat << EOF > "$TMP/expected.txt" 27 | error: Unknown command 28 | at command unknown_command 29 | 30 | Run the \`help\` command for usage information 31 | EOF 32 | 33 | diff "$TMP/stderr" "$TMP/expected.txt" 34 | 35 | echo "PASS" 1>&2 -------------------------------------------------------------------------------- /test/validate/pass_many.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "properties": { 14 | "foo": { 15 | "type": "string" 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | cat << 'EOF' > "$TMP/instance_1.json" 22 | { "foo": "bar" } 23 | EOF 24 | 25 | cat << 'EOF' > "$TMP/instance_2.json" 26 | { "foo": "baz" } 27 | EOF 28 | 29 | cat << 'EOF' > "$TMP/instance_3.json" 30 | { "foo": "qux" } 31 | EOF 32 | 33 | "$1" validate "$TMP/schema.json" \ 34 | "$TMP/instance_1.json" \ 35 | "$TMP/instance_2.json" \ 36 | "$TMP/instance_3.json" \ 37 | 2> "$TMP/stderr.txt" 38 | 39 | cat << EOF > "$TMP/expected.txt" 40 | EOF 41 | 42 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 43 | -------------------------------------------------------------------------------- /vendor/core/vendor/jsonschema-draft3/links.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema" : "http://json-schema.org/draft-03/hyper-schema#", 3 | "id" : "http://json-schema.org/draft-03/links#", 4 | "type" : "object", 5 | 6 | "properties" : { 7 | "href" : { 8 | "type" : "string", 9 | "required" : true, 10 | "format" : "link-description-object-template" 11 | }, 12 | 13 | "rel" : { 14 | "type" : "string", 15 | "required" : true 16 | }, 17 | 18 | "targetSchema" : {"$ref" : "http://json-schema.org/draft-03/hyper-schema#"}, 19 | 20 | "method" : { 21 | "type" : "string", 22 | "default" : "GET" 23 | }, 24 | 25 | "enctype" : { 26 | "type" : "string", 27 | "requires" : "method" 28 | }, 29 | 30 | "properties" : { 31 | "type" : "object", 32 | "additionalProperties" : {"$ref" : "http://json-schema.org/draft-03/hyper-schema#"} 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /snapcraft.yaml: -------------------------------------------------------------------------------- 1 | # See https://documentation.ubuntu.com/snapcraft/stable/reference/project-file/snapcraft-yaml 2 | name: jsonschema 3 | base: core22 4 | adopt-info: jsonschema 5 | summary: The command-line tool for working with JSON Schema 6 | description: | 7 | Covers formatting, linting, testing, bundling, and more for both local development and CI/CD pipelines. 8 | grade: stable 9 | confinement: strict 10 | apps: 11 | jsonschema: 12 | command: usr/local/bin/jsonschema 13 | completer: usr/local/share/bash-completion/completions/jsonschema 14 | # Means users can only run it on HOME 15 | plugs: [ home, network ] 16 | parts: 17 | jsonschema: 18 | plugin: cmake 19 | source: . 20 | cmake-parameters: 21 | - -DCMAKE_BUILD_TYPE:STRING=Release 22 | override-pull: | 23 | craftctl default 24 | craftctl set version="$(tr -d '\n\r' < VERSION)" 25 | -------------------------------------------------------------------------------- /test/decode/pass_schema_less_jsonl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/document.jsonl" 11 | { "count": 1 } 12 | { "count": 2 } 13 | { "count": 3 } 14 | { "count": 4 } 15 | { "count": 5 } 16 | EOF 17 | 18 | "$1" encode "$TMP/document.jsonl" "$TMP/output.binpack" 19 | "$1" decode "$TMP/output.binpack" "$TMP/result.jsonl" > "$TMP/output.txt" 2>&1 20 | 21 | cat "$TMP/result.jsonl" 22 | 23 | cat << EOF > "$TMP/expected.jsonl" 24 | { 25 | "count": 1 26 | } 27 | { 28 | "count": 2 29 | } 30 | { 31 | "count": 3 32 | } 33 | { 34 | "count": 4 35 | } 36 | { 37 | "count": 5 38 | } 39 | EOF 40 | 41 | cat << EOF > "$TMP/expected-output.txt" 42 | EOF 43 | 44 | diff "$TMP/expected.jsonl" "$TMP/result.jsonl" 45 | diff "$TMP/output.txt" "$TMP/expected-output.txt" 46 | -------------------------------------------------------------------------------- /test/lint/fail_lint_disable_many.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "type": "string", 14 | "contentMediaType": "application/json", 15 | "enum": [ "foo" ] 16 | } 17 | EOF 18 | 19 | cd "$TMP" 20 | "$1" lint "$TMP/schema.json" --exclude enum_to_const -x enum_with_type >"$TMP/stderr.txt" 2>&1 && CODE="$?" || CODE="$?" 21 | test "$CODE" = "2" || exit 1 22 | 23 | cat << EOF > "$TMP/expected.txt" 24 | schema.json:4:3: 25 | The \`contentMediaType\` keyword is meaningless without the presence of the \`contentEncoding\` keyword (content_media_type_without_encoding) 26 | at location "/contentMediaType" 27 | EOF 28 | 29 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 30 | -------------------------------------------------------------------------------- /test/test/fail_test_case_non_object.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/test.json" 11 | { 12 | "target": "http://json-schema.org/draft-04/schema#", 13 | "tests": [ 14 | { 15 | "valid": true, 16 | "data": {} 17 | }, 18 | [] 19 | ] 20 | } 21 | EOF 22 | 23 | "$1" test "$TMP/test.json" 1> "$TMP/output.txt" 2>&1 \ 24 | && CODE="$?" || CODE="$?" 25 | test "$CODE" = "1" || exit 1 26 | 27 | cat << EOF > "$TMP/expected.txt" 28 | $(realpath "$TMP")/test.json: 29 | error: Test case documents must be objects 30 | at test case #2 31 | at file path $(realpath "$TMP")/test.json 32 | 33 | Learn more here: https://github.com/sourcemeta/jsonschema/blob/main/docs/test.markdown 34 | EOF 35 | 36 | diff "$TMP/output.txt" "$TMP/expected.txt" 37 | -------------------------------------------------------------------------------- /test/validate/pass_directory.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": "object", 14 | "properties": { 15 | "name": { 16 | "type": "string" 17 | }, 18 | "age": { 19 | "type": "integer" 20 | } 21 | } 22 | } 23 | EOF 24 | 25 | mkdir "$TMP/instances" 26 | 27 | cat << 'EOF' > "$TMP/instances/instance_1.json" 28 | { "name": "Alice", "age": 30 } 29 | EOF 30 | 31 | cat << 'EOF' > "$TMP/instances/instance_2.json" 32 | { "name": "Bob", "age": 25 } 33 | EOF 34 | 35 | "$1" validate "$TMP/schema.json" "$TMP/instances" 2> "$TMP/stderr.txt" 36 | 37 | cat << 'EOF' > "$TMP/expected.txt" 38 | EOF 39 | 40 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 41 | -------------------------------------------------------------------------------- /test/ci/fail_bundle_http_non_schema.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-07/schema#", 13 | "allOf": [ { "$ref": "https://schemas.sourcemeta.com/self/api/schemas/stats/jsonschema/2020-12/schema" } ] 14 | } 15 | EOF 16 | 17 | "$1" bundle "$TMP/schema.json" --http 2> "$TMP/stderr.txt" \ 18 | && CODE="$?" || CODE="$?" 19 | test "$CODE" = "1" || exit 1 20 | 21 | cat << EOF > "$TMP/expected.txt" 22 | error: The JSON document is not a valid JSON Schema 23 | at identifier https://schemas.sourcemeta.com/self/api/schemas/stats/jsonschema/2020-12/schema 24 | at file path $(realpath "$TMP")/schema.json 25 | at location "/allOf/0/\$ref" 26 | EOF 27 | 28 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 29 | -------------------------------------------------------------------------------- /test/format/fail_check_single_indentation.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": 1 14 | } 15 | EOF 16 | 17 | "$1" fmt "$TMP/schema.json" --indentation 4 --check >"$TMP/output.txt" 2>&1 && CODE="$?" || CODE="$?" 18 | test "$CODE" = "2" || exit 1 19 | 20 | cat << EOF > "$TMP/expected.txt" 21 | fail: $(realpath "$TMP")/schema.json 22 | 23 | Run the \`fmt\` command without \`--check/-c\` to fix the formatting 24 | EOF 25 | 26 | diff "$TMP/output.txt" "$TMP/expected.txt" 27 | 28 | cat << 'EOF' > "$TMP/expected.json" 29 | { 30 | "$schema": "http://json-schema.org/draft-04/schema#", 31 | "type": 1 32 | } 33 | EOF 34 | 35 | diff "$TMP/schema.json" "$TMP/expected.json" 36 | -------------------------------------------------------------------------------- /test/lint/pass_lint_examples_no_fix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-06/schema#", 13 | "properties": { 14 | "foo": { 15 | "type": "string", 16 | "examples": [ "foo" ] 17 | } 18 | } 19 | } 20 | EOF 21 | 22 | "$1" lint "$TMP/schema.json" > "$TMP/result.txt" 2>&1 23 | 24 | cat << 'EOF' > "$TMP/output.txt" 25 | EOF 26 | 27 | diff "$TMP/result.txt" "$TMP/output.txt" 28 | 29 | cat << 'EOF' > "$TMP/expected.json" 30 | { 31 | "$schema": "http://json-schema.org/draft-06/schema#", 32 | "properties": { 33 | "foo": { 34 | "type": "string", 35 | "examples": [ "foo" ] 36 | } 37 | } 38 | } 39 | EOF 40 | 41 | diff "$TMP/schema.json" "$TMP/expected.json" 42 | -------------------------------------------------------------------------------- /test/lint/pass_lint_direct_custom_extension.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | mkdir "$TMP/schemas" 11 | 12 | cat << 'EOF' > "$TMP/schema.json.schema" 13 | { 14 | "$schema": "http://json-schema.org/draft-04/schema#", 15 | "id": "https://example.com" 16 | } 17 | EOF 18 | 19 | "$1" lint --resolve "$TMP/schema.json.schema" "$TMP/schema.json.schema" --verbose > "$TMP/output.txt" 2>&1 20 | 21 | cat << EOF > "$TMP/expected.txt" 22 | Detecting schema resources from file: $(realpath "$TMP")/schema.json.schema 23 | Importing schema into the resolution context: file://$(realpath "$TMP")/schema.json.schema 24 | Importing schema into the resolution context: https://example.com 25 | Linting: $(realpath "$TMP")/schema.json.schema 26 | EOF 27 | 28 | diff "$TMP/output.txt" "$TMP/expected.txt" 29 | -------------------------------------------------------------------------------- /test/validate/pass_directory_fast.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": "object", 14 | "properties": { 15 | "name": { 16 | "type": "string" 17 | }, 18 | "age": { 19 | "type": "integer" 20 | } 21 | } 22 | } 23 | EOF 24 | 25 | mkdir "$TMP/instances" 26 | 27 | cat << 'EOF' > "$TMP/instances/instance_1.json" 28 | { "name": "Alice", "age": 30 } 29 | EOF 30 | 31 | cat << 'EOF' > "$TMP/instances/instance_2.json" 32 | { "name": "Bob", "age": 25 } 33 | EOF 34 | 35 | "$1" validate "$TMP/schema.json" "$TMP/instances" --fast 2> "$TMP/stderr.txt" 36 | 37 | cat << 'EOF' > "$TMP/expected.txt" 38 | EOF 39 | 40 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 41 | -------------------------------------------------------------------------------- /vendor/core/src/lang/numeric/include/sourcemeta/core/numeric_parse.h: -------------------------------------------------------------------------------- 1 | #ifndef SOURCEMETA_CORE_NUMERIC_PARSE_H 2 | #define SOURCEMETA_CORE_NUMERIC_PARSE_H 3 | 4 | #ifndef SOURCEMETA_CORE_NUMERIC_EXPORT 5 | #include 6 | #endif 7 | 8 | #include // std::int64_t 9 | #include // std::optional 10 | #include // std::string 11 | 12 | namespace sourcemeta::core { 13 | 14 | /// @ingroup numeric 15 | /// Attempt to parse a string as a double 16 | SOURCEMETA_CORE_NUMERIC_EXPORT 17 | auto to_double(const std::string &input) noexcept -> std::optional; 18 | 19 | /// @ingroup numeric 20 | /// Attempt to parse a string as a signed 64-bit integer 21 | SOURCEMETA_CORE_NUMERIC_EXPORT 22 | auto to_int64_t(const std::string &input) noexcept 23 | -> std::optional; 24 | 25 | } // namespace sourcemeta::core 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /test/metaschema/pass_config_path.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | mkdir -p "$TMP/foo" 11 | mkdir -p "$TMP/bar" 12 | 13 | cat << 'EOF' > "$TMP/foo/schema.json" 14 | { 15 | "$schema": "http://json-schema.org/draft-04/schema#", 16 | "type": "string" 17 | } 18 | EOF 19 | 20 | cat << 'EOF' > "$TMP/jsonschema.json" 21 | { 22 | "path": "./foo" 23 | } 24 | EOF 25 | 26 | cd "$TMP/bar" 27 | "$1" metaschema --verbose > "$TMP/output.txt" 2>&1 28 | 29 | cat << EOF > "$TMP/expected.txt" 30 | Using configuration file: $(realpath "$TMP")/jsonschema.json 31 | Using extension: .json 32 | Using extension: .yaml 33 | Using extension: .yml 34 | ok: $(realpath "$TMP")/foo/schema.json 35 | matches http://json-schema.org/draft-04/schema# 36 | EOF 37 | 38 | diff "$TMP/output.txt" "$TMP/expected.txt" 39 | -------------------------------------------------------------------------------- /test/validate/pass_jsonl_json_verbose.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "properties": { 14 | "foo": { 15 | "type": "string" 16 | } 17 | } 18 | } 19 | EOF 20 | 21 | cat << 'EOF' > "$TMP/instance.jsonl" 22 | { "foo": "first" } 23 | { "foo": "second" } 24 | { "foo": "third" } 25 | EOF 26 | 27 | "$1" validate "$TMP/schema.json" "$TMP/instance.jsonl" --json --verbose > "$TMP/output.json" 2>&1 28 | 29 | cat << EOF > "$TMP/expected.json" 30 | Interpreting input as JSONL: $(realpath "$TMP")/instance.jsonl 31 | { 32 | "valid": true 33 | } 34 | { 35 | "valid": true 36 | } 37 | { 38 | "valid": true 39 | } 40 | EOF 41 | 42 | diff "$TMP/output.json" "$TMP/expected.json" 43 | -------------------------------------------------------------------------------- /test/test/fail_schema_non_string.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/test.json" 11 | { 12 | "target": 1, 13 | "tests": [ 14 | { 15 | "valid": true, 16 | "data": {} 17 | }, 18 | { 19 | "valid": true, 20 | "data": { "type": 1 } 21 | } 22 | ] 23 | } 24 | EOF 25 | 26 | "$1" test "$TMP/test.json" 1> "$TMP/output.txt" 2>&1 \ 27 | && CODE="$?" || CODE="$?" 28 | test "$CODE" = "1" || exit 1 29 | 30 | cat << EOF > "$TMP/expected.txt" 31 | $(realpath "$TMP")/test.json: 32 | error: The test document \`target\` property must be a URI 33 | at file path $(realpath "$TMP")/test.json 34 | 35 | Learn more here: https://github.com/sourcemeta/jsonschema/blob/main/docs/test.markdown 36 | EOF 37 | 38 | diff "$TMP/output.txt" "$TMP/expected.txt" 39 | -------------------------------------------------------------------------------- /test/format/pass_single.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "additionalProperties": false, 14 | "title": "Hello World", 15 | "properties": {"foo": {}, "bar": {}} 16 | } 17 | EOF 18 | 19 | "$1" fmt "$TMP/schema.json" >"$TMP/output.txt" 2>&1 20 | 21 | cat << 'EOF' > "$TMP/expected_output.txt" 22 | EOF 23 | 24 | diff "$TMP/output.txt" "$TMP/expected_output.txt" 25 | 26 | cat << 'EOF' > "$TMP/expected.json" 27 | { 28 | "$schema": "https://json-schema.org/draft/2020-12/schema", 29 | "title": "Hello World", 30 | "properties": { 31 | "foo": {}, 32 | "bar": {} 33 | }, 34 | "additionalProperties": false 35 | } 36 | EOF 37 | 38 | diff "$TMP/schema.json" "$TMP/expected.json" 39 | -------------------------------------------------------------------------------- /test/validate/pass_directory_and_file.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": "object", 14 | "properties": { 15 | "name": { 16 | "type": "string" 17 | } 18 | } 19 | } 20 | EOF 21 | 22 | mkdir "$TMP/instances" 23 | 24 | cat << 'EOF' > "$TMP/instances/instance_1.json" 25 | { "name": "Alice" } 26 | EOF 27 | 28 | cat << 'EOF' > "$TMP/instances/instance_2.json" 29 | { "name": "Bob" } 30 | EOF 31 | 32 | cat << 'EOF' > "$TMP/single.json" 33 | { "name": "Charlie" } 34 | EOF 35 | 36 | "$1" validate "$TMP/schema.json" "$TMP/single.json" "$TMP/instances" 2> "$TMP/stderr.txt" 37 | 38 | cat << 'EOF' > "$TMP/expected.txt" 39 | EOF 40 | 41 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 42 | -------------------------------------------------------------------------------- /vendor/core/cmake/common/commands/copy-file.cmake: -------------------------------------------------------------------------------- 1 | function(sourcemeta_command_copy_file) 2 | cmake_parse_arguments(SOURCEMETA_COMMAND_COPY_FILE "" "FROM;TO" "" ${ARGN}) 3 | 4 | if(NOT SOURCEMETA_COMMAND_COPY_FILE_FROM) 5 | message(FATAL_ERROR "You must pass the file to copy using the FROM option") 6 | endif() 7 | if(NOT SOURCEMETA_COMMAND_COPY_FILE_TO) 8 | message(FATAL_ERROR "You must pass the destination to copy to using the TO option") 9 | endif() 10 | 11 | add_custom_command( 12 | OUTPUT "${SOURCEMETA_COMMAND_COPY_FILE_TO}" 13 | COMMAND "${CMAKE_COMMAND}" -E copy "${SOURCEMETA_COMMAND_COPY_FILE_FROM}" "${SOURCEMETA_COMMAND_COPY_FILE_TO}" 14 | MAIN_DEPENDENCY "${SOURCEMETA_COMMAND_COPY_FILE_FROM}" 15 | DEPENDS "${SOURCEMETA_COMMAND_COPY_FILE_FROM}" 16 | COMMENT "Copying ${SOURCEMETA_COMMAND_COPY_FILE_FROM} ot ${SOURCEMETA_COMMAND_COPY_FILE_TO}") 17 | endfunction() 18 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/include/cpr/filesystem.h: -------------------------------------------------------------------------------- 1 | #ifndef CPR_FILESYSTEM_H 2 | #define CPR_FILESYSTEM_H 3 | 4 | // Include filesystem into the namespace "fs" from either "filesystem" or "experimental/filesystem" or "boost/filesystem" 5 | #ifdef CPR_USE_BOOST_FILESYSTEM 6 | #define BOOST_FILESYSTEM_VERSION 4 // Use the latest, with the closest behavior to std::filesystem. 7 | #include 8 | namespace cpr { 9 | namespace fs = boost::filesystem; 10 | } 11 | // cppcheck-suppress preprocessorErrorDirective 12 | #elif __has_include() 13 | #include 14 | namespace cpr { 15 | namespace fs = std::filesystem; 16 | } 17 | #elif __has_include("experimental/filesystem") 18 | #include 19 | namespace cpr { 20 | namespace fs = std::experimental::filesystem; 21 | } 22 | #else 23 | #error "Failed to include header!" 24 | #endif 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /test/bundle/pass_without_remote.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "$id": "https://example.com", 14 | "$ref": "#/$defs/string", 15 | "$defs": { 16 | "string": { "type": "string" } 17 | } 18 | } 19 | EOF 20 | 21 | "$1" bundle "$TMP/schema.json" > "$TMP/result.json" 22 | 23 | cat << 'EOF' > "$TMP/expected.json" 24 | { 25 | "$schema": "https://json-schema.org/draft/2020-12/schema", 26 | "$id": "https://example.com", 27 | "$ref": "#/$defs/string", 28 | "$defs": { 29 | "string": { 30 | "type": "string" 31 | } 32 | } 33 | } 34 | EOF 35 | 36 | diff "$TMP/result.json" "$TMP/expected.json" 37 | 38 | # Must come out formatted 39 | "$1" fmt "$TMP/result.json" --check 40 | -------------------------------------------------------------------------------- /test/encode/pass_schema_less_jsonl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/document.jsonl" 11 | { "count": 1 } 12 | { "count": 2 } 13 | { "count": 3 } 14 | { "count": 4 } 15 | { "count": 5 } 16 | EOF 17 | 18 | "$1" encode "$TMP/document.jsonl" "$TMP/output.binpack" > "$TMP/output.txt" 2>&1 19 | xxd "$TMP/output.binpack" > "$TMP/output.hex" 20 | 21 | cat << 'EOF' > "$TMP/expected.txt" 22 | 00000000: 1306 636f 756e 7415 1300 091d 1300 0525 ..count........% 23 | 00000010: 1300 052d 1300 0535 ...-...5 24 | EOF 25 | 26 | cat << 'EOF' > "$TMP/expected-output.txt" 27 | original file size: 75 bytes 28 | encoded file size: 24 bytes 29 | compression ratio: 32% 30 | EOF 31 | 32 | diff "$TMP/expected.txt" "$TMP/output.hex" 33 | diff "$TMP/output.txt" "$TMP/expected-output.txt" 34 | -------------------------------------------------------------------------------- /test/test/fail_test_case_non_string_data_path.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/test.json" 11 | { 12 | "target": "http://json-schema.org/draft-04/schema#", 13 | "tests": [ 14 | { 15 | "valid": true, 16 | "dataPath": 1 17 | } 18 | ] 19 | } 20 | EOF 21 | 22 | "$1" test "$TMP/test.json" 1> "$TMP/output.txt" 2>&1 \ 23 | && CODE="$?" || CODE="$?" 24 | test "$CODE" = "1" || exit 1 25 | 26 | cat << EOF > "$TMP/expected.txt" 27 | $(realpath "$TMP")/test.json: 28 | error: Test case documents must set the \`dataPath\` property to a string 29 | at test case #1 30 | at file path $(realpath "$TMP")/test.json 31 | 32 | Learn more here: https://github.com/sourcemeta/jsonschema/blob/main/docs/test.markdown 33 | EOF 34 | 35 | diff "$TMP/output.txt" "$TMP/expected.txt" 36 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:bookworm AS builder 2 | RUN apt-get --yes update && apt-get install --yes --no-install-recommends \ 3 | build-essential cmake && apt-get clean && rm -rf /var/lib/apt/lists/* 4 | 5 | COPY cmake /source/cmake 6 | COPY src /source/src 7 | COPY completion /source/completion 8 | COPY vendor /source/vendor 9 | COPY CMakeLists.txt /source/CMakeLists.txt 10 | COPY VERSION /source/VERSION 11 | 12 | RUN cmake -S /source -B ./build \ 13 | -DCMAKE_BUILD_TYPE:STRING=Release \ 14 | -DBUILD_SHARED_LIBS:BOOL=OFF \ 15 | -DJSONSCHEMA_PORTABLE:BOOL=ON 16 | RUN cmake --build /build --config Release --parallel 4 17 | RUN cmake --install /build --prefix /usr/local --config Release --verbose --component sourcemeta_jsonschema 18 | 19 | FROM debian:bookworm-slim 20 | COPY --from=builder /usr/local/bin/jsonschema /usr/local/bin/jsonschema 21 | WORKDIR /workspace 22 | ENTRYPOINT [ "/usr/local/bin/jsonschema" ] 23 | -------------------------------------------------------------------------------- /test/test/fail_additional_properties.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "id": "https://example.com", 13 | "$schema": "http://json-schema.org/draft-04/schema#", 14 | "type": "object", 15 | "additionalProperties": false, 16 | "properties": { 17 | "foo": true, 18 | "bar": true 19 | } 20 | } 21 | EOF 22 | 23 | cat << 'EOF' > "$TMP/test.json" 24 | { 25 | "target": "https://example.com", 26 | "tests": [ 27 | { 28 | "valid": false, 29 | "data": { "fo": true } 30 | } 31 | ] 32 | } 33 | EOF 34 | 35 | "$1" test "$TMP/test.json" --resolve "$TMP/schema.json" 1> "$TMP/output.txt" 2>&1 36 | 37 | cat << EOF > "$TMP/expected.txt" 38 | $(realpath "$TMP")/test.json: PASS 1/1 39 | EOF 40 | 41 | diff "$TMP/output.txt" "$TMP/expected.txt" 42 | -------------------------------------------------------------------------------- /vendor/core/vendor/jsonschema-draft4/links.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema" : "http://json-schema.org/draft-04/hyper-schema#", 3 | "id" : "http://json-schema.org/draft-04/links#", 4 | "type" : "object", 5 | 6 | "properties" : { 7 | "rel" : { 8 | "type" : "string" 9 | }, 10 | 11 | "href" : { 12 | "type" : "string" 13 | }, 14 | 15 | "template" : { 16 | "type" : "string" 17 | }, 18 | 19 | "targetSchema" : {"$ref" : "http://json-schema.org/draft-04/hyper-schema#"}, 20 | 21 | "method" : { 22 | "type" : "string", 23 | "default" : "GET" 24 | }, 25 | 26 | "enctype" : { 27 | "type" : "string" 28 | }, 29 | 30 | "properties" : { 31 | "type" : "object", 32 | "additionalProperties" : {"$ref" : "http://json-schema.org/draft-04/hyper-schema#"} 33 | } 34 | }, 35 | 36 | "required" : ["rel", "href"], 37 | 38 | "dependencies" : { 39 | "enctype" : ["method"] 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /vendor/hydra/vendor/cpr/cmake/cprver.h.in: -------------------------------------------------------------------------------- 1 | #ifndef CPR_CPRVER_H 2 | #define CPR_CPRVER_H 3 | 4 | /** 5 | * CPR version as a string. 6 | **/ 7 | #define CPR_VERSION "${cpr_VERSION}" 8 | 9 | /** 10 | * CPR version split up into parts. 11 | **/ 12 | #define CPR_VERSION_MAJOR ${cpr_VERSION_MAJOR} 13 | #define CPR_VERSION_MINOR ${cpr_VERSION_MINOR} 14 | #define CPR_VERSION_PATCH ${cpr_VERSION_PATCH} 15 | 16 | /** 17 | * CPR version as a single hex digit. 18 | * it can be split up into three parts: 19 | * 0xAABBCC 20 | * AA: The current CPR major version number in a hex format. 21 | * BB: The current CPR minor version number in a hex format. 22 | * CC: The current CPR patch version number in a hex format. 23 | * 24 | * Examples: 25 | * '0x010702' -> 01.07.02 -> CPR_VERSION: 1.7.2 26 | * '0xA13722' -> A1.37.22 -> CPR_VERSION: 161.55.34 27 | **/ 28 | #define CPR_VERSION_NUM ${cpr_VERSION_NUM} 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /src/command.h: -------------------------------------------------------------------------------- 1 | #ifndef SOURCEMETA_JSONSCHEMA_CLI_COMMAND_H_ 2 | #define SOURCEMETA_JSONSCHEMA_CLI_COMMAND_H_ 3 | 4 | #include 5 | 6 | namespace sourcemeta::jsonschema { 7 | auto fmt(const sourcemeta::core::Options &options) -> void; 8 | auto inspect(const sourcemeta::core::Options &options) -> void; 9 | auto bundle(const sourcemeta::core::Options &options) -> void; 10 | auto test(const sourcemeta::core::Options &options) -> void; 11 | auto lint(const sourcemeta::core::Options &options) -> void; 12 | auto validate(const sourcemeta::core::Options &options) -> void; 13 | auto metaschema(const sourcemeta::core::Options &options) -> void; 14 | auto compile(const sourcemeta::core::Options &options) -> void; 15 | auto encode(const sourcemeta::core::Options &options) -> void; 16 | auto decode(const sourcemeta::core::Options &options) -> void; 17 | } // namespace sourcemeta::jsonschema 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /test/validate/pass_directory_extension.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": "object", 14 | "properties": { 15 | "name": { 16 | "type": "string" 17 | } 18 | } 19 | } 20 | EOF 21 | 22 | mkdir "$TMP/instances" 23 | 24 | cat << 'EOF' > "$TMP/instances/instance_1.data.json" 25 | { "name": "Alice" } 26 | EOF 27 | 28 | cat << 'EOF' > "$TMP/instances/instance_2.data.json" 29 | { "name": "Bob" } 30 | EOF 31 | 32 | cat << 'EOF' > "$TMP/instances/other.json" 33 | { "name": 123 } 34 | EOF 35 | 36 | "$1" validate "$TMP/schema.json" "$TMP/instances" --extension .data.json 2> "$TMP/stderr.txt" 37 | 38 | cat << 'EOF' > "$TMP/expected.txt" 39 | EOF 40 | 41 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 42 | -------------------------------------------------------------------------------- /vendor/core/vendor/jsonschema-2019-09/meta/hyper-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2019-09/hyper-schema", 3 | "$id": "https://json-schema.org/draft/2019-09/meta/hyper-schema", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2019-09/vocab/hyper-schema": true 6 | }, 7 | "$recursiveAnchor": true, 8 | 9 | "title": "JSON Hyper-Schema Vocabulary Schema", 10 | "type": ["object", "boolean"], 11 | "properties": { 12 | "base": { 13 | "type": "string", 14 | "format": "uri-template" 15 | }, 16 | "links": { 17 | "type": "array", 18 | "items": { 19 | "$ref": "https://json-schema.org/draft/2019-09/links" 20 | } 21 | } 22 | }, 23 | "links": [ 24 | { 25 | "rel": "self", 26 | "href": "{+%24id}" 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /vendor/core/vendor/jsonschema-2020-12/meta/hyper-schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json-schema.org/draft/2020-12/hyper-schema", 3 | "$id": "https://json-schema.org/draft/2020-12/meta/hyper-schema", 4 | "$vocabulary": { 5 | "https://json-schema.org/draft/2019-09/vocab/hyper-schema": true 6 | }, 7 | "$dynamicAnchor": "meta", 8 | 9 | "title": "JSON Hyper-Schema Vocabulary Schema", 10 | "type": ["object", "boolean"], 11 | "properties": { 12 | "base": { 13 | "type": "string", 14 | "format": "uri-template" 15 | }, 16 | "links": { 17 | "type": "array", 18 | "items": { 19 | "$ref": "https://json-schema.org/draft/2020-12/links" 20 | } 21 | } 22 | }, 23 | "links": [ 24 | { 25 | "rel": "self", 26 | "href": "{+%24id}" 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /test/test/fail_test_case_no_valid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/test.json" 11 | { 12 | "target": "http://json-schema.org/draft-04/schema#", 13 | "tests": [ 14 | { 15 | "data": {} 16 | }, 17 | { 18 | "valid": true, 19 | "data": {} 20 | } 21 | ] 22 | } 23 | EOF 24 | 25 | "$1" test "$TMP/test.json" 1> "$TMP/output.txt" 2>&1 \ 26 | && CODE="$?" || CODE="$?" 27 | test "$CODE" = "1" || exit 1 28 | 29 | cat << EOF > "$TMP/expected.txt" 30 | $(realpath "$TMP")/test.json: 31 | error: Test case documents must contain a \`valid\` property 32 | at test case #1 33 | at file path $(realpath "$TMP")/test.json 34 | 35 | Learn more here: https://github.com/sourcemeta/jsonschema/blob/main/docs/test.markdown 36 | EOF 37 | 38 | diff "$TMP/output.txt" "$TMP/expected.txt" 39 | -------------------------------------------------------------------------------- /vendor/core/cmake/common/targets/googletest.cmake: -------------------------------------------------------------------------------- 1 | function(sourcemeta_googletest) 2 | cmake_parse_arguments(SOURCEMETA_GOOGLETEST "" 3 | "NAMESPACE;PROJECT;NAME;VARIANT" "SOURCES" ${ARGN}) 4 | 5 | if(SOURCEMETA_GOOGLETEST_VARIANT) 6 | set(TARGET_VARIANT "${SOURCEMETA_GOOGLETEST_VARIANT}_unit") 7 | else() 8 | set(TARGET_VARIANT "unit") 9 | endif() 10 | 11 | sourcemeta_executable( 12 | NAMESPACE "${SOURCEMETA_GOOGLETEST_NAMESPACE}" 13 | PROJECT "${SOURCEMETA_GOOGLETEST_PROJECT}" 14 | NAME "${SOURCEMETA_GOOGLETEST_NAME}" 15 | VARIANT "${TARGET_VARIANT}" 16 | SOURCES "${SOURCEMETA_GOOGLETEST_SOURCES}" 17 | OUTPUT TARGET_NAME) 18 | 19 | target_link_libraries("${TARGET_NAME}" 20 | PRIVATE GTest::gtest GTest::gmock GTest::gtest_main) 21 | add_test(NAME "${SOURCEMETA_GOOGLETEST_PROJECT}.${SOURCEMETA_GOOGLETEST_NAME}" 22 | COMMAND "${TARGET_NAME}" --gtest_brief=1) 23 | endfunction() 24 | -------------------------------------------------------------------------------- /vendor/core/src/core/jsonl/grammar.h: -------------------------------------------------------------------------------- 1 | #ifndef SOURCEMETA_CORE_JSONL_GRAMMAR_H_ 2 | #define SOURCEMETA_CORE_JSONL_GRAMMAR_H_ 3 | 4 | namespace sourcemeta::core::internal { 5 | template 6 | static constexpr CharT token_jsonl_line_feed{'\u000A'}; 7 | 8 | // Whitespace is any sequence of one or more of the following code points: 9 | // character tabulation (U+0009), line feed (U+000A), carriage return (U+000D), 10 | // and space (U+0020). 11 | // See 12 | // https://www.ecma-international.org/wp-content/uploads/ECMA-404_2nd_edition_december_2017.pdf 13 | template 14 | static constexpr CharT token_jsonl_whitespace_tabulation{'\u0009'}; 15 | template 16 | static constexpr CharT token_jsonl_whitespace_carriage_return{'\u000D'}; 17 | template 18 | static constexpr CharT token_jsonl_whitespace_space{'\u0020'}; 19 | 20 | } // namespace sourcemeta::core::internal 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /test/decode/fail_no_document.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/document.json" 11 | { "version": 2.0 } 12 | EOF 13 | 14 | "$1" decode 2>"$TMP/stderr.txt" && CODE="$?" || CODE="$?" 15 | test "$CODE" = "1" || exit 1 16 | 17 | cat << 'EOF' > "$TMP/expected.txt" 18 | error: This command expects a path to a binary file and an output path 19 | 20 | For example: jsonschema decode path/to/output.binpack path/to/document.json 21 | EOF 22 | 23 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 24 | 25 | # JSON error 26 | "$1" decode --json > "$TMP/stdout.txt" 2>&1 && CODE="$?" || CODE="$?" 27 | test "$CODE" = "1" || exit 1 28 | 29 | cat << 'EOF' > "$TMP/expected.txt" 30 | { 31 | "error": "This command expects a path to a binary file and an output path" 32 | } 33 | EOF 34 | 35 | diff "$TMP/stdout.txt" "$TMP/expected.txt" 36 | -------------------------------------------------------------------------------- /test/test/pass_single_resolve.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "id": "https://example.com", 13 | "$schema": "http://json-schema.org/draft-04/schema#", 14 | "type": "string" 15 | } 16 | EOF 17 | 18 | cat << 'EOF' > "$TMP/test.json" 19 | { 20 | "target": "https://example.com", 21 | "tests": [ 22 | { 23 | "description": "First test", 24 | "valid": true, 25 | "data": "foo" 26 | }, 27 | { 28 | "description": "Invalid type", 29 | "valid": false, 30 | "data": 1 31 | } 32 | ] 33 | } 34 | EOF 35 | 36 | "$1" test "$TMP/test.json" --resolve "$TMP/schema.json" 1> "$TMP/output.txt" 2>&1 37 | 38 | cat << EOF > "$TMP/expected.txt" 39 | $(realpath "$TMP")/test.json: PASS 2/2 40 | EOF 41 | 42 | diff "$TMP/output.txt" "$TMP/expected.txt" 43 | -------------------------------------------------------------------------------- /test/encode/fail_no_document.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/document.json" 11 | { "version": 2.0 } 12 | EOF 13 | 14 | "$1" encode 2> "$TMP/stderr.txt" && CODE="$?" || CODE="$?" 15 | test "$CODE" = "1" || exit 1 16 | 17 | cat << 'EOF' > "$TMP/expected.txt" 18 | error: This command expects a path to a JSON document and an output path 19 | 20 | For example: jsonschema encode path/to/document.json path/to/output.binpack 21 | EOF 22 | 23 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 24 | 25 | # JSON error 26 | "$1" encode --json > "$TMP/stdout.txt" 2>&1 && CODE="$?" || CODE="$?" 27 | test "$CODE" = "1" || exit 1 28 | 29 | cat << 'EOF' > "$TMP/expected.txt" 30 | { 31 | "error": "This command expects a path to a JSON document and an output path" 32 | } 33 | EOF 34 | 35 | diff "$TMP/stdout.txt" "$TMP/expected.txt" 36 | -------------------------------------------------------------------------------- /test/lint/fail_lint_default.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-06/schema#", 13 | "properties": { 14 | "foo": { 15 | "type": "string", 16 | "default": 1 17 | } 18 | } 19 | } 20 | EOF 21 | 22 | cd "$TMP" 23 | "$1" lint "$TMP/schema.json" >"$TMP/stderr.txt" 2>&1 && CODE="$?" || CODE="$?" 24 | test "$CODE" = "2" || exit 1 25 | 26 | cat << EOF > "$TMP/expected.txt" 27 | schema.json:6:7: 28 | Only set a \`default\` value that validates against the schema (blaze/valid_default) 29 | at location "/properties/foo/default" 30 | The value was expected to be of type string but it was of type integer 31 | at instance location "" 32 | at evaluate path "/type" 33 | EOF 34 | 35 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 36 | -------------------------------------------------------------------------------- /test/lint/fail_lint_yaml.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.yaml" 11 | $schema: http://json-schema.org/draft-04/schema# 12 | type: string 13 | enum: [ foo ] 14 | EOF 15 | 16 | cd "$TMP" 17 | "$1" lint "$TMP/schema.yaml" >"$TMP/stderr.txt" 2>&1 && CODE="$?" || CODE="$?" 18 | test "$CODE" = "2" || exit 1 19 | 20 | cat << EOF > "$TMP/expected.txt" 21 | schema.yaml:3:1: 22 | Setting \`type\` alongside \`enum\` is considered an anti-pattern, as the enumeration choices already imply their respective types (enum_with_type) 23 | at location "/enum" 24 | schema.yaml:2:1: 25 | Setting \`type\` alongside \`enum\` is considered an anti-pattern, as the enumeration choices already imply their respective types (enum_with_type) 26 | at location "/type" 27 | EOF 28 | 29 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 30 | -------------------------------------------------------------------------------- /vendor/core/vendor/googlebenchmark/src/colorprint.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARK_COLORPRINT_H_ 2 | #define BENCHMARK_COLORPRINT_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace benchmark { 9 | enum LogColor { 10 | COLOR_DEFAULT, 11 | COLOR_RED, 12 | COLOR_GREEN, 13 | COLOR_YELLOW, 14 | COLOR_BLUE, 15 | COLOR_MAGENTA, 16 | COLOR_CYAN, 17 | COLOR_WHITE 18 | }; 19 | 20 | std::string FormatString(const char* msg, va_list args); 21 | std::string FormatString(const char* msg, ...); 22 | 23 | void ColorPrintf(std::ostream& out, LogColor color, const char* fmt, 24 | va_list args); 25 | void ColorPrintf(std::ostream& out, LogColor color, const char* fmt, ...); 26 | 27 | // Returns true if stdout appears to be a terminal that supports colored 28 | // output, false otherwise. 29 | bool IsColorTerminal(); 30 | 31 | } // end namespace benchmark 32 | 33 | #endif // BENCHMARK_COLORPRINT_H_ 34 | -------------------------------------------------------------------------------- /test/format/pass_single_indentation.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "https://json-schema.org/draft/2020-12/schema", 13 | "additionalProperties": false, 14 | "title": "Hello World", 15 | "properties": {"foo": {}, "bar": {}} 16 | } 17 | EOF 18 | 19 | "$1" fmt "$TMP/schema.json" --indentation 4 >"$TMP/output.txt" 2>&1 20 | 21 | cat << 'EOF' > "$TMP/expected_output.txt" 22 | EOF 23 | 24 | diff "$TMP/output.txt" "$TMP/expected_output.txt" 25 | 26 | cat << 'EOF' > "$TMP/expected.json" 27 | { 28 | "$schema": "https://json-schema.org/draft/2020-12/schema", 29 | "title": "Hello World", 30 | "properties": { 31 | "foo": {}, 32 | "bar": {} 33 | }, 34 | "additionalProperties": false 35 | } 36 | EOF 37 | 38 | diff "$TMP/schema.json" "$TMP/expected.json" 39 | -------------------------------------------------------------------------------- /test/validate/pass_directory_ignore_jsonl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": "object", 14 | "properties": { 15 | "name": { 16 | "type": "string" 17 | } 18 | } 19 | } 20 | EOF 21 | 22 | mkdir "$TMP/instances" 23 | 24 | cat << 'EOF' > "$TMP/instances/instance_1.json" 25 | { "name": "Alice" } 26 | EOF 27 | 28 | cat << 'EOF' > "$TMP/instances/instance_2.json" 29 | { "name": "Bob" } 30 | EOF 31 | 32 | cat << 'EOF' > "$TMP/instances/dataset.jsonl" 33 | { "name": "Charlie" } 34 | { "name": "Diana" } 35 | { "name": "Eve" } 36 | EOF 37 | 38 | "$1" validate "$TMP/schema.json" "$TMP/instances" 2> "$TMP/stderr.txt" 39 | 40 | cat << EOF > "$TMP/expected.txt" 41 | EOF 42 | 43 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 44 | -------------------------------------------------------------------------------- /vendor/core/cmake/common/variables.cmake: -------------------------------------------------------------------------------- 1 | # Get the list of languages defined in the project 2 | get_property(SOURCEMETA_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) 3 | 4 | # Compiler detection (C++) 5 | # TODO: Detect compilers on programming languages other than C++ 6 | if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") 7 | set(SOURCEMETA_COMPILER_LLVM ON) 8 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 9 | set(SOURCEMETA_COMPILER_GCC ON) 10 | elseif(MSVC) 11 | set(SOURCEMETA_COMPILER_MSVC ON) 12 | endif() 13 | 14 | if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") 15 | set(SOURCEMETA_OS_MACOS ON) 16 | # It seems that in some cases, `LINUX` is not set on GNU/Linux on WSL 17 | elseif(LINUX OR CMAKE_SYSTEM_NAME STREQUAL "Linux") 18 | set(SOURCEMETA_OS_LINUX ON) 19 | elseif(WIN32) 20 | set(SOURCEMETA_OS_WINDOWS ON) 21 | elseif(${CMAKE_SYSTEM_NAME} MATCHES ".*BSD") 22 | set(SOURCEMETA_OS_BSD ON) 23 | endif() 24 | -------------------------------------------------------------------------------- /test/compile/pass_yaml.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.yaml" 11 | $schema: https://json-schema.org/draft/2020-12/schema 12 | $id: https://example.com 13 | $ref: '#/$defs/string' 14 | $defs: 15 | string: { type: string } 16 | EOF 17 | 18 | "$1" compile "$TMP/schema.yaml" > "$TMP/template.json" 19 | 20 | cat << 'EOF' > "$TMP/expected.json" 21 | [ 22 | false, 23 | true, 24 | [ "", "https://example.com" ], 25 | [ 26 | [ 27 | 51, 28 | "/$ref", 29 | "", 30 | "#/$ref", 31 | 2, 32 | [ 0 ], 33 | [ 34 | [ 35 | 11, 36 | "/type", 37 | "", 38 | "#/$defs/string/type", 39 | 2, 40 | [ 8, 4 ] 41 | ] 42 | ] 43 | ] 44 | ] 45 | ] 46 | EOF 47 | 48 | diff "$TMP/template.json" "$TMP/expected.json" 49 | -------------------------------------------------------------------------------- /test/test/fail_not_object.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/test.json" 11 | [ 12 | { 13 | "target": "https://json-schema.org/draft/2020-12/schema", 14 | "tests": [ 15 | { 16 | "valid": true, 17 | "data": {} 18 | }, 19 | { 20 | "valid": true, 21 | "data": { "type": 1 } 22 | } 23 | ] 24 | } 25 | ] 26 | EOF 27 | 28 | "$1" test "$TMP/test.json" 1> "$TMP/output.txt" 2>&1 \ 29 | && CODE="$?" || CODE="$?" 30 | test "$CODE" = "1" || exit 1 31 | 32 | cat << EOF > "$TMP/expected.txt" 33 | $(realpath "$TMP")/test.json: 34 | error: The test document must be an object 35 | at file path $(realpath "$TMP")/test.json 36 | 37 | Learn more here: https://github.com/sourcemeta/jsonschema/blob/main/docs/test.markdown 38 | EOF 39 | 40 | diff "$TMP/output.txt" "$TMP/expected.txt" 41 | -------------------------------------------------------------------------------- /test/test/fail_test_case_data_and_data_path.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/test.json" 11 | { 12 | "target": "http://json-schema.org/draft-04/schema#", 13 | "tests": [ 14 | { 15 | "valid": true, 16 | "data": {}, 17 | "dataPath": "./foo.json" 18 | } 19 | ] 20 | } 21 | EOF 22 | 23 | "$1" test "$TMP/test.json" 1> "$TMP/output.txt" 2>&1 \ 24 | && CODE="$?" || CODE="$?" 25 | test "$CODE" = "1" || exit 1 26 | 27 | cat << EOF > "$TMP/expected.txt" 28 | $(realpath "$TMP")/test.json: 29 | error: Test case documents must contain either a \`data\` or \`dataPath\` property, but not both 30 | at test case #1 31 | at file path $(realpath "$TMP")/test.json 32 | 33 | Learn more here: https://github.com/sourcemeta/jsonschema/blob/main/docs/test.markdown 34 | EOF 35 | 36 | diff "$TMP/output.txt" "$TMP/expected.txt" 37 | -------------------------------------------------------------------------------- /test/test/fail_test_case_non_boolean_valid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/test.json" 11 | { 12 | "target": "http://json-schema.org/draft-04/schema#", 13 | "tests": [ 14 | { 15 | "data": {}, 16 | "valid": 1 17 | }, 18 | { 19 | "valid": true, 20 | "data": {} 21 | } 22 | ] 23 | } 24 | EOF 25 | 26 | "$1" test "$TMP/test.json" 1> "$TMP/output.txt" 2>&1 \ 27 | && CODE="$?" || CODE="$?" 28 | test "$CODE" = "1" || exit 1 29 | 30 | cat << EOF > "$TMP/expected.txt" 31 | $(realpath "$TMP")/test.json: 32 | error: The test case document \`valid\` property must be a boolean 33 | at test case #1 34 | at file path $(realpath "$TMP")/test.json 35 | 36 | Learn more here: https://github.com/sourcemeta/jsonschema/blob/main/docs/test.markdown 37 | EOF 38 | 39 | diff "$TMP/output.txt" "$TMP/expected.txt" 40 | -------------------------------------------------------------------------------- /test/validate/fail_jsonl_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | cat << 'EOF' > "$TMP/schema.json" 11 | { 12 | "$schema": "http://json-schema.org/draft-04/schema#", 13 | "type": "array" 14 | } 15 | EOF 16 | 17 | cat << 'EOF' > "$TMP/instance.jsonl" 18 | { "foo": 1 } 19 | { "foo": 2 } 20 | { "foo": 3 } 21 | EOF 22 | 23 | "$1" validate "$TMP/schema.json" "$TMP/instance.jsonl" 2>"$TMP/stderr.txt" \ 24 | && EXIT_CODE="$?" || EXIT_CODE="$?" 25 | test "$EXIT_CODE" = "2" || exit 1 26 | 27 | cat << EOF > "$TMP/expected.txt" 28 | fail: $(realpath "$TMP")/instance.jsonl (entry #1) 29 | 30 | { 31 | "foo": 1 32 | } 33 | 34 | error: Schema validation failure 35 | The value was expected to be of type array but it was of type object 36 | at instance location "" 37 | at evaluate path "/type" 38 | EOF 39 | 40 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 41 | -------------------------------------------------------------------------------- /test/validate/fail_no_schema.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -o errexit 4 | set -o nounset 5 | 6 | TMP="$(mktemp -d)" 7 | clean() { rm -rf "$TMP"; } 8 | trap clean EXIT 9 | 10 | "$1" validate 2>"$TMP/stderr.txt" && EXIT_CODE="$?" || EXIT_CODE="$?" 11 | test "$EXIT_CODE" = "1" || exit 1 12 | 13 | cat << 'EOF' > "$TMP/expected.txt" 14 | error: This command expects a path to a schema and a path to an 15 | instance to validate against the schema 16 | 17 | For example: jsonschema validate path/to/schema.json path/to/instance.json 18 | EOF 19 | 20 | diff "$TMP/stderr.txt" "$TMP/expected.txt" 21 | 22 | # JSON error 23 | "$1" validate --json > "$TMP/stdout.txt" 2>&1 && EXIT_CODE="$?" || EXIT_CODE="$?" 24 | test "$EXIT_CODE" = "1" || exit 1 25 | 26 | cat << 'EOF' > "$TMP/expected.txt" 27 | { 28 | "error": "This command expects a path to a schema and a path to an\ninstance to validate against the schema" 29 | } 30 | EOF 31 | 32 | diff "$TMP/stdout.txt" "$TMP/expected.txt" 33 | -------------------------------------------------------------------------------- /vendor/jsonbinpack/src/numeric/include/sourcemeta/jsonbinpack/numeric_zigzag.h: -------------------------------------------------------------------------------- 1 | #ifndef SOURCEMETA_JSONBINPACK_NUMERIC_ZIGZAG_H_ 2 | #define SOURCEMETA_JSONBINPACK_NUMERIC_ZIGZAG_H_ 3 | 4 | #include // std::abs 5 | #include // std::uint64_t, std::int64_t 6 | 7 | namespace sourcemeta::jsonbinpack { 8 | 9 | /// @ingroup numeric 10 | constexpr auto zigzag_encode(const std::int64_t value) noexcept 11 | -> std::uint64_t { 12 | if (value >= 0) { 13 | return static_cast(value * 2); 14 | } 15 | 16 | return (static_cast(std::abs(value)) * 2) - 1; 17 | } 18 | 19 | /// @ingroup numeric 20 | constexpr auto zigzag_decode(const std::uint64_t value) noexcept 21 | -> std::int64_t { 22 | if (value % 2 == 0) { 23 | return static_cast(value / 2); 24 | } 25 | 26 | return -(static_cast((value + 1) / 2)); 27 | } 28 | 29 | } // namespace sourcemeta::jsonbinpack 30 | 31 | #endif 32 | --------------------------------------------------------------------------------