Coder Social home page Coder Social logo

Comments (15)

RicoSuter avatar RicoSuter commented on July 16, 2024

Looks correct to me, can you post exception details?

from njsonschema.

dyetube avatar dyetube commented on July 16, 2024

It says "ArrayItemNotValid"
screenshot
Does this screenshot help or do you need more info?

from njsonschema.

RicoSuter avatar RicoSuter commented on July 16, 2024

You have a validation error in the filters property not in the values property... Can you post its data and schema as well?

from njsonschema.

RicoSuter avatar RicoSuter commented on July 16, 2024

Clarification: JSON Schema does not know dictionaries. The schema describes an object which can have any properties (i.e. the dictionary keys) of type object (i.e. the dictionary values)... Because the property is nullable, its JSON Schema type can be null or object (as described).

from njsonschema.

dyetube avatar dyetube commented on July 16, 2024

Post the wrong screenshot. I know I do have an error there, I've got that fixed. maybe this screenshot will help better?

screenshot2

screenshot3

from njsonschema.

RicoSuter avatar RicoSuter commented on July 16, 2024

Ok, I see the problem. Probably the .NET string is not recognized as JSON Schema object...

from njsonschema.

dyetube avatar dyetube commented on July 16, 2024

The reason it can be null or object is that I didn't make it required. If it is Null, I get no errors, I only get errors when I populate it with key:value pairs as an object.

from njsonschema.

RicoSuter avatar RicoSuter commented on July 16, 2024

I have to implement a Unit Test... I'll report back...

from njsonschema.

dyetube avatar dyetube commented on July 16, 2024

Ok. Thanks!

from njsonschema.

RicoSuter avatar RicoSuter commented on July 16, 2024

According to http://jsonschemalint.com/draft4/ the JSON Schema validation is correct for the given data:

image

So we have to change the JSON Schema generator...

from njsonschema.

RicoSuter avatar RicoSuter commented on July 16, 2024

I've added the following unit test:

    public class DictTest
    {
        public Dictionary<string, object> values { get; set; }
    }

    [TestMethod]
    public void When_dictionary_value_is_null_then_string_values_are_allowed()
    {
        //// Arrange
        var schema = JsonSchema4.FromType<DictTest>();
        var schemaData = schema.ToJson();

        var data = @"{
            ""values"": { 
                ""key"": ""value"", 
            }
        }";

        //// Act
        var errors = schema.Validate(data);

        //// Assert
        Assert.AreEqual(0, errors.Count);
    }

Is this correct?

from njsonschema.

RicoSuter avatar RicoSuter commented on July 16, 2024

Commit: 6406618

from njsonschema.

RicoSuter avatar RicoSuter commented on July 16, 2024

v2.11 now available via NuGet, please try with this version and report if it works...

from njsonschema.

dyetube avatar dyetube commented on July 16, 2024

Sorry it took a while to get back with you on this. Yes, this fixed the issue and now dictionary works correctly.

from njsonschema.

RicoSuter avatar RicoSuter commented on July 16, 2024

Nice. Thx for reporting the issue and using the library...

from njsonschema.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.