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 {
/**
* @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 search string to search
* @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)
{
size_t pos = 0;
@ -94,8 +94,8 @@ inline std::string extractReferenceToken(std::string::const_iterator begin,
std::string token(begin, end);
// Replace JSON Pointer-specific escaped character sequences
replace_all_inplace(token, "~1", "/");
replace_all_inplace(token, "~0", "~");
replaceAllInPlace(token, "~1", "/");
replaceAllInPlace(token, "~0", "~");
// Replace %-encoded character sequences with their actual characters
for (size_t n = token.find('%'); n != std::string::npos;

View File

@ -967,9 +967,16 @@ public:
if (!additionalPropertiesSubschema) {
if (propertiesMatched.size() != target.getObjectSize()) {
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' "
"or 'additionalProperties' constraints");
"or 'additionalProperties' constraints: '" + unwanted + "'.");
}
return false;

View File

@ -12,7 +12,7 @@ TEST_F(TestJsonCppAdapter, BasicArrayIteration)
{
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);
for (unsigned int i = 0; i < numElements; i++) {
document.append(Json::Value(i));
@ -46,7 +46,7 @@ TEST_F(TestJsonCppAdapter, BasicObjectIteration)
{
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
Json::Value document(Json::objectValue);
for (unsigned int i = 0; i < numElements; i++) {

View File

@ -12,7 +12,7 @@ TEST_F(TestPropertyTreeAdapter, BasicArrayIteration)
{
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.
boost::property_tree::ptree document;
for (unsigned int i = 0; i < numElements; i++) {
@ -50,7 +50,7 @@ TEST_F(TestPropertyTreeAdapter, BasicObjectIteration)
{
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
boost::property_tree::ptree document;
for (unsigned int i = 0; i < numElements; i++) {