Merge remote-tracking branch 'origin/master' into v6-and-v7-support

This commit is contained in:
Tristan Penman 2020-06-03 19:54:48 +10:00
commit 8febb456f4
4 changed files with 17 additions and 10 deletions

View File

@ -15,13 +15,13 @@ namespace internal {
namespace json_pointer { namespace json_pointer {
/** /**
* @brief Replace all occurrences of `search` with `replace`. Modifies `subject` in place * @brief Replace all occurrences of `search` with `replace`. Modifies `subject` in place.
* *
* @param subject string to operate on * @param subject string to operate on
* @param search string to search * @param search string to search
* @param replace replacement string * @param replace replacement string
*/ */
inline void replace_all_inplace(std::string& subject, const char* search, inline void replaceAllInPlace(std::string& subject, const char* search,
const char* replace) const char* replace)
{ {
size_t pos = 0; size_t pos = 0;
@ -94,8 +94,8 @@ inline std::string extractReferenceToken(std::string::const_iterator begin,
std::string token(begin, end); std::string token(begin, end);
// Replace JSON Pointer-specific escaped character sequences // Replace JSON Pointer-specific escaped character sequences
replace_all_inplace(token, "~1", "/"); replaceAllInPlace(token, "~1", "/");
replace_all_inplace(token, "~0", "~"); replaceAllInPlace(token, "~0", "~");
// Replace %-encoded character sequences with their actual characters // Replace %-encoded character sequences with their actual characters
for (size_t n = token.find('%'); n != std::string::npos; for (size_t n = token.find('%'); n != std::string::npos;

View File

@ -967,9 +967,16 @@ public:
if (!additionalPropertiesSubschema) { if (!additionalPropertiesSubschema) {
if (propertiesMatched.size() != target.getObjectSize()) { if (propertiesMatched.size() != target.getObjectSize()) {
if (results) { if (results) {
results->pushError(context, "Object contains properties " std::string unwanted;
for (const typename AdapterType::ObjectMember m : object) {
if (propertiesMatched.find(m.first) == propertiesMatched.end()) {
unwanted = m.first;
break;
}
}
results->pushError(context, "Object contains a property "
"that could not be validated using 'properties' " "that could not be validated using 'properties' "
"or 'additionalProperties' constraints"); "or 'additionalProperties' constraints: '" + unwanted + "'.");
} }
return false; return false;

View File

@ -12,7 +12,7 @@ TEST_F(TestJsonCppAdapter, BasicArrayIteration)
{ {
const unsigned int numElements = 10; const unsigned int numElements = 10;
// Create a rapidjson document that consists of an array of numbers // Create a jsoncpp document that consists of an array of numbers
Json::Value document(Json::arrayValue); Json::Value document(Json::arrayValue);
for (unsigned int i = 0; i < numElements; i++) { for (unsigned int i = 0; i < numElements; i++) {
document.append(Json::Value(i)); document.append(Json::Value(i));
@ -46,7 +46,7 @@ TEST_F(TestJsonCppAdapter, BasicObjectIteration)
{ {
const unsigned int numElements = 10; const unsigned int numElements = 10;
// Create a rapidjson document that consists of an object that maps numeric // Create a jsoncpp document that consists of an object that maps numeric
// strings their corresponding numeric values // strings their corresponding numeric values
Json::Value document(Json::objectValue); Json::Value document(Json::objectValue);
for (unsigned int i = 0; i < numElements; i++) { for (unsigned int i = 0; i < numElements; i++) {

View File

@ -12,7 +12,7 @@ TEST_F(TestPropertyTreeAdapter, BasicArrayIteration)
{ {
const unsigned int numElements = 10; const unsigned int numElements = 10;
// Create a boost property that is equivalent to a JSON array containing a // Create a boost property tree that is equivalent to a JSON array containing a
// list of numbers. // list of numbers.
boost::property_tree::ptree document; boost::property_tree::ptree document;
for (unsigned int i = 0; i < numElements; i++) { for (unsigned int i = 0; i < numElements; i++) {
@ -50,7 +50,7 @@ TEST_F(TestPropertyTreeAdapter, BasicObjectIteration)
{ {
const unsigned int numElements = 10; const unsigned int numElements = 10;
// Create a rapidjson document that consists of an object that maps numeric // Create a boost property tree that consists of an object that maps numeric
// strings their corresponding numeric values // strings their corresponding numeric values
boost::property_tree::ptree document; boost::property_tree::ptree document;
for (unsigned int i = 0; i < numElements; i++) { for (unsigned int i = 0; i < numElements; i++) {