mirror of
https://github.com/tristanpenman/valijson.git
synced 2025-03-03 12:58:03 +01:00
Allow SchemaParser to track path to current node in recursive populateSchema calls
This commit is contained in:
parent
cdabbe5549
commit
71a6b64e0e
@ -76,7 +76,7 @@ public:
|
||||
boost::optional<typename FetchDocumentFunction<AdapterType>::Type>
|
||||
fetchDoc = boost::none)
|
||||
{
|
||||
populateSchema(node, node, schema, boost::none, fetchDoc, NULL, NULL);
|
||||
populateSchema(node, node, schema, boost::none, "", fetchDoc, NULL, NULL);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -95,6 +95,7 @@ private:
|
||||
* @param node Reference to node to parse
|
||||
* @param schema Reference to Schema to populate
|
||||
* @param currentScope URI for current resolution scope
|
||||
* @param nodePath JSON Pointer representing path to current node
|
||||
* @param fetchDoc Function to fetch remote JSON documents (optional)
|
||||
* @param parentSchema Optional pointer to the parent schema, used to
|
||||
* support required keyword in Draft 3.
|
||||
@ -107,6 +108,7 @@ private:
|
||||
const AdapterType &node,
|
||||
Schema &schema,
|
||||
boost::optional<std::string> currentScope,
|
||||
const std::string &nodePath,
|
||||
boost::optional<typename FetchDocumentFunction<AdapterType>::Type>
|
||||
fetchDoc = boost::none,
|
||||
Schema *parentSchema = NULL,
|
||||
@ -129,7 +131,8 @@ private:
|
||||
}
|
||||
const std::string &jsonRef = itr->second.asString();
|
||||
populateSchemaUsingJsonReference(jsonRef, rootNode, node,
|
||||
schema, currentScope, fetchDoc, parentSchema, ownName);
|
||||
schema, currentScope, nodePath, fetchDoc,
|
||||
parentSchema, ownName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -145,17 +148,18 @@ private:
|
||||
|
||||
if ((itr = object.find("allOf")) != object.end()) {
|
||||
schema.addConstraint(makeAllOfConstraint(rootNode, itr->second,
|
||||
currentScope, fetchDoc));
|
||||
currentScope, nodePath + "/allOf", fetchDoc));
|
||||
}
|
||||
|
||||
if ((itr = object.find("anyOf")) != object.end()) {
|
||||
schema.addConstraint(makeAnyOfConstraint(rootNode, itr->second,
|
||||
currentScope, fetchDoc));
|
||||
currentScope, nodePath + "/anyOf", fetchDoc));
|
||||
}
|
||||
|
||||
if ((itr = object.find("dependencies")) != object.end()) {
|
||||
schema.addConstraint(makeDependenciesConstraint(rootNode,
|
||||
itr->second, currentScope, fetchDoc));
|
||||
itr->second, currentScope, nodePath + "/dependencies",
|
||||
fetchDoc));
|
||||
}
|
||||
|
||||
if ((itr = object.find("description")) != object.end()) {
|
||||
@ -190,7 +194,8 @@ private:
|
||||
schema.addConstraint(makeItemsConstraint(rootNode,
|
||||
itemsItr != object.end() ? &itemsItr->second : NULL,
|
||||
additionalitemsItr != object.end() ? &additionalitemsItr->second : NULL,
|
||||
currentScope, fetchDoc));
|
||||
currentScope, nodePath + "/items",
|
||||
nodePath + "/additionalItems", fetchDoc));
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,12 +255,12 @@ private:
|
||||
|
||||
if ((itr = object.find("not")) != object.end()) {
|
||||
schema.addConstraint(makeNotConstraint(rootNode, itr->second,
|
||||
currentScope, fetchDoc));
|
||||
currentScope, nodePath + "/not", fetchDoc));
|
||||
}
|
||||
|
||||
if ((itr = object.find("oneOf")) != object.end()) {
|
||||
schema.addConstraint(makeOneOfConstraint(rootNode, itr->second,
|
||||
currentScope, fetchDoc));
|
||||
currentScope, nodePath + "/oneOf", fetchDoc));
|
||||
}
|
||||
|
||||
if ((itr = object.find("pattern")) != object.end()) {
|
||||
@ -276,7 +281,9 @@ private:
|
||||
propertiesItr != object.end() ? &propertiesItr->second : NULL,
|
||||
patternPropertiesItr != object.end() ? &patternPropertiesItr->second : NULL,
|
||||
additionalPropertiesItr != object.end() ? &additionalPropertiesItr->second : NULL,
|
||||
currentScope, fetchDoc, &schema));
|
||||
currentScope, nodePath + "/properties",
|
||||
nodePath + "/patternProperties",
|
||||
nodePath + "/additionalProperties", fetchDoc, &schema));
|
||||
}
|
||||
}
|
||||
|
||||
@ -305,7 +312,7 @@ private:
|
||||
|
||||
if ((itr = object.find("type")) != object.end()) {
|
||||
schema.addConstraint(makeTypeConstraint(rootNode, itr->second,
|
||||
currentScope, fetchDoc));
|
||||
currentScope, nodePath + "/type", fetchDoc));
|
||||
}
|
||||
|
||||
if ((itr = object.find("uniqueItems")) != object.end()) {
|
||||
@ -329,6 +336,7 @@ private:
|
||||
* @param node Reference to node to parse
|
||||
* @param schema Reference to Schema to populate
|
||||
* @param currentScope URI for current resolution scope
|
||||
* @param nodePath JSON Pointer representing path to current node
|
||||
* @param fetchDoc Function to fetch remote JSON documents (optional)
|
||||
* @param parentSchema Optional pointer to the parent schema, used to
|
||||
* support required keyword in Draft 3.
|
||||
@ -342,6 +350,7 @@ private:
|
||||
const AdapterType &node,
|
||||
Schema &schema,
|
||||
boost::optional<std::string> currentScope,
|
||||
const std::string &nodePath,
|
||||
boost::optional<typename FetchDocumentFunction<AdapterType>::Type>
|
||||
fetchDoc,
|
||||
Schema *parentSchema = NULL,
|
||||
@ -380,7 +389,7 @@ private:
|
||||
|
||||
// Resolve reference against retrieved document
|
||||
populateSchema<AdapterType>(ref, ref, schema, currentScope,
|
||||
fetchDoc, parentSchema, ownName);
|
||||
nodePath, fetchDoc, parentSchema, ownName);
|
||||
|
||||
} else {
|
||||
const AdapterType &ref = internal::json_pointer::resolveJsonPointer(
|
||||
@ -388,7 +397,7 @@ private:
|
||||
|
||||
// Resolve reference against current document
|
||||
populateSchema<AdapterType>(rootNode, ref, schema, currentScope,
|
||||
fetchDoc, parentSchema, ownName);
|
||||
nodePath, fetchDoc, parentSchema, ownName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -400,6 +409,7 @@ private:
|
||||
* document; used for recursive parsing of schemas
|
||||
* @param node JSON node containing an array of child schemas
|
||||
* @param currentScope URI for current resolution scope
|
||||
* @param nodePath JSON Pointer representing path to current node
|
||||
* @param fetchDoc Function to fetch remote JSON documents (optional)
|
||||
*
|
||||
* @return pointer to a new AllOfConstraint object that belongs to the
|
||||
@ -410,6 +420,7 @@ private:
|
||||
const AdapterType &rootNode,
|
||||
const AdapterType &node,
|
||||
boost::optional<std::string> currentScope,
|
||||
const std::string &nodePath,
|
||||
boost::optional<typename FetchDocumentFunction<AdapterType>::Type > fetchDoc)
|
||||
{
|
||||
if (!node.maybeArray()) {
|
||||
@ -417,11 +428,15 @@ private:
|
||||
}
|
||||
|
||||
constraints::AllOfConstraint::Schemas childSchemas;
|
||||
int index = 0;
|
||||
BOOST_FOREACH ( const AdapterType schemaNode, node.asArray() ) {
|
||||
if (schemaNode.maybeObject()) {
|
||||
const std::string childPath = nodePath + "/" +
|
||||
boost::lexical_cast<std::string>(index);
|
||||
childSchemas.push_back(new Schema);
|
||||
populateSchema<AdapterType>(rootNode, schemaNode,
|
||||
childSchemas.back(), currentScope, fetchDoc);
|
||||
childSchemas.back(), currentScope, childPath, fetchDoc);
|
||||
index++;
|
||||
} else {
|
||||
throw std::runtime_error("Expected array element to be an object value in 'allOf' constraint.");
|
||||
}
|
||||
@ -439,6 +454,7 @@ private:
|
||||
* document; used for recursive parsing of schemas
|
||||
* @param node JSON node containing an array of child schemas
|
||||
* @param currentScope URI for current resolution scope
|
||||
* @param nodePath JSON Pointer representing path to current node
|
||||
* @param fetchDoc Function to fetch remote JSON documents (optional)
|
||||
*
|
||||
* @return pointer to a new AnyOfConstraint object that belongs to the
|
||||
@ -449,6 +465,7 @@ private:
|
||||
const AdapterType &rootNode,
|
||||
const AdapterType &node,
|
||||
boost::optional<std::string> currentScope,
|
||||
const std::string &nodePath,
|
||||
boost::optional<typename FetchDocumentFunction<AdapterType>::Type > fetchDoc)
|
||||
{
|
||||
if (!node.maybeArray()) {
|
||||
@ -456,11 +473,15 @@ private:
|
||||
}
|
||||
|
||||
constraints::AnyOfConstraint::Schemas childSchemas;
|
||||
int index = 0;
|
||||
BOOST_FOREACH ( const AdapterType schemaNode, node.asArray() ) {
|
||||
if (schemaNode.maybeObject()) {
|
||||
const std::string childPath = nodePath + "/" +
|
||||
boost::lexical_cast<std::string>(index);
|
||||
childSchemas.push_back(new Schema);
|
||||
populateSchema<AdapterType>(rootNode, schemaNode,
|
||||
childSchemas.back(), currentScope, fetchDoc);
|
||||
childSchemas.back(), currentScope, childPath, fetchDoc);
|
||||
index++;
|
||||
} else {
|
||||
throw std::runtime_error("Expected array element to be an object value in 'anyOf' constraint.");
|
||||
}
|
||||
@ -496,6 +517,7 @@ private:
|
||||
* @param node JSON node containing an object that defines a
|
||||
* mapping of properties to their dependencies.
|
||||
* @param currentScope URI for current resolution scope
|
||||
* @param nodePath JSON Pointer representing path to current node
|
||||
* @param fetchDoc Function to fetch remote JSON documents (optional)
|
||||
*
|
||||
* @return pointer to a new DependencyConstraint that belongs to the
|
||||
@ -506,6 +528,7 @@ private:
|
||||
const AdapterType &rootNode,
|
||||
const AdapterType &node,
|
||||
boost::optional<std::string> currentScope,
|
||||
const std::string &nodePath,
|
||||
boost::optional<typename FetchDocumentFunction<AdapterType>::Type >
|
||||
fetchDoc)
|
||||
{
|
||||
@ -548,7 +571,7 @@ private:
|
||||
// Parse dependent subschema
|
||||
Schema &childSchema = pdsm[member.first];
|
||||
populateSchema<AdapterType>(rootNode, member.second,
|
||||
childSchema, currentScope, fetchDoc);
|
||||
childSchema, currentScope, nodePath, fetchDoc);
|
||||
|
||||
// If we're supposed to be parsing a Draft3 schema, then the value
|
||||
// of the dependency mapping can also be a string containing the
|
||||
@ -593,18 +616,23 @@ private:
|
||||
/**
|
||||
* @brief Make a new ItemsConstraint object.
|
||||
*
|
||||
* @param rootNode Reference to the node from which JSON
|
||||
* References will be resolved when they refer
|
||||
* to the current document; used for recursive
|
||||
* parsing of schemas
|
||||
* @param items Optional pointer to a JSON node containing
|
||||
* an object mapping property names to schemas.
|
||||
* @param additionalItems Optional pointer to a JSON node containing
|
||||
* an additional properties schema or a boolean
|
||||
* value.
|
||||
* @param currentScope URI for current resolution scope
|
||||
* @param fetchDoc Function to fetch remote JSON documents
|
||||
* (optional)
|
||||
* @param rootNode Reference to the node from which JSON
|
||||
* References will be resolved when they refer
|
||||
* to the current document; used for recursive
|
||||
* parsing of schemas
|
||||
* @param items Optional pointer to a JSON node containing
|
||||
* an object mapping property names to
|
||||
* schemas.
|
||||
* @param additionalItems Optional pointer to a JSON node containing
|
||||
* an additional properties schema or a
|
||||
* boolean value.
|
||||
* @param currentScope URI for current resolution scope
|
||||
* @param itemsPath JSON Pointer representing the path to
|
||||
* the 'items' node
|
||||
* @param additionalItemsPath JSON Pointer representing the path to
|
||||
* the 'additionalItems' node
|
||||
* @param fetchDoc Function to fetch remote JSON documents
|
||||
* (optional)
|
||||
*
|
||||
* @return pointer to a new ItemsConstraint that belongs to the caller
|
||||
*/
|
||||
@ -614,6 +642,8 @@ private:
|
||||
const AdapterType *items,
|
||||
const AdapterType *additionalItems,
|
||||
boost::optional<std::string> currentScope,
|
||||
const std::string &itemsPath,
|
||||
const std::string &additionalItemsPath,
|
||||
boost::optional<typename FetchDocumentFunction<AdapterType>::Type >
|
||||
fetchDoc)
|
||||
{
|
||||
@ -633,8 +663,9 @@ private:
|
||||
// then it should be parsed into a Schema object, which will be
|
||||
// used to validate additional array items.
|
||||
additionalItemsSchema.reset(new Schema());
|
||||
populateSchema<AdapterType>(rootNode, *additionalItems,
|
||||
*additionalItemsSchema, currentScope, fetchDoc);
|
||||
populateSchema<AdapterType>(
|
||||
rootNode, *additionalItems, *additionalItemsSchema,
|
||||
currentScope, additionalItemsPath, fetchDoc);
|
||||
} else {
|
||||
// Any other format for the additionalItems property will result
|
||||
// in an exception being thrown.
|
||||
@ -658,11 +689,15 @@ private:
|
||||
// contain a list of child schemas which will be used to
|
||||
// validate the values at the corresponding indexes in a target
|
||||
// array.
|
||||
int index = 0;
|
||||
BOOST_FOREACH( const AdapterType v, items->getArray() ) {
|
||||
const std::string childPath = itemsPath + "/" +
|
||||
boost::lexical_cast<std::string>(index);
|
||||
itemSchemas.push_back(new Schema());
|
||||
Schema &childSchema = itemSchemas.back();
|
||||
populateSchema<AdapterType>(rootNode, v, childSchema,
|
||||
currentScope, fetchDoc);
|
||||
currentScope, childPath, fetchDoc);
|
||||
index++;
|
||||
}
|
||||
|
||||
// Create an ItemsConstraint object using the appropriate
|
||||
@ -680,7 +715,7 @@ private:
|
||||
// additionalItems constraint will be ignored.
|
||||
Schema childSchema;
|
||||
populateSchema<AdapterType>(rootNode, *items, childSchema,
|
||||
currentScope, fetchDoc);
|
||||
currentScope, itemsPath, fetchDoc);
|
||||
if (additionalItemsSchema) {
|
||||
return new constraints::ItemsConstraint(childSchema, *additionalItemsSchema);
|
||||
} else {
|
||||
@ -951,6 +986,7 @@ private:
|
||||
* document; used for recursive parsing of schemas
|
||||
* @param node JSON node containing a schema
|
||||
* @param currentScope URI for current resolution scope
|
||||
* @param nodePath JSON Pointer representing path to current node
|
||||
* @param fetchDoc Function to fetch remote JSON documents (optional)
|
||||
*
|
||||
* @return pointer to a new NotConstraint object that belongs to the caller
|
||||
@ -960,12 +996,13 @@ private:
|
||||
const AdapterType &rootNode,
|
||||
const AdapterType &node,
|
||||
boost::optional<std::string> currentScope,
|
||||
const std::string &nodePath,
|
||||
boost::optional<typename FetchDocumentFunction<AdapterType>::Type > fetchDoc)
|
||||
{
|
||||
if (node.maybeObject()) {
|
||||
Schema childSchema;
|
||||
populateSchema<AdapterType>(rootNode, node, childSchema,
|
||||
currentScope, fetchDoc);
|
||||
currentScope, nodePath, fetchDoc);
|
||||
return new constraints::NotConstraint(childSchema);
|
||||
}
|
||||
|
||||
@ -980,6 +1017,7 @@ private:
|
||||
* document; used for recursive parsing of schemas
|
||||
* @param node JSON node containing an array of child schemas
|
||||
* @param currentScope URI for current resolution scope
|
||||
* @param nodePath JSON Pointer representing path to current node
|
||||
* @param fetchDoc Function to fetch remote JSON documents (optional)
|
||||
*
|
||||
* @return pointer to a new OneOfConstraint that belongs to the caller
|
||||
@ -989,14 +1027,19 @@ private:
|
||||
const AdapterType &rootNode,
|
||||
const AdapterType &node,
|
||||
boost::optional<std::string> currentScope,
|
||||
const std::string &nodePath,
|
||||
boost::optional<typename FetchDocumentFunction<AdapterType>::Type >
|
||||
fetchDoc)
|
||||
{
|
||||
constraints::OneOfConstraint::Schemas childSchemas;
|
||||
int index = 0;
|
||||
BOOST_FOREACH ( const AdapterType schemaNode, node.getArray() ) {
|
||||
const std::string childPath = nodePath + "/" +
|
||||
boost::lexical_cast<std::string>(index);
|
||||
childSchemas.push_back(new Schema);
|
||||
populateSchema<AdapterType>(rootNode, schemaNode,
|
||||
childSchemas.back(), currentScope, fetchDoc);
|
||||
childSchemas.back(), currentScope, childPath, fetchDoc);
|
||||
index++;
|
||||
}
|
||||
|
||||
/// @todo: bypass deep copy of the child schemas
|
||||
@ -1021,25 +1064,31 @@ private:
|
||||
/**
|
||||
* @brief Make a new Properties object.
|
||||
*
|
||||
* @param rootNode Reference to the node from which JSON
|
||||
* References will be resolved when they
|
||||
* refer to the current document; used for
|
||||
* recursive parsing of schemas
|
||||
* @param properties Optional pointer to a JSON node containing
|
||||
* an object mapping property names to
|
||||
* schemas.
|
||||
* @param patternProperties Optional pointer to a JSON node containing
|
||||
* an object mapping pattern property names
|
||||
* to schemas.
|
||||
* @param additionalProperties Optional pointer to a JSON node containing
|
||||
* an additional properties schema or a
|
||||
* boolean value.
|
||||
* @param currentScope URI for current resolution scope
|
||||
* @param fetchDoc Function to fetch remote JSON documents
|
||||
* (optional)
|
||||
* @param parentSchema Optional pointer to the Schema of the
|
||||
* parent object, to support the 'required'
|
||||
* keyword in Draft 3 of JSON Schema.
|
||||
* @param rootNode Reference to the node from which JSON
|
||||
* References will be resolved when they
|
||||
* refer to the current document; used
|
||||
* for recursive parsing of schemas
|
||||
* @param properties Optional pointer to a JSON node
|
||||
* containing an object mapping property
|
||||
* names to schemas.
|
||||
* @param patternProperties Optional pointer to a JSON node
|
||||
* containing an object mapping pattern
|
||||
* property names to schemas.
|
||||
* @param additionalProperties Optional pointer to a JSON node
|
||||
* containing an additional properties
|
||||
* schema or a boolean value.
|
||||
* @param currentScope URI for current resolution scope
|
||||
* @param propertiesPath JSON Pointer representing the path to
|
||||
* the 'properties' node
|
||||
* @param patternPropertiesPath JSON Pointer representing the path to
|
||||
* the 'patternProperties' node
|
||||
* @param additionalPropertiesPath JSON Pointer representing the path to
|
||||
* the 'additionalProperties' node
|
||||
* @param fetchDoc Function to fetch remote JSON
|
||||
* documents (optional)
|
||||
* @param parentSchema Optional pointer to the Schema of the
|
||||
* parent object, needed to support the
|
||||
* 'required' keyword in Draft 3.
|
||||
*
|
||||
* @return pointer to a new Properties that belongs to the caller
|
||||
*/
|
||||
@ -1050,6 +1099,9 @@ private:
|
||||
const AdapterType *patternProperties,
|
||||
const AdapterType *additionalProperties,
|
||||
boost::optional<std::string> currentScope,
|
||||
const std::string &propertiesPath,
|
||||
const std::string &patternPropertiesPath,
|
||||
const std::string &additionalPropertiesPath,
|
||||
boost::optional<typename FetchDocumentFunction<AdapterType>::Type >
|
||||
fetchDoc,
|
||||
Schema *parentSchema)
|
||||
@ -1063,10 +1115,12 @@ private:
|
||||
if (properties) {
|
||||
BOOST_FOREACH( const Member m, properties->getObject() ) {
|
||||
const std::string &propertyName = m.first;
|
||||
const std::string childPath = propertiesPath + "/" +
|
||||
propertyName;
|
||||
Schema &childSchema = propertySchemas[propertyName];
|
||||
populateSchema<AdapterType>(
|
||||
rootNode, m.second, childSchema, currentScope, fetchDoc,
|
||||
parentSchema, &propertyName);
|
||||
rootNode, m.second, childSchema, currentScope,
|
||||
childPath, fetchDoc, parentSchema, &propertyName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1076,10 +1130,12 @@ private:
|
||||
if (patternProperties) {
|
||||
BOOST_FOREACH( const Member m, patternProperties->getObject() ) {
|
||||
const std::string &propertyName = m.first;
|
||||
const std::string childPath = patternPropertiesPath + "/" +
|
||||
propertyName;
|
||||
Schema &childSchema = patternPropertySchemas[propertyName];
|
||||
populateSchema<AdapterType>(
|
||||
rootNode, m.second, childSchema, currentScope, fetchDoc,
|
||||
parentSchema, &propertyName);
|
||||
rootNode, m.second, childSchema, currentScope,
|
||||
childPath, fetchDoc, parentSchema, &propertyName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1105,7 +1161,8 @@ private:
|
||||
// a child schema.
|
||||
additionalPropertiesSchema.reset(new Schema());
|
||||
populateSchema<AdapterType>(rootNode, *additionalProperties,
|
||||
*additionalPropertiesSchema, currentScope, fetchDoc);
|
||||
*additionalPropertiesSchema, currentScope,
|
||||
additionalPropertiesPath, fetchDoc);
|
||||
} else {
|
||||
// All other types are invalid
|
||||
throw std::runtime_error("Invalid type for 'additionalProperties' constraint.");
|
||||
@ -1120,8 +1177,8 @@ private:
|
||||
// If an additionalProperties schema has been created, construct a
|
||||
// new PropertiesConstraint object using that schema.
|
||||
return new constraints::PropertiesConstraint(
|
||||
propertySchemas, patternPropertySchemas,
|
||||
*additionalPropertiesSchema);
|
||||
propertySchemas, patternPropertySchemas,
|
||||
*additionalPropertiesSchema);
|
||||
}
|
||||
|
||||
return new constraints::PropertiesConstraint(
|
||||
@ -1192,6 +1249,7 @@ private:
|
||||
* document; used for recursive parsing of schemas
|
||||
* @param node Node containing the name of a JSON type
|
||||
* @param currentScope URI for current resolution scope
|
||||
* @param nodePath JSON Pointer representing path to current node
|
||||
* @param fetchDoc Function to fetch remote JSON documents (optional)
|
||||
|
||||
*
|
||||
@ -1202,6 +1260,7 @@ private:
|
||||
const AdapterType &rootNode,
|
||||
const AdapterType &node,
|
||||
boost::optional<std::string> currentScope,
|
||||
const std::string &nodePath,
|
||||
boost::optional<typename FetchDocumentFunction<AdapterType>::Type >
|
||||
fetchDoc)
|
||||
{
|
||||
@ -1218,6 +1277,7 @@ private:
|
||||
jsonTypes.insert(jsonType);
|
||||
|
||||
} else if (node.isArray()) {
|
||||
int index = 0;
|
||||
BOOST_FOREACH( const AdapterType v, node.getArray() ) {
|
||||
if (v.isString()) {
|
||||
const TC::JsonType jsonType = TC::jsonTypeFromString(v.getString());
|
||||
@ -1226,18 +1286,20 @@ private:
|
||||
}
|
||||
jsonTypes.insert(jsonType);
|
||||
} else if (v.isObject() && version == kDraft3) {
|
||||
// Schema!
|
||||
const std::string childPath = nodePath + "/" +
|
||||
boost::lexical_cast<std::string>(index);
|
||||
schemas.push_back(new Schema());
|
||||
populateSchema<AdapterType>(rootNode, v, schemas.back(),
|
||||
currentScope, fetchDoc);
|
||||
currentScope, childPath, fetchDoc);
|
||||
} else {
|
||||
throw std::runtime_error("Type name should be a string.");
|
||||
}
|
||||
index++;
|
||||
}
|
||||
} else if (node.isObject() && version == kDraft3) {
|
||||
schemas.push_back(new Schema());
|
||||
populateSchema<AdapterType>(rootNode, node, schemas.back(),
|
||||
currentScope, fetchDoc);
|
||||
currentScope, nodePath, fetchDoc);
|
||||
} else {
|
||||
throw std::runtime_error("Type name should be a string.");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user