You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A common pattern (at least for me) is something like this:
(I'm using YAML here for ease of typing)
id: MySchemaproperties:
- name:
type: string
- children:
type: arrayitems:
$ref: "#"#Reference to this schema
This should validate a document where each object has a list of child objects that are of the same schema type as the parent object.
"Out of the box" valijson crashes with a stack-overflow, however I found a simple hack that enables this use case.
In schema_parser.h - makeOrReuseSchema:
if (actualDocumentUri && (!currentScope || *actualDocumentUri != *currentScope)) {
// Removed for brevity
}
// ADDEDelseif (*actualDocumentUri == *currentScope)
{
// Recursive document, return the parent schemareturn &rootSchema;
}
This seems to work and handles the trivial example above.
A more robust solution would be capable of detecting any cyclic schema references. A simple solution would be an enhanced fetchDoc signature that would allow users to return a valijson::Schema document instead of an adapter document, pushing the problem to the user.
Thoughts?
The text was updated successfully, but these errors were encountered:
A common pattern (at least for me) is something like this:
(I'm using YAML here for ease of typing)
This should validate a document where each object has a list of child objects that are of the same schema type as the parent object.
"Out of the box" valijson crashes with a stack-overflow, however I found a simple hack that enables this use case.
In
schema_parser.h - makeOrReuseSchema
:This seems to work and handles the trivial example above.
A more robust solution would be capable of detecting any cyclic schema references. A simple solution would be an enhanced
fetchDoc
signature that would allow users to return avalijson::Schema
document instead of an adapter document, pushing the problem to the user.Thoughts?
The text was updated successfully, but these errors were encountered: