MQTTSuite
Loading...
Searching...
No Matches
issue-93.cpp File Reference
#include <nlohmann/json-schema.hpp>
#include <fstream>
#include <iostream>
Include dependency graph for issue-93.cpp:

Go to the source code of this file.

Functions

static void loader (const json_uri &uri, json &schema)
int main (void)

Variables

static const auto expected_patch
static const auto instance

Function Documentation

◆ loader()

void loader ( const json_uri & uri,
json & schema )
static

Definition at line 25 of file issue-93.cpp.

26{
27 std::string filename = "./" + uri.path();
28 std::ifstream lf(filename);
29 if (!lf.good())
30 throw std::invalid_argument("could not open " + uri.url() + " tried with " + filename);
31 try {
32 lf >> schema;
33 } catch (const std::exception &e) {
34 throw e;
35 }
36}
std::string url() const
const std::string & path() const
auto schema
Definition id-ref.cpp:69

References nlohmann::json_uri::path(), and nlohmann::json_uri::url().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( void )

Definition at line 38 of file issue-93.cpp.

39{
41
42 std::fstream f("blueprints.schema.json");
43
45 f >> schema;
46
47 validator.set_root_schema(schema);
48
49 auto missing_default_patch = validator.validate(instance);
50
51 std::cerr << missing_default_patch << "\n";
52 std::cerr << expected_patch << "\n";
53
54 return missing_default_patch != expected_patch;
55}
nlohmann::json_schema::json_validator validator
nlohmann::json json
static const auto instance
Definition issue-93.cpp:14
static const auto expected_patch
Definition issue-93.cpp:10
static void loader(const json_uri &uri, json &schema)

References expected_patch, instance, nlohmann::json_schema::json_validator::json_validator(), loader(), nlohmann::json_schema::json_validator::set_root_schema(), and nlohmann::json_schema::json_validator::validate().

Here is the call graph for this function:

Variable Documentation

◆ expected_patch

const auto expected_patch
static
Initial value:
= R"(
[{"op":"add","path":"/0/renderable/bg","value":"Black"}]
)"_json

Definition at line 10 of file issue-93.cpp.

Referenced by main().

◆ instance

const auto instance
static
Initial value:
= R"(
[
{
"name":"player",
"renderable": {
"fg":"White"
}
}
]
)"_json

Definition at line 14 of file issue-93.cpp.

Referenced by main().