|
14 | 14 | #include <memory>
|
15 | 15 | #include <set>
|
16 | 16 | #include <sstream>
|
| 17 | +#include <string> |
17 | 18 |
|
18 | 19 | using nlohmann::json;
|
19 | 20 | using nlohmann::json_patch;
|
@@ -308,11 +309,31 @@ class root_schema
|
308 | 309 | break;
|
309 | 310 | } while (1);
|
310 | 311 |
|
311 |
| - for (const auto &file : files_) |
312 |
| - if (file.second.unresolved.size() != 0) |
| 312 | + for (const auto &file : files_) { |
| 313 | + if (file.second.unresolved.size() != 0) { |
| 314 | + // Build a representation of the undefined |
| 315 | + // references as a list of comma-separated strings. |
| 316 | + auto n_urefs = file.second.unresolved.size(); |
| 317 | + std::string urefs = "["; |
| 318 | + |
| 319 | + decltype(n_urefs) counter = 0; |
| 320 | + for (const auto &p : file.second.unresolved) { |
| 321 | + urefs += p.first; |
| 322 | + |
| 323 | + if (counter != n_urefs - 1u) { |
| 324 | + urefs += ", "; |
| 325 | + } |
| 326 | + |
| 327 | + ++counter; |
| 328 | + } |
| 329 | + |
| 330 | + urefs += "]"; |
| 331 | + |
313 | 332 | throw std::invalid_argument("after all files have been parsed, '" +
|
314 | 333 | (file.first == "" ? "<root>" : file.first) +
|
315 |
| - "' has still undefined references."); |
| 334 | + "' has still the following undefined references: " + urefs); |
| 335 | + } |
| 336 | + } |
316 | 337 | }
|
317 | 338 |
|
318 | 339 | void validate(const json::json_pointer &ptr,
|
@@ -929,8 +950,8 @@ class boolean : public schema
|
929 | 950 | {
|
930 | 951 | if (!true_) { // false schema
|
931 | 952 | // empty array
|
932 |
| - //switch (instance.type()) { |
933 |
| - //case json::value_t::array: |
| 953 | + // switch (instance.type()) { |
| 954 | + // case json::value_t::array: |
934 | 955 | // if (instance.size() != 0) // valid false-schema
|
935 | 956 | // e.error(ptr, instance, "false-schema required empty array");
|
936 | 957 | // return;
|
|
0 commit comments