Skip to content
This repository has been archived by the owner on Feb 15, 2021. It is now read-only.

additionalProperties of additionalProperties #287

Open
amosonn opened this issue Oct 20, 2020 · 2 comments
Open

additionalProperties of additionalProperties #287

amosonn opened this issue Oct 20, 2020 · 2 comments

Comments

@amosonn
Copy link

amosonn commented Oct 20, 2020

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.

@gregsdennis
Copy link
Owner

gregsdennis commented Oct 20, 2020

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.

@amosonn
Copy link
Author

amosonn commented Oct 20, 2020

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants