Revert "fix(schemav2validator): conditionally strip @context/@type based on schema properties"
The fix in the previous PR is no longer required because the protocol is changed to solve the root cause, reverting this change.
This commit is contained in:
@@ -383,22 +383,12 @@ func (c *schemaCache) validateReferencedObject(
|
|||||||
return fmt.Errorf("at %s: %w", obj.Path, err)
|
return fmt.Errorf("at %s: %w", obj.Path, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strip @context and @type only if the schema does not declare them as properties.
|
// Strip JSON-LD metadata before validation
|
||||||
// Some schemas explicitly require these fields; stripping them in that case
|
domainData := make(map[string]interface{}, len(obj.Data)-2)
|
||||||
// would cause a "missing required field" validation error.
|
|
||||||
schemaProps := schema.Value.Properties
|
|
||||||
_, contextInSchema := schemaProps["@context"]
|
|
||||||
_, typeInSchema := schemaProps["@type"]
|
|
||||||
|
|
||||||
domainData := make(map[string]interface{}, len(obj.Data))
|
|
||||||
for k, v := range obj.Data {
|
for k, v := range obj.Data {
|
||||||
if k == "@context" && !contextInSchema {
|
if k != "@context" && k != "@type" {
|
||||||
continue
|
domainData[k] = v
|
||||||
}
|
}
|
||||||
if k == "@type" && !typeInSchema {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
domainData[k] = v
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate domain-specific data against schema
|
// Validate domain-specific data against schema
|
||||||
|
|||||||
Reference in New Issue
Block a user