Skip to content

"additionalProperties" being validated as a property  #39

@nabinked

Description

@nabinked

Describe the bug
The additionalProperties keyword is being treated as a property.

To Reproduce

using System;
using System.Text.Json;
using Json.Schema;

var schema = @"{
  ""$schema"": ""http://json-schema.org/draft-07/schema#"",
  ""additionalProperties"": false
}";

var data = @"{
  ""prop1"":""val""
}";

var jsonSchema = JsonSchema.FromText(schema);
var validationResult = jsonSchema.Validate(JsonDocument.Parse(data).RootElement, new ValidationOptions { OutputFormat = OutputFormat.Basic });
Console.WriteLine(JsonSerializer.Serialize(validationResult));

//outputs
{
    "valid": false,
    "keywordLocation": "#/additionalProperties/$false",
    "instanceLocation": "#/prop1",
    "error": "All values fail against the false schema"
}

Expected behaviour
The error should indicate that additional properties is present.
image

Desktop (please complete the following information):

  • OS: Windows 10
  • .NET 5 (SDK 5.0.100)
  • Nuget Version [e.g. 22]
    image

Metadata

Metadata

Assignees

No one assigned

    Labels

    not-a-bugA reported issue is actually working as designedwontfixThis will not be worked on

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions