Manatee.Json icon indicating copy to clipboard operation
Manatee.Json copied to clipboard

additionalProperties of additionalProperties

Open amosonn opened this issue 5 years ago • 2 comments

Describe the bug additionalProperties inside an additionalProperties subschema is not properly validated.

To Reproduce

using System;
using Manatee.Json;
using Manatee.Json.Schema;
using Manatee.Json.Serialization;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var schemaStr = @"
{
  ""$schema"": ""http://json-schema.org/draft-07/schema#"",
  ""additionalProperties"": {
      ""additionalProperties"": false
  }
}";
            var jsonStr = @"
{
  ""abc"": {
    ""abc"": ""abc""
  }
}";
            var serializer = new JsonSerializer();
            var schema = serializer.Deserialize<JsonSchema>(JsonValue.Parse(schemaStr));
            var json = JsonValue.Parse(jsonStr);
            var validation = schema.Validate(json);
            Console.WriteLine("{0}", serializer.Serialize(validation));
        }
    }
}

Should give false, gives true.

Version

  • Manatee.Json 13.0.3

Additional context This problem doesn't exist in JsonSchema.NET.

amosonn avatar Oct 20 '20 10:10 amosonn

What does that schema do? Instances can have properties so long as they're not an object or have no properties?

Also, I'm winding down support for this library in favor of the new one. Happy to pull in a PR if you want to try and fix it, though.

gregsdennis avatar Oct 20 '20 19:10 gregsdennis

Yes, that what it means. It's of course contrived, but it is just a minimal reproduction from a larger schema I had. I think that also other subschemas inside additionalProperties aren't properly checked.

As mentioned above, this bug doesn't exist in the newer one, and I guess we'll switch soon. But I thought if I found it, I might as well document it.

amosonn avatar Oct 20 '20 23:10 amosonn