check the type constraint first because others might rely on it

This commit is contained in:
Marco Porsch 2023-08-23 15:41:15 +02:00
parent f1902801d6
commit f716227d0a

View File

@ -624,6 +624,14 @@ private:
updatedScope = currentScope; updatedScope = currentScope;
} }
// Add the type constraint first to be the first one to check because other constraints may rely on it
if ((itr = object.find("type")) != object.end()) {
rootSchema.addConstraintToSubschema(
makeTypeConstraint(rootSchema, rootNode, itr->second, updatedScope, nodePath + "/type", fetchDoc,
docCache, schemaCache),
&subschema);
}
if ((itr = object.find("allOf")) != object.end()) { if ((itr = object.find("allOf")) != object.end()) {
rootSchema.addConstraintToSubschema( rootSchema.addConstraintToSubschema(
makeAllOfConstraint(rootSchema, rootNode, itr->second, makeAllOfConstraint(rootSchema, rootNode, itr->second,
@ -925,13 +933,6 @@ private:
} }
} }
if ((itr = object.find("type")) != object.end()) {
rootSchema.addConstraintToSubschema(
makeTypeConstraint(rootSchema, rootNode, itr->second, updatedScope, nodePath + "/type", fetchDoc,
docCache, schemaCache),
&subschema);
}
if ((itr = object.find("uniqueItems")) != object.end()) { if ((itr = object.find("uniqueItems")) != object.end()) {
opt::optional<constraints::UniqueItemsConstraint> constraint = makeUniqueItemsConstraint(itr->second); opt::optional<constraints::UniqueItemsConstraint> constraint = makeUniqueItemsConstraint(itr->second);
if (constraint) { if (constraint) {